mirror of
https://github.com/MoxiFoxi411/PlaneRun.git
synced 2026-11-08 19:34:55 +00:00
First commit
This commit is contained in:
commit
3f9baae36e
975 files changed
+242181
No files matched your search
@@ -0,0 +1,55 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class FlareLauncher : MonoBehaviour
|
||||
{
|
||||
public GameObject flareProjectile;
|
||||
//public int startingRounds;
|
||||
private int rounds;
|
||||
private float countdown;
|
||||
public float firerate;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (rounds > 0)
|
||||
{
|
||||
if(countdown > 0)
|
||||
{
|
||||
countdown-=Time.deltaTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
Instantiate(flareProjectile, transform.position, transform.rotation);
|
||||
countdown = firerate;
|
||||
rounds--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ActivateFlares(int r)
|
||||
{
|
||||
PickupManager pm = GameObject.FindObjectOfType<PickupManager>();
|
||||
|
||||
pm.flarePickup.AddFlareCount(r * 2);
|
||||
|
||||
GameObject[] missles = GameObject.FindGameObjectsWithTag("missle");
|
||||
|
||||
foreach(GameObject m in missles)
|
||||
{
|
||||
if (m.GetComponent<missle>() != null)
|
||||
{
|
||||
m.GetComponent<missle>().SearchForFlares();
|
||||
}
|
||||
}
|
||||
|
||||
rounds = r;
|
||||
countdown = 0;
|
||||
}
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94123bfa98e78d444b48130aabe87729
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,51 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class FrendlyMissle : MonoBehaviour
|
||||
{
|
||||
public float speed = 60;
|
||||
public float rotSpeed = 100;
|
||||
public Transform target;
|
||||
public GameObject explosion;
|
||||
public float timer;
|
||||
public GameObject trail;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
timer -= Time.deltaTime;
|
||||
|
||||
if (timer <= 0)
|
||||
{
|
||||
Instantiate(explosion, transform.position, transform.rotation);
|
||||
Destroy(gameObject, 0);
|
||||
}
|
||||
|
||||
transform.Translate(0, 0, speed * Time.deltaTime);
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
Vector3 direction = target.position - transform.position;
|
||||
Quaternion rotation = Quaternion.LookRotation(direction);
|
||||
transform.rotation = Quaternion.Lerp(transform.rotation, rotation, rotSpeed * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.CompareTag("missle"))
|
||||
{
|
||||
trail.transform.SetParent(null);
|
||||
trail.GetComponent<missleTrail>().StartTimer();
|
||||
Instantiate(explosion, transform.position, transform.rotation);
|
||||
Destroy(gameObject, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f4466a5adb8a454d9b5b508a994dc17
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,31 @@
|
||||
using GoogleMobileAds;
|
||||
using GoogleMobileAds.Api;
|
||||
using GoogleMobileAds.Sample;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class GoogleMobileAdsScript : MonoBehaviour
|
||||
{
|
||||
[SerializeField] RewardedAdController rewardedAdController;
|
||||
[SerializeField] InterstitialAdController InterstitialAdController;
|
||||
|
||||
[SerializeField] shopManager shopManager;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
// Initialize the Google Mobile Ads SDK.
|
||||
MobileAds.Initialize((InitializationStatus initStatus) =>
|
||||
{
|
||||
// This callback is called once the MobileAds SDK is initialized.
|
||||
|
||||
rewardedAdController.LoadAd();
|
||||
|
||||
InterstitialAdController.LoadAd();
|
||||
|
||||
shopManager.EnableRewardedAdButton(true);
|
||||
});
|
||||
|
||||
MobileAds.RaiseAdEventsOnUnityMainThread = true;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 982fe3a0957e075499ada64429264fcd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,147 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using GoogleMobileAds.Api;
|
||||
|
||||
namespace GoogleMobileAds.Sample
|
||||
{
|
||||
/// <summary>
|
||||
/// Demonstrates how to use Google Mobile Ads interstitial ads.
|
||||
/// </summary>
|
||||
public class InterstitialAdController : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// UI element activated when an ad is ready to show.
|
||||
/// </summary>
|
||||
|
||||
// These ad units are configured to always serve test ads.
|
||||
#if UNITY_ANDROID
|
||||
private const string _adUnitId = "ca-app-pub-2626773788355001/6080131766";
|
||||
#elif UNITY_IPHONE
|
||||
private const string _adUnitId = "ca-app-pub-3940256099942544/4411468910";
|
||||
#else
|
||||
private const string _adUnitId = "unused";
|
||||
#endif
|
||||
|
||||
private InterstitialAd _interstitialAd;
|
||||
|
||||
/// <summary>
|
||||
/// Loads the ad.
|
||||
/// </summary>
|
||||
public void LoadAd()
|
||||
{
|
||||
// Clean up the old ad before loading a new one.
|
||||
if (_interstitialAd != null)
|
||||
{
|
||||
DestroyAd();
|
||||
}
|
||||
|
||||
Debug.Log("Loading interstitial ad.");
|
||||
|
||||
// Create our request used to load the ad.
|
||||
var adRequest = new AdRequest();
|
||||
|
||||
// Send the request to load the ad.
|
||||
InterstitialAd.Load(_adUnitId, adRequest, (InterstitialAd ad, LoadAdError error) =>
|
||||
{
|
||||
// If the operation failed with a reason.
|
||||
if (error != null)
|
||||
{
|
||||
Debug.LogError("Interstitial ad failed to load an ad with error : " + error);
|
||||
return;
|
||||
}
|
||||
// If the operation failed for unknown reasons.
|
||||
// This is an unexpected error, please report this bug if it happens.
|
||||
if (ad == null)
|
||||
{
|
||||
Debug.LogError("Unexpected error: Interstitial load event fired with null ad and null error.");
|
||||
return;
|
||||
}
|
||||
|
||||
// The operation completed successfully.
|
||||
Debug.Log("Interstitial ad loaded with response : " + ad.GetResponseInfo());
|
||||
_interstitialAd = ad;
|
||||
|
||||
// Register to ad events to extend functionality.
|
||||
RegisterEventHandlers(ad);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the ad.
|
||||
/// </summary>
|
||||
public void ShowAd()
|
||||
{
|
||||
if (_interstitialAd != null && _interstitialAd.CanShowAd())
|
||||
{
|
||||
Debug.Log("Showing interstitial ad.");
|
||||
_interstitialAd.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Interstitial ad is not ready yet.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Destroys the ad.
|
||||
/// </summary>
|
||||
public void DestroyAd()
|
||||
{
|
||||
if (_interstitialAd != null)
|
||||
{
|
||||
Debug.Log("Destroying interstitial ad.");
|
||||
_interstitialAd.Destroy();
|
||||
_interstitialAd = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Logs the ResponseInfo.
|
||||
/// </summary>
|
||||
public void LogResponseInfo()
|
||||
{
|
||||
if (_interstitialAd != null)
|
||||
{
|
||||
var responseInfo = _interstitialAd.GetResponseInfo();
|
||||
UnityEngine.Debug.Log(responseInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private void RegisterEventHandlers(InterstitialAd ad)
|
||||
{
|
||||
// Raised when the ad is estimated to have earned money.
|
||||
ad.OnAdPaid += (AdValue adValue) =>
|
||||
{
|
||||
Debug.Log(String.Format("Interstitial ad paid {0} {1}.",
|
||||
adValue.Value,
|
||||
adValue.CurrencyCode));
|
||||
};
|
||||
// Raised when an impression is recorded for an ad.
|
||||
ad.OnAdImpressionRecorded += () =>
|
||||
{
|
||||
Debug.Log("Interstitial ad recorded an impression.");
|
||||
};
|
||||
// Raised when a click is recorded for an ad.
|
||||
ad.OnAdClicked += () =>
|
||||
{
|
||||
Debug.Log("Interstitial ad was clicked.");
|
||||
};
|
||||
// Raised when an ad opened full screen content.
|
||||
ad.OnAdFullScreenContentOpened += () =>
|
||||
{
|
||||
Debug.Log("Interstitial ad full screen content opened.");
|
||||
};
|
||||
// Raised when the ad closed full screen content.
|
||||
ad.OnAdFullScreenContentClosed += () =>
|
||||
{
|
||||
Debug.Log("Interstitial ad full screen content closed.");
|
||||
};
|
||||
// Raised when the ad failed to open full screen content.
|
||||
ad.OnAdFullScreenContentFailed += (AdError error) =>
|
||||
{
|
||||
Debug.LogError("Interstitial ad failed to open full screen content with error : "
|
||||
+ error);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1c53eb44491dd34193dc711afd12431
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,181 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MenuControler : MonoBehaviour
|
||||
{
|
||||
public spawner spawnerScript;
|
||||
public UiManager uiManager;
|
||||
public PlayerMovement playerMovement;
|
||||
public PLayerLife playerLife;
|
||||
public shopManager shopmanager;
|
||||
public soundManager soundmanager;
|
||||
public score Score;
|
||||
public PickupManager pickupManager;
|
||||
public GameObject playerModels;
|
||||
public bool playing;
|
||||
public GameObject menu_UI;
|
||||
public GameObject skins_UI;
|
||||
public GameObject game_UI;
|
||||
public Transform cam;
|
||||
private bool inShop;
|
||||
private float z;
|
||||
private Vector2 cameraZoomRange = new Vector2(-442.7f, -277.8f);
|
||||
|
||||
[SerializeField]
|
||||
PlayGamesManager PGM;
|
||||
|
||||
|
||||
[SerializeField] private GameObject SigninUI;
|
||||
|
||||
[SerializeField] private GameObject UserUI;
|
||||
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
spawnerScript.enabled = false;
|
||||
menu_UI.SetActive(true);
|
||||
skins_UI.SetActive(false);
|
||||
game_UI.SetActive(false);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if(inShop && z<1)
|
||||
{
|
||||
z += Time.deltaTime * 2;
|
||||
}else if(!inShop && z>0)
|
||||
{
|
||||
z -= Time.deltaTime * 2;
|
||||
}
|
||||
cam.transform.localPosition = new Vector3(0f,0f,Mathf.Lerp(cameraZoomRange.x, cameraZoomRange.y, z));
|
||||
}
|
||||
|
||||
public void Play()
|
||||
{
|
||||
playerLife.life = true;
|
||||
uiManager.gameOver = false;
|
||||
uiManager.gameOverAnimPlayed = false;
|
||||
shopmanager.coinsGiven = false;
|
||||
soundmanager.PlayClick1();
|
||||
spawnerScript.enabled = true;
|
||||
inShop = false;
|
||||
playing = true;
|
||||
menu_UI.SetActive(false);
|
||||
skins_UI.SetActive(false);
|
||||
game_UI.SetActive(true);
|
||||
}
|
||||
|
||||
public void Skins()
|
||||
{
|
||||
soundmanager.PlayClick1();
|
||||
shopmanager.selectedSkin = shopmanager.equippedSkin;
|
||||
shopmanager.UpdateUI();
|
||||
shopmanager.UpdateButton();
|
||||
inShop = true;
|
||||
menu_UI.SetActive(false);
|
||||
skins_UI.SetActive(true);
|
||||
game_UI.SetActive(false);
|
||||
}
|
||||
|
||||
public void Menu()
|
||||
{
|
||||
if (Score.scoreAmount > Score.highscoreAmount && !uiManager.paused)
|
||||
{
|
||||
Score.highscore.SetActive(true);
|
||||
Score.highscoreAmount = Score.scoreAmount;
|
||||
PlayerPrefs.SetFloat("HighScore", Score.highscoreAmount);
|
||||
|
||||
// Save data
|
||||
PGM.OpenSave(true);
|
||||
|
||||
PGM.UpdateLeaderboardScore((int)Score.scoreAmount);
|
||||
|
||||
if (Score.scoreAmount >= 100)
|
||||
PGM.UnlockAchievement("warming_up");
|
||||
if(Score.scoreAmount >= 200)
|
||||
PGM.UnlockAchievement("on_fire");
|
||||
if (Score.scoreAmount >= 300)
|
||||
PGM.UnlockAchievement("untouchable");
|
||||
|
||||
PGM.UpdateLeaderboardScore((int)Score.scoreAmount);
|
||||
}
|
||||
|
||||
playing = false;
|
||||
|
||||
soundmanager.PlayClick1();
|
||||
|
||||
pickupManager.ClearPickups();
|
||||
|
||||
uiManager.Pause(false);
|
||||
|
||||
shopmanager.ShowSkin(shopmanager.equippedSkin);
|
||||
|
||||
playerMovement.gameObject.transform.position = Vector3.zero;
|
||||
playerMovement.gameObject.transform.rotation = Quaternion.Euler(0, 0, 0);
|
||||
playerModels.transform.rotation = Quaternion.Euler(0, 0, 0);
|
||||
|
||||
playerMovement.DontAllowMovement();
|
||||
|
||||
spawnerScript.enabled = false;
|
||||
|
||||
uiManager.gameOver = false;
|
||||
|
||||
KillAllEnemies();
|
||||
|
||||
playerMovement.enabled = true;
|
||||
playerLife.Hp = 3;
|
||||
|
||||
playerModels.SetActive(true);
|
||||
|
||||
inShop = false;
|
||||
playing = false;
|
||||
|
||||
menu_UI.SetActive(true);
|
||||
skins_UI.SetActive(false);
|
||||
game_UI.SetActive(false);
|
||||
uiManager.gameOverAnimPlayed = false;
|
||||
|
||||
Score.scoreAmount = 0;
|
||||
}
|
||||
|
||||
public void Quit()
|
||||
{
|
||||
//quit the game
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
void KillAllEnemies()
|
||||
{
|
||||
string[] str = { "missle", "shield", "speedBoost", "flare", "misslePickup" , "parachute"};
|
||||
foreach(string s in str)
|
||||
{
|
||||
GameObject[] enemies = GameObject.FindGameObjectsWithTag(s);
|
||||
foreach (GameObject enemy in enemies)
|
||||
{
|
||||
Destroy(enemy);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void ShowSignInUI(bool state)
|
||||
{
|
||||
if (!Application.isEditor)
|
||||
{
|
||||
SigninUI.SetActive(state);
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowUserUI(bool state)
|
||||
{
|
||||
if(!Application.isEditor)
|
||||
{
|
||||
UserUI.SetActive(state);
|
||||
menu_UI.SetActive(!state);
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1ef8df85395974b489a663fda2ebb823
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,105 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PLayerLife : MonoBehaviour
|
||||
{
|
||||
public float Hp = 3;
|
||||
public bool shieldEnabled;
|
||||
|
||||
public GameObject Hp3;
|
||||
public GameObject Hp2;
|
||||
public GameObject Hp1;
|
||||
public bool life;
|
||||
|
||||
public GameObject effect1;
|
||||
public GameObject effect2;
|
||||
|
||||
public GameObject gameOver;
|
||||
|
||||
public GameObject Cam;
|
||||
public Animator animCam;
|
||||
public bool Shake = false;
|
||||
|
||||
public PickupManager pickupManager;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
Shake = false;
|
||||
animCam = Cam.GetComponent<Animator>();
|
||||
effect1.SetActive(false);
|
||||
effect2.SetActive(false);
|
||||
life = true;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if(Hp == 3)
|
||||
{
|
||||
effect1.SetActive(false);
|
||||
effect2.SetActive(false);
|
||||
Hp3.SetActive(true);
|
||||
Hp2.SetActive(false);
|
||||
Hp1.SetActive(false);
|
||||
}
|
||||
if (Hp == 2)
|
||||
{
|
||||
effect1.SetActive(true);
|
||||
effect2.SetActive(false);
|
||||
Hp3.SetActive(false);
|
||||
Hp2.SetActive(true);
|
||||
Hp1.SetActive(false);
|
||||
}
|
||||
if (Hp == 1)
|
||||
{
|
||||
effect1.SetActive(true);
|
||||
effect2.SetActive(true);
|
||||
Hp3.SetActive(false);
|
||||
Hp2.SetActive(false);
|
||||
Hp1.SetActive(true);
|
||||
}
|
||||
if(Hp <= 0)
|
||||
{
|
||||
life = false;
|
||||
gameOver.SetActive(true);
|
||||
pickupManager.ClearPickups();
|
||||
}
|
||||
|
||||
if (Shake)
|
||||
{
|
||||
Handheld.Vibrate();
|
||||
Shake = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.CompareTag("missle"))
|
||||
{
|
||||
Shake = true;
|
||||
if (!shieldEnabled)
|
||||
{
|
||||
Hp -= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pickupManager.shieldPickup.DisableShield();
|
||||
}
|
||||
}
|
||||
|
||||
if (other.CompareTag("parachute"))
|
||||
{
|
||||
if(Hp < 3)
|
||||
{
|
||||
Hp += 1;
|
||||
|
||||
if (shieldEnabled)
|
||||
{
|
||||
pickupManager.shieldPickup.UpdateUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 10fe2a97fef34ca4f98574168e60f3da
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,348 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class PickupManager : MonoBehaviour
|
||||
{
|
||||
// 1 - shield | 2 - speedBoost | 3 - flare | 4 - missle
|
||||
public int currentPickup;
|
||||
|
||||
[SerializeField]
|
||||
public ShieldPickup shieldPickup;
|
||||
|
||||
[SerializeField]
|
||||
public SpeedBoostPickup speedBoostPickup;
|
||||
|
||||
[SerializeField]
|
||||
public FlarePickup flarePickup;
|
||||
|
||||
[SerializeField]
|
||||
public MisslePickup misslePickup;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
shieldPickup.Start();
|
||||
speedBoostPickup.Start();
|
||||
flarePickup.Start();
|
||||
misslePickup.Start();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if(shieldPickup.playerLife.shieldEnabled)
|
||||
shieldPickup.shieldObj.transform.rotation = Quaternion.Euler(0, 0, 0);
|
||||
}
|
||||
|
||||
void PickupPickedUp(int index)
|
||||
{
|
||||
if(index == 1)
|
||||
{
|
||||
shieldPickup.EnableShield();
|
||||
}
|
||||
else if(index == 2)
|
||||
{
|
||||
speedBoostPickup.ShowButton();
|
||||
}
|
||||
else if (index == 3)
|
||||
{
|
||||
flarePickup.ShowButton();
|
||||
}
|
||||
else if (index == 4)
|
||||
{
|
||||
misslePickup.ShowButton();
|
||||
}
|
||||
}
|
||||
|
||||
void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.tag == "shield" && !shieldPickup.playerLife.shieldEnabled)
|
||||
{
|
||||
Destroy(other.gameObject);
|
||||
PickupPickedUp(1);
|
||||
}
|
||||
|
||||
if (currentPickup == 0)
|
||||
{
|
||||
if (other.tag == "speedBoost")
|
||||
{
|
||||
currentPickup = 2;
|
||||
Destroy(other.gameObject);
|
||||
PickupPickedUp(currentPickup);
|
||||
}else if(other.tag == "flare")
|
||||
{
|
||||
currentPickup = 3;
|
||||
Destroy(other.gameObject);
|
||||
PickupPickedUp(currentPickup);
|
||||
}
|
||||
else if (other.tag == "misslePickup")
|
||||
{
|
||||
currentPickup = 4;
|
||||
Destroy(other.gameObject);
|
||||
PickupPickedUp(currentPickup);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ActivateSpeedBoost()
|
||||
{
|
||||
speedBoostPickup.EnableSpeedBoost();
|
||||
}
|
||||
|
||||
public void ActivateFlares()
|
||||
{
|
||||
flarePickup.EnableFlare();
|
||||
}
|
||||
|
||||
public void ActivateMissle()
|
||||
{
|
||||
misslePickup.EnableMissle();
|
||||
}
|
||||
|
||||
public void ShootMissle(Transform target)
|
||||
{
|
||||
if (missleEnabled)
|
||||
{
|
||||
FrendlyMissle missl = Instantiate(misslePickup.missle, misslePickup.shootPos.position, misslePickup.shootPos.rotation).GetComponent<FrendlyMissle>();
|
||||
missl.target = target;
|
||||
HideTargets();
|
||||
if (target.gameObject.GetComponent<helicopterEnemy>() != null)
|
||||
{
|
||||
target.gameObject.GetComponent<helicopterEnemy>().targetUItimer = 10;
|
||||
target.gameObject.GetComponent<helicopterEnemy>().targetUI.SetActive(true);
|
||||
target.gameObject.GetComponent<helicopterEnemy>().targetUI.GetComponent<RectTransform>().localScale = new Vector3(1f, 1f, 1f);
|
||||
target.gameObject.GetComponent<helicopterEnemy>().ChasedByPlayerMissle(missl.gameObject);
|
||||
}
|
||||
else if (target.gameObject.GetComponent<jetEnemy>() != null)
|
||||
{
|
||||
target.gameObject.GetComponent<jetEnemy>().targetUItimer = 10;
|
||||
target.gameObject.GetComponent<jetEnemy>().targetUI.SetActive(true);
|
||||
target.gameObject.GetComponent<jetEnemy>().targetUI.GetComponent<RectTransform>().localScale = new Vector3(1f, 1f, 1f);
|
||||
target.gameObject.GetComponent<jetEnemy>().ChasedByPlayerMissle(missl.gameObject);
|
||||
}
|
||||
else if (target.gameObject.GetComponent<missle>() != null)
|
||||
{
|
||||
target.gameObject.GetComponent<missle>().targetUItimer = 10;
|
||||
target.gameObject.GetComponent<missle>().targetUI.SetActive(true);
|
||||
target.gameObject.GetComponent<missle>().targetUI.GetComponent<RectTransform>().localScale = new Vector3(1f, 1f, 1f);
|
||||
target.gameObject.GetComponent<missle>().ChasedByPlayerMissle(missl.gameObject);
|
||||
}
|
||||
|
||||
currentPickup = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void ClearPickups()
|
||||
{
|
||||
misslePickup.missleButton.SetActive(false);
|
||||
flarePickup.flareButton.SetActive(false);
|
||||
speedBoostPickup.speedBoostButton.SetActive(false);
|
||||
currentPickup = 0;
|
||||
}
|
||||
|
||||
public bool missleEnabled;
|
||||
private Transform missleTarget;
|
||||
|
||||
public void EnableMissle()
|
||||
{
|
||||
helicopterEnemy[] heli = Object.FindObjectsOfType<helicopterEnemy>();
|
||||
jetEnemy[] jet = Object.FindObjectsOfType<jetEnemy>();
|
||||
missle[] kami = Object.FindObjectsOfType<missle>();
|
||||
|
||||
if (heli.Length > 0)
|
||||
foreach(helicopterEnemy heliItem in heli)
|
||||
{
|
||||
heliItem.GetComponent<helicopterEnemy>().ShowTargeting();
|
||||
}
|
||||
|
||||
if (jet.Length > 0)
|
||||
foreach (jetEnemy jetItem in jet)
|
||||
{
|
||||
jetItem.GetComponent<jetEnemy>().ShowTargeting();
|
||||
}
|
||||
|
||||
if (kami.Length > 0)
|
||||
foreach (missle kamiItem in kami)
|
||||
{
|
||||
kamiItem.GetComponent<missle>().ShowTargeting();
|
||||
}
|
||||
|
||||
missleEnabled = true;
|
||||
}
|
||||
|
||||
public void HideTargets()
|
||||
{
|
||||
helicopterEnemy[] heli = Object.FindObjectsOfType<helicopterEnemy>();
|
||||
jetEnemy[] jet = Object.FindObjectsOfType<jetEnemy>();
|
||||
missle[] kami = Object.FindObjectsOfType<missle>();
|
||||
|
||||
if (heli.Length > 0)
|
||||
foreach (helicopterEnemy heliItem in heli)
|
||||
{
|
||||
heliItem.GetComponent<helicopterEnemy>().HideTargeting();
|
||||
}
|
||||
|
||||
if (jet.Length > 0)
|
||||
foreach (jetEnemy jetItem in jet)
|
||||
{
|
||||
jetItem.GetComponent<jetEnemy>().HideTargeting();
|
||||
}
|
||||
|
||||
if (kami.Length > 0)
|
||||
foreach (missle kamiItem in kami)
|
||||
{
|
||||
kamiItem.GetComponent<missle>().HideTargeting();
|
||||
}
|
||||
|
||||
|
||||
missleEnabled = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class ShieldPickup
|
||||
{
|
||||
public PLayerLife playerLife;
|
||||
public Image[] ShieldUI;
|
||||
public GameObject shieldObj;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
foreach (Image shieldUI in ShieldUI)
|
||||
{
|
||||
shieldUI.gameObject.SetActive(false);
|
||||
}
|
||||
shieldObj.SetActive(false);
|
||||
}
|
||||
|
||||
public void EnableShield()
|
||||
{
|
||||
playerLife.shieldEnabled = true;
|
||||
shieldObj.SetActive(true);
|
||||
|
||||
if (playerLife.Hp == 1)
|
||||
ShieldUI[0].gameObject.SetActive(true);
|
||||
else if (playerLife.Hp == 2)
|
||||
ShieldUI[1].gameObject.SetActive(true);
|
||||
else
|
||||
ShieldUI[2].gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void DisableShield()
|
||||
{
|
||||
Debug.Log("Shield disabled!");
|
||||
playerLife.shieldEnabled = false;
|
||||
|
||||
foreach (Image shieldUI in ShieldUI)
|
||||
{
|
||||
shieldUI.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
shieldObj.SetActive(false);
|
||||
}
|
||||
|
||||
public void UpdateUI()
|
||||
{
|
||||
if (playerLife.Hp == 1)
|
||||
ShieldUI[0].gameObject.SetActive(true);
|
||||
else if (playerLife.Hp == 2)
|
||||
ShieldUI[1].gameObject.SetActive(true);
|
||||
else
|
||||
ShieldUI[2].gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SpeedBoostPickup
|
||||
{
|
||||
public PlayerMovement playerMovement;
|
||||
public GameObject speedBoostButton;
|
||||
public PickupManager pickupManager;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
speedBoostButton.SetActive(false);
|
||||
}
|
||||
|
||||
public void ShowButton()
|
||||
{
|
||||
speedBoostButton.SetActive(true);
|
||||
speedBoostButton.GetComponent<Animation>().Play();
|
||||
}
|
||||
|
||||
public void EnableSpeedBoost()
|
||||
{
|
||||
playerMovement.speedBoostTimer = 5;
|
||||
speedBoostButton.SetActive(false);
|
||||
pickupManager.currentPickup = 0;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class FlarePickup
|
||||
{
|
||||
public GameObject flareButton;
|
||||
public FlareLauncher flareLauncher;
|
||||
public PickupManager pickupManager;
|
||||
|
||||
public int numOfFlares;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
flareButton.SetActive(false);
|
||||
}
|
||||
|
||||
public void ShowButton()
|
||||
{
|
||||
flareButton.SetActive(true);
|
||||
flareButton.GetComponent<Animation>().Play();
|
||||
}
|
||||
|
||||
public void EnableFlare()
|
||||
{
|
||||
flareLauncher.ActivateFlares(2);
|
||||
flareButton.SetActive(false);
|
||||
pickupManager.currentPickup = 0;
|
||||
}
|
||||
|
||||
public void AddFlareCount(int n)
|
||||
{
|
||||
numOfFlares += n;
|
||||
}
|
||||
|
||||
public void RemoveFlareCount(int n)
|
||||
{
|
||||
numOfFlares -= n;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class MisslePickup
|
||||
{
|
||||
public GameObject missleButton;
|
||||
public PickupManager pickupManager;
|
||||
public Transform shootPos;
|
||||
public GameObject missle;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
missleButton.SetActive(false);
|
||||
}
|
||||
|
||||
public void ShowButton()
|
||||
{
|
||||
missleButton.SetActive(true);
|
||||
missleButton.GetComponent<Animation>().Play();
|
||||
}
|
||||
|
||||
public void EnableMissle()
|
||||
{
|
||||
missleButton.SetActive(false);
|
||||
pickupManager.EnableMissle();
|
||||
}
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 818831fd46c48f94786e436b1e8c0f31
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
// <copyright file="GPGSIds.cs" company="Google Inc.">
|
||||
// Copyright (C) 2015 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
///
|
||||
/// This file is automatically generated DO NOT EDIT!
|
||||
///
|
||||
/// These are the constants defined in the Play Games Console for Game Services
|
||||
/// Resources.
|
||||
///
|
||||
|
||||
namespace scripts
|
||||
{
|
||||
public static class PlaneRunGPGSIds
|
||||
{
|
||||
public const string achievement_untouchable = "CgkIrvSr9uUPEAIQBQ"; // <GPGSID>
|
||||
public const string achievement_warming_up = "CgkIrvSr9uUPEAIQAw"; // <GPGSID>
|
||||
public const string leaderboard_highscore = "CgkIrvSr9uUPEAIQAg"; // <GPGSID>
|
||||
public const string achievement_on_fire = "CgkIrvSr9uUPEAIQBA"; // <GPGSID>
|
||||
|
||||
}
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 460e280c81b1d454db21d4d9bb2b52a0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,247 @@
|
||||
using UnityEngine;
|
||||
using GooglePlayGames;
|
||||
using GooglePlayGames.BasicApi;
|
||||
using UnityEngine.SocialPlatforms;
|
||||
using System;
|
||||
using TMPro;
|
||||
using GooglePlayGames.BasicApi.SavedGame;
|
||||
using scripts;
|
||||
|
||||
|
||||
public class PlayGamesManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
TMP_Text nicknameText;
|
||||
|
||||
private score score;
|
||||
|
||||
[SerializeField]
|
||||
private shopManager shopManager;
|
||||
|
||||
[SerializeField]
|
||||
private MenuControler menuController;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_Text debugText;
|
||||
|
||||
[SerializeField]
|
||||
private GameObject LoadingUI;
|
||||
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
this.score = GetComponent<score>();
|
||||
|
||||
SignIn();
|
||||
}
|
||||
|
||||
#region signin
|
||||
|
||||
public void SignIn()
|
||||
{
|
||||
PlayGamesPlatform.Activate();
|
||||
PlayGamesPlatform.Instance.Authenticate(ProcessAuthentication);
|
||||
}
|
||||
|
||||
internal void ProcessAuthentication(SignInStatus status)
|
||||
{
|
||||
if (status == SignInStatus.Success)
|
||||
{
|
||||
// Continue with Play Games Services
|
||||
|
||||
string name = PlayGamesPlatform.Instance.GetUserDisplayName();
|
||||
|
||||
nicknameText.text = name;
|
||||
|
||||
menuController.ShowSignInUI(false);
|
||||
|
||||
OpenSave(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
menuController.ShowSignInUI(true);
|
||||
|
||||
// Disable your integration with Play Games Services or show a login button
|
||||
// to ask users to sign-in. Clicking it should call
|
||||
// PlayGamesPlatform.Instance.ManuallyAuthenticate(ProcessAuthentication).
|
||||
}
|
||||
}
|
||||
|
||||
public void ManualAuthentication()
|
||||
{
|
||||
PlayGamesPlatform.Instance.ManuallyAuthenticate(ProcessAuthentication);
|
||||
|
||||
menuController.ShowSignInUI(false);
|
||||
|
||||
OpenSave(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region save
|
||||
|
||||
private bool isSaving;
|
||||
|
||||
public void OpenSave(bool saving)
|
||||
{
|
||||
if (Social.localUser.authenticated)
|
||||
{
|
||||
isSaving = saving;
|
||||
((PlayGamesPlatform)Social.Active).SavedGame.OpenWithAutomaticConflictResolution("Save", DataSource.ReadCacheOrNetwork, ConflictResolutionStrategy.UseLongestPlaytime, SavedGameOpen);
|
||||
}
|
||||
}
|
||||
|
||||
private void SavedGameOpen(SavedGameRequestStatus status, ISavedGameMetadata metadata)
|
||||
{
|
||||
if (status == SavedGameRequestStatus.Success)
|
||||
{
|
||||
debugText.text += "Request successfull!\n";
|
||||
|
||||
if (isSaving) // Saving
|
||||
{
|
||||
debugText.text += "Saving...\n";
|
||||
|
||||
byte[] myData = System.Text.ASCIIEncoding.ASCII.GetBytes(GetSaveString());
|
||||
|
||||
SavedGameMetadataUpdate updateForMetadata = new SavedGameMetadataUpdate.Builder().WithUpdatedDescription("I have played my game at: " + DateTime.Now.ToString()).Build();
|
||||
|
||||
((PlayGamesPlatform)Social.Active).SavedGame.CommitUpdate(metadata, updateForMetadata, myData, SaveCallback);
|
||||
|
||||
debugText.text += "Saving...\n";
|
||||
}
|
||||
else // Loading
|
||||
{
|
||||
debugText.text += "loading...\n";
|
||||
|
||||
((PlayGamesPlatform)Social.Active).SavedGame.ReadBinaryData(metadata, LoadCallBack);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
debugText.text += "Request failed!\n";
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadCallBack(SavedGameRequestStatus status, byte[] data)
|
||||
{
|
||||
if (status == SavedGameRequestStatus.Success)
|
||||
{
|
||||
debugText.text += "Load request successfull!\n";
|
||||
|
||||
string loadedData = System.Text.ASCIIEncoding.ASCII.GetString(data);
|
||||
|
||||
LoadSavedString(loadedData);
|
||||
|
||||
debugText.text += "Data loaded!\n";
|
||||
|
||||
ShowLoadingUI(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
debugText.text += "Load request failed!\n";
|
||||
|
||||
ShowLoadingUI(false);
|
||||
|
||||
menuController.ShowSignInUI(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadSavedString(string loadedData)
|
||||
{
|
||||
int highscore = 0;
|
||||
|
||||
int coins = 0;
|
||||
|
||||
string ownedPlanes = "0";
|
||||
|
||||
if (loadedData.Length > 0)
|
||||
{
|
||||
string[] cloudStringArr = loadedData.Split('|');
|
||||
|
||||
highscore = int.Parse(cloudStringArr[0]);
|
||||
|
||||
coins = int.Parse(cloudStringArr[1]);
|
||||
|
||||
ownedPlanes = cloudStringArr[2];
|
||||
|
||||
}
|
||||
|
||||
score.SetHighscore(highscore);
|
||||
|
||||
shopManager.coins = coins;
|
||||
|
||||
shopManager.ConvertOwnedPlanes(ownedPlanes);
|
||||
}
|
||||
|
||||
private string GetSaveString()
|
||||
{
|
||||
string dataToSave = "";
|
||||
|
||||
dataToSave += ((int)score.highscoreAmount).ToString() + "|" + shopManager.coins.ToString() + "|" + shopManager.GetOwnedPlanesString();
|
||||
|
||||
return dataToSave;
|
||||
}
|
||||
|
||||
private void SaveCallback(SavedGameRequestStatus status, ISavedGameMetadata metadata)
|
||||
{
|
||||
if (status == SavedGameRequestStatus.Success)
|
||||
{
|
||||
Debug.Log("Successfully saved to the cloud\n");
|
||||
|
||||
debugText.text += "Successfully saved to the cloud!\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Failed to save to cloud\n");
|
||||
|
||||
debugText.text += "Failed to save to cloud!\n";
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowLoadingUI(bool show)
|
||||
{
|
||||
LoadingUI.SetActive(show);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region achievements
|
||||
|
||||
public void ShowAchievementsPanel()
|
||||
{
|
||||
Social.ShowAchievementsUI();
|
||||
}
|
||||
|
||||
public void UnlockAchievement(String achievement)
|
||||
{
|
||||
switch(achievement)
|
||||
{
|
||||
case "on_fire":
|
||||
Social.ReportProgress(PlaneRunGPGSIds.achievement_on_fire, 100f, null);
|
||||
break;
|
||||
case "warming_up":
|
||||
Social.ReportProgress(PlaneRunGPGSIds.achievement_warming_up, 100f, null);
|
||||
break;
|
||||
case "untouchable":
|
||||
Social.ReportProgress(PlaneRunGPGSIds.achievement_untouchable, 100f, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region leaderboard
|
||||
|
||||
public void ShowLeaderboard()
|
||||
{
|
||||
Social.ShowLeaderboardUI();
|
||||
}
|
||||
|
||||
public void UpdateLeaderboardScore(int score)
|
||||
{
|
||||
Social.ReportScore(score, PlaneRunGPGSIds.leaderboard_highscore, null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28eb0b24e6e6fbc4fb75ae8bf3029742
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,135 @@
|
||||
using UnityEngine;
|
||||
using GooglePlayGames;
|
||||
using GooglePlayGames.BasicApi;
|
||||
using GooglePlayGames.BasicApi.SavedGame;
|
||||
using System;
|
||||
using TMPro;
|
||||
|
||||
|
||||
public class PlayGamesManager_old : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
TMP_Text nicknameText;
|
||||
|
||||
private score score;
|
||||
|
||||
[SerializeField]
|
||||
private shopManager shopManager;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
this.score = GetComponent<score>();
|
||||
|
||||
SignIn();
|
||||
|
||||
}
|
||||
|
||||
public void SignIn()
|
||||
{
|
||||
PlayGamesPlatform.Activate();
|
||||
PlayGamesPlatform.Instance.Authenticate(ProcessAuthentication);
|
||||
|
||||
OpenSave(false);
|
||||
}
|
||||
|
||||
internal void ProcessAuthentication(SignInStatus status)
|
||||
{
|
||||
if (status == SignInStatus.Success)
|
||||
{
|
||||
// Continue with Play Games Services
|
||||
|
||||
string name = PlayGamesPlatform.Instance.GetUserDisplayName();
|
||||
|
||||
nicknameText.text = name;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Disable your integration with Play Games Services or show a login button
|
||||
// to ask users to sign-in. Clicking it should call
|
||||
// PlayGamesPlatform.Instance.ManuallyAuthenticate(ProcessAuthentication).
|
||||
}
|
||||
}
|
||||
|
||||
#region SavedGames
|
||||
|
||||
private bool isSaving;
|
||||
|
||||
public void OpenSave(bool saving)
|
||||
{
|
||||
if(Social.localUser.authenticated)
|
||||
{
|
||||
isSaving = saving;
|
||||
((PlayGamesPlatform)Social.Active).SavedGame.OpenWithAutomaticConflictResolution("Save", DataSource.ReadCacheOrNetwork, ConflictResolutionStrategy.UseLongestPlaytime, SavedGameOpen);
|
||||
}
|
||||
}
|
||||
|
||||
private void SavedGameOpen(SavedGameRequestStatus status, ISavedGameMetadata metadata)
|
||||
{
|
||||
if(status == SavedGameRequestStatus.Success)
|
||||
{
|
||||
if(isSaving) // Saving
|
||||
{
|
||||
byte[] myData = System.Text.ASCIIEncoding.ASCII.GetBytes(GetSaveString());
|
||||
|
||||
SavedGameMetadataUpdate updateForMetadata = new SavedGameMetadataUpdate.Builder().WithUpdatedDescription("I have played my game at: " + DateTime.Now.ToString()).Build();
|
||||
|
||||
((PlayGamesPlatform)Social.Active).SavedGame.CommitUpdate(metadata, updateForMetadata, myData, SaveCallback);
|
||||
}
|
||||
else // Loading
|
||||
{
|
||||
((PlayGamesPlatform)Social.Active).SavedGame.ReadBinaryData(metadata, LoadCallBack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadCallBack(SavedGameRequestStatus status, byte[] data)
|
||||
{
|
||||
if(status == SavedGameRequestStatus.Success)
|
||||
{
|
||||
string loadedData = System.Text.ASCIIEncoding.ASCII.GetString(data);
|
||||
|
||||
LoadSavedString(loadedData);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadSavedString(string loadedData)
|
||||
{
|
||||
string[] cloudStringArr = loadedData.Split('|');
|
||||
|
||||
int highscore = int.Parse(cloudStringArr[0]);
|
||||
|
||||
int coins = int.Parse(cloudStringArr[1]);
|
||||
|
||||
string ownedPlanes = cloudStringArr[2];
|
||||
|
||||
score.SetHighscore(highscore);
|
||||
|
||||
shopManager.coins = coins;
|
||||
|
||||
shopManager.ConvertOwnedPlanes(ownedPlanes);
|
||||
}
|
||||
|
||||
private string GetSaveString()
|
||||
{
|
||||
string dataToSave = "";
|
||||
|
||||
dataToSave += ((int)score.highscoreAmount).ToString() + "|" + shopManager.coins.ToString() + "|" + shopManager.GetOwnedPlanesString();
|
||||
|
||||
return dataToSave;
|
||||
}
|
||||
|
||||
private void SaveCallback(SavedGameRequestStatus status, ISavedGameMetadata metadata)
|
||||
{
|
||||
if(status == SavedGameRequestStatus.Success)
|
||||
{
|
||||
Debug.Log("Successfully saved to the cloud");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Failed to save to cloud");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dce2ad60d23539e44a8422890ae506cc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,119 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
public class PlayerMovement : MonoBehaviour
|
||||
{
|
||||
public float speed;
|
||||
public float rotSpeed;
|
||||
|
||||
public GameObject plane;
|
||||
|
||||
public float speedBoostTimer;
|
||||
public ParticleSystem speedEffect;
|
||||
|
||||
public Animator anim;
|
||||
|
||||
public bool moveLeft;
|
||||
public bool moveRight;
|
||||
public bool notMove;
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
anim = plane.GetComponent<Animator>();
|
||||
notMove = true;
|
||||
}
|
||||
|
||||
|
||||
void Update()
|
||||
{
|
||||
Move();
|
||||
|
||||
if (speedBoostTimer>0)
|
||||
speedBoostTimer-=Time.deltaTime;
|
||||
|
||||
if(speedBoostTimer > 0 && !speedEffect.isPlaying)
|
||||
{
|
||||
Debug.Log("Speed effect is playing!");
|
||||
speedEffect.Play();
|
||||
}
|
||||
else if(speedBoostTimer <= 0 && speedEffect.isPlaying)
|
||||
{
|
||||
speedEffect.Stop();
|
||||
}
|
||||
|
||||
transform.Translate(0, 0, speed * (speedBoostTimer >0? 2f:1f) * Time.deltaTime);
|
||||
|
||||
}
|
||||
|
||||
public void Move()
|
||||
{
|
||||
if(Input.GetKey("a"))
|
||||
{
|
||||
notMove = false;
|
||||
moveLeft = true;
|
||||
}
|
||||
else if (Input.GetKey("d"))
|
||||
{
|
||||
notMove = false;
|
||||
moveLeft = false;
|
||||
}
|
||||
|
||||
if(Input.GetKeyUp("a") || Input.GetKeyUp("d"))
|
||||
{
|
||||
notMove = true;
|
||||
}
|
||||
|
||||
if (notMove)
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (moveLeft)
|
||||
{
|
||||
left();
|
||||
}
|
||||
else if (!moveLeft)
|
||||
{
|
||||
right();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
anim.SetInteger("controll", 0);
|
||||
}
|
||||
|
||||
public void left()
|
||||
{
|
||||
anim.SetInteger("controll", 1);
|
||||
|
||||
transform.Rotate(0, -rotSpeed * Time.deltaTime, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void right()
|
||||
{
|
||||
anim.SetInteger("controll", 2);
|
||||
|
||||
transform.Rotate(0, rotSpeed * Time.deltaTime, 0);
|
||||
}
|
||||
|
||||
public void AllowMovement(bool movement)
|
||||
{
|
||||
notMove = false;
|
||||
moveLeft = movement;
|
||||
}
|
||||
|
||||
public void DontAllowMovement()
|
||||
{
|
||||
notMove = true;
|
||||
}
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ae4950f5ad02ce4880e1f3142d8a5ad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,164 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using GoogleMobileAds.Api;
|
||||
|
||||
namespace GoogleMobileAds.Sample
|
||||
{
|
||||
/// <summary>
|
||||
/// Demonstrates how to use Google Mobile Ads rewarded ads.
|
||||
/// </summary>
|
||||
public class RewardedAdController : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// UI element activated when an ad is ready to show.
|
||||
/// </summary>
|
||||
|
||||
// These ad units are configured to always serve test ads.
|
||||
#if UNITY_ANDROID
|
||||
private const string _adUnitId = "ca-app-pub-2626773788355001/2015295060";
|
||||
#elif UNITY_IPHONE
|
||||
private const string _adUnitId = "ca-app-pub-3940256099942544/1712485313";
|
||||
#else
|
||||
private const string _adUnitId = "unused";
|
||||
#endif
|
||||
|
||||
private RewardedAd _rewardedAd;
|
||||
|
||||
[SerializeField] private shopManager shopManager;
|
||||
|
||||
/// <summary>
|
||||
/// Loads the ad.
|
||||
/// </summary>
|
||||
public void LoadAd()
|
||||
{
|
||||
// Clean up the old ad before loading a new one.
|
||||
if (_rewardedAd != null)
|
||||
{
|
||||
DestroyAd();
|
||||
}
|
||||
|
||||
Debug.Log("Loading rewarded ad.");
|
||||
|
||||
// Create our request used to load the ad.
|
||||
var adRequest = new AdRequest();
|
||||
|
||||
// Send the request to load the ad.
|
||||
RewardedAd.Load(_adUnitId, adRequest, (RewardedAd ad, LoadAdError error) =>
|
||||
{
|
||||
// If the operation failed with a reason.
|
||||
if (error != null)
|
||||
{
|
||||
Debug.LogError("Rewarded ad failed to load an ad with error : " + error);
|
||||
|
||||
shopManager.EnableRewardedAdButton(false);
|
||||
return;
|
||||
}
|
||||
// If the operation failed for unknown reasons.
|
||||
// This is an unexpected error, please report this bug if it happens.
|
||||
if (ad == null)
|
||||
{
|
||||
Debug.LogError("Unexpected error: Rewarded load event fired with null ad and null error.");
|
||||
shopManager.EnableRewardedAdButton(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// The operation completed successfully.
|
||||
Debug.Log("Rewarded ad loaded with response : " + ad.GetResponseInfo());
|
||||
|
||||
shopManager.EnableRewardedAdButton(true);
|
||||
|
||||
_rewardedAd = ad;
|
||||
|
||||
// Register to ad events to extend functionality.
|
||||
RegisterEventHandlers(ad);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the ad.
|
||||
/// </summary>
|
||||
public void ShowAd()
|
||||
{
|
||||
if (_rewardedAd != null && _rewardedAd.CanShowAd())
|
||||
{
|
||||
Debug.Log("Showing rewarded ad.");
|
||||
_rewardedAd.Show((Reward reward) =>
|
||||
{
|
||||
Debug.Log(String.Format("Rewarded ad granted a reward: {0} {1}",
|
||||
reward.Amount,
|
||||
reward.Type));
|
||||
|
||||
shopManager.RewardUser();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
shopManager.EnableRewardedAdButton(false);
|
||||
Debug.LogError("Rewarded ad is not ready yet.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Destroys the ad.
|
||||
/// </summary>
|
||||
public void DestroyAd()
|
||||
{
|
||||
if (_rewardedAd != null)
|
||||
{
|
||||
Debug.Log("Destroying rewarded ad.");
|
||||
_rewardedAd.Destroy();
|
||||
_rewardedAd = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Logs the ResponseInfo.
|
||||
/// </summary>
|
||||
public void LogResponseInfo()
|
||||
{
|
||||
if (_rewardedAd != null)
|
||||
{
|
||||
var responseInfo = _rewardedAd.GetResponseInfo();
|
||||
UnityEngine.Debug.Log(responseInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private void RegisterEventHandlers(RewardedAd ad)
|
||||
{
|
||||
// Raised when the ad is estimated to have earned money.
|
||||
ad.OnAdPaid += (AdValue adValue) =>
|
||||
{
|
||||
Debug.Log(String.Format("Rewarded ad paid {0} {1}.",
|
||||
adValue.Value,
|
||||
adValue.CurrencyCode));
|
||||
};
|
||||
// Raised when an impression is recorded for an ad.
|
||||
ad.OnAdImpressionRecorded += () =>
|
||||
{
|
||||
Debug.Log("Rewarded ad recorded an impression.");
|
||||
};
|
||||
// Raised when a click is recorded for an ad.
|
||||
ad.OnAdClicked += () =>
|
||||
{
|
||||
Debug.Log("Rewarded ad was clicked.");
|
||||
};
|
||||
// Raised when the ad opened full screen content.
|
||||
ad.OnAdFullScreenContentOpened += () =>
|
||||
{
|
||||
Debug.Log("Rewarded ad full screen content opened.");
|
||||
};
|
||||
// Raised when the ad closed full screen content.
|
||||
ad.OnAdFullScreenContentClosed += () =>
|
||||
{
|
||||
Debug.Log("Rewarded ad full screen content closed.");
|
||||
LoadAd();
|
||||
};
|
||||
// Raised when the ad failed to open full screen content.
|
||||
ad.OnAdFullScreenContentFailed += (AdError error) =>
|
||||
{
|
||||
Debug.LogError("Rewarded ad failed to open full screen content with error : "
|
||||
+ error);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aded68394d5bf214d9945db7cb805ad7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class TargetingButton : MonoBehaviour
|
||||
{
|
||||
public Transform enemy;
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if(enemy == null)
|
||||
Destroy(gameObject);
|
||||
}
|
||||
public void TargetSelected()
|
||||
{
|
||||
GameObject.FindGameObjectWithTag("Player").GetComponent<PickupManager>().ShootMissle(enemy);
|
||||
}
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43b7e5124201a3f46b55be62695165ba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,87 @@
|
||||
using GoogleMobileAds.Sample;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
|
||||
public class UiManager : MonoBehaviour
|
||||
{
|
||||
public MenuControler menuControler;
|
||||
public PlayerMovement playerMovement;
|
||||
public PLayerLife playerLife;
|
||||
public soundManager soundmanager;
|
||||
public GameObject PauseMenu;
|
||||
public bool paused;
|
||||
public bool gameOver;
|
||||
public bool gameOverAnimPlayed;
|
||||
public score scr;
|
||||
public GameObject playerModels;
|
||||
public int adindex;
|
||||
public Animation gameOverAnim;
|
||||
|
||||
[SerializeField] InterstitialAdController interstitialAdController;
|
||||
|
||||
[SerializeField] private PlayGamesManager PGM;
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
adindex = PlayerPrefs.GetInt("adIndex");
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
PauseMenu.SetActive(menuControler.playing && paused);
|
||||
|
||||
if(paused) Time.timeScale = 0;
|
||||
else Time.timeScale = 1;
|
||||
|
||||
if (playerLife.Hp <= 0 )
|
||||
{
|
||||
paused = false;
|
||||
gameOver = true;
|
||||
}
|
||||
|
||||
if( gameOver && !gameOverAnimPlayed)
|
||||
{
|
||||
playerModels.SetActive(false);
|
||||
playerMovement.enabled = false;
|
||||
gameOverAnim.Play();
|
||||
|
||||
if (adindex >= 5)
|
||||
{
|
||||
// SHOW INTERSTITIAL AD
|
||||
interstitialAdController.ShowAd();
|
||||
|
||||
PlayerPrefs.SetInt("adIndex", 0);
|
||||
adindex = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerPrefs.SetInt("adIndex", adindex + 1);
|
||||
adindex++;
|
||||
}
|
||||
|
||||
// Do stuff when player dies;
|
||||
|
||||
// Save data
|
||||
PGM.OpenSave(true);
|
||||
|
||||
gameOverAnimPlayed = true;
|
||||
}
|
||||
|
||||
scr.enabled = !gameOver;
|
||||
|
||||
if (!gameOver)
|
||||
gameOverAnim.gameObject.transform.localScale = Vector3.zero;
|
||||
|
||||
}
|
||||
|
||||
public void Pause(bool state)
|
||||
{
|
||||
paused = state;
|
||||
soundmanager.PlayClick1();
|
||||
}
|
||||
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55cf456191a5a0648bfb2997c82c7450
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,17 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
public class adsLeftText : MonoBehaviour
|
||||
{
|
||||
public string txt;
|
||||
public TMP_Text text;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Update()
|
||||
{
|
||||
text.text = txt;
|
||||
Destroy(gameObject, 2f);
|
||||
}
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6267e79921f1c1e46b37423eb85e8ef6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
using System.Security.Cryptography;
|
||||
using UnityEngine;
|
||||
|
||||
public class cameraFollow : MonoBehaviour
|
||||
{
|
||||
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void FixedUpdate()
|
||||
{
|
||||
transform.rotation = Quaternion.Euler(90, 0, 0);
|
||||
|
||||
}
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 230072d298b7f6c49951d8344c111072
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class destroy : MonoBehaviour
|
||||
{
|
||||
public float time;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
Destroy(gameObject, time);
|
||||
}
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25298b62175143943a3b429fc9318ce9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,42 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class flareParticle : MonoBehaviour
|
||||
{
|
||||
public AnimationCurve speedCurve;
|
||||
public AnimationCurve heightCurve;
|
||||
public float distance,speedModifier, heightModifier;
|
||||
private float t_speed, t_height;
|
||||
public float flareTime;
|
||||
private float t_scale = 2f;
|
||||
|
||||
public bool taken;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
flareTime -= Time.deltaTime;
|
||||
if( flareTime <= 0)
|
||||
{
|
||||
t_scale-=Time.deltaTime;
|
||||
transform.localScale = new Vector3(t_scale, t_scale, t_scale);
|
||||
if (t_scale <= 0)
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
if (t_speed < 1f)
|
||||
t_speed += speedModifier * Time.deltaTime;
|
||||
|
||||
if (t_height < 1f)
|
||||
t_height += heightModifier * Time.deltaTime;
|
||||
|
||||
transform.localPosition = new Vector3(0, heightCurve.Evaluate(t_height), speedCurve.Evaluate(t_speed) * distance);
|
||||
}
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48e8b6dbd26c3e2429c87ba646c5dcd7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class healing : MonoBehaviour
|
||||
{
|
||||
public GameObject effect;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
|
||||
if (other.CompareTag("Player"))
|
||||
{
|
||||
Instantiate(effect, transform.position, transform.rotation);
|
||||
Destroy(gameObject, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 040e0ea6e273acb469c1c6650f4ef2d7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,133 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class helicopterEnemy : MonoBehaviour
|
||||
{
|
||||
public float speed = 60;
|
||||
public float rotSpeed = 100;
|
||||
public Transform playerTransform;
|
||||
public GameObject explosion;
|
||||
private float TimeBtwSpawn;
|
||||
public float StartTimeSpawn;
|
||||
public GameObject missleLauncher;
|
||||
public GameObject missle;
|
||||
public float retreatDis;
|
||||
public float shootDist;
|
||||
private Camera cam;
|
||||
public GameObject missleDrop;
|
||||
public float targetUItimer;
|
||||
public GameObject playerMissle;
|
||||
public bool chased;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
targetUI = Instantiate(targetUI);
|
||||
targetUI.transform.SetParent(GameObject.FindGameObjectWithTag("Canvas").transform);
|
||||
targetUI.GetComponent<TargetingButton>().enemy = transform;
|
||||
playerTransform = GameObject.FindWithTag("Player").transform;
|
||||
if(playerTransform.gameObject.GetComponent<PickupManager>().missleEnabled)
|
||||
ShowTargeting();
|
||||
cam = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();
|
||||
targetUI.SetActive(false);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
Vector3 direction = playerTransform.position - transform.position;
|
||||
Quaternion rotation = Quaternion.LookRotation(direction);
|
||||
transform.rotation = Quaternion.Lerp(transform.rotation, rotation, rotSpeed * Time.deltaTime);
|
||||
|
||||
float dist = Vector3.Distance(playerTransform.position, transform.position);
|
||||
|
||||
if (dist <= retreatDis)
|
||||
{
|
||||
transform.Translate(0, 0, -speed * Time.deltaTime);
|
||||
}
|
||||
|
||||
if (dist >= retreatDis)
|
||||
{
|
||||
|
||||
|
||||
transform.Translate(0, 0, speed * Time.deltaTime);
|
||||
}
|
||||
|
||||
if(dist <= shootDist)
|
||||
{
|
||||
if (TimeBtwSpawn <= 0)
|
||||
{
|
||||
Instantiate(missle, missleLauncher.transform.position, missleLauncher.transform.rotation);
|
||||
TimeBtwSpawn = StartTimeSpawn;
|
||||
}
|
||||
else
|
||||
{
|
||||
TimeBtwSpawn -= Time.deltaTime;
|
||||
}
|
||||
}
|
||||
if(targetUI!=null)
|
||||
targetUI.transform.position = cam.WorldToScreenPoint(transform.position);
|
||||
|
||||
if (targetUI.activeSelf)
|
||||
{
|
||||
if (targetUItimer > 0)
|
||||
targetUItimer -= Time.deltaTime;
|
||||
else
|
||||
targetUI.SetActive(false);
|
||||
}
|
||||
|
||||
if (chased && playerMissle == null)
|
||||
{
|
||||
targetUI.GetComponent<RectTransform>().localScale = new Vector3(2f, 2f, 2f);
|
||||
HideTargeting();
|
||||
chased = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
|
||||
if (other.CompareTag("missle"))
|
||||
{
|
||||
Instantiate(explosion, transform.position, transform.rotation);
|
||||
int i = Random.Range(0, 3);
|
||||
if (i == 0)
|
||||
Instantiate(missleDrop, transform.position, transform.rotation);
|
||||
Destroy(targetUI);
|
||||
Destroy(gameObject, 0);
|
||||
|
||||
}
|
||||
|
||||
if (other.CompareTag("Player"))
|
||||
{
|
||||
Instantiate(explosion, transform.position, transform.rotation);
|
||||
int i = Random.Range(0, 3);
|
||||
if (i == 0)
|
||||
Instantiate(missleDrop, transform.position, transform.rotation);
|
||||
Destroy(targetUI);
|
||||
Destroy(gameObject, 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject targetUI;
|
||||
|
||||
public void ShowTargeting()
|
||||
{
|
||||
targetUI.SetActive(true);
|
||||
}
|
||||
|
||||
public void HideTargeting()
|
||||
{
|
||||
targetUI.SetActive(false);
|
||||
}
|
||||
|
||||
public void ChasedByPlayerMissle(GameObject playerMissle)
|
||||
{
|
||||
this.playerMissle = playerMissle;
|
||||
chased = true;
|
||||
}
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 019db9327e556fc46a06ff554d4b7bfa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,142 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class jetEnemy : MonoBehaviour
|
||||
{
|
||||
public float speed = 60;
|
||||
public float rotSpeed = 100;
|
||||
public Transform playerTransform;
|
||||
public GameObject explosion;
|
||||
public float retreatDis;
|
||||
public float attackDis;
|
||||
public int state; // 0 - attack | 1 - go away
|
||||
private bool shotMissle;
|
||||
public float attackDistance;
|
||||
|
||||
private float TimeBtwSpawn;
|
||||
public float StartTimeSpawn;
|
||||
public GameObject missleLauncher;
|
||||
public GameObject missle;
|
||||
private Camera cam;
|
||||
public GameObject missleDrop;
|
||||
public float targetUItimer;
|
||||
public GameObject playerMissle;
|
||||
public bool chased;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
playerTransform = GameObject.FindWithTag("Player").transform;
|
||||
TimeBtwSpawn = StartTimeSpawn;
|
||||
|
||||
targetUI = Instantiate(targetUI);
|
||||
targetUI.transform.SetParent(GameObject.FindGameObjectWithTag("Canvas").transform);
|
||||
if (playerTransform.gameObject.GetComponent<PickupManager>().missleEnabled)
|
||||
ShowTargeting();
|
||||
targetUI.GetComponent<TargetingButton>().enemy = transform;
|
||||
cam = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();
|
||||
targetUI.SetActive(false);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
float dist = Vector3.Distance(playerTransform.position, transform.position);
|
||||
|
||||
if(state == 0)
|
||||
{
|
||||
Vector3 direction = playerTransform.position - transform.position;
|
||||
Quaternion rotation = Quaternion.LookRotation(direction);
|
||||
transform.rotation = Quaternion.Lerp(transform.rotation, rotation, rotSpeed * Time.deltaTime);
|
||||
|
||||
if(dist <= attackDistance && !shotMissle)
|
||||
{
|
||||
ShootMissle();
|
||||
shotMissle=true;
|
||||
}
|
||||
|
||||
}else if(state == 1)
|
||||
{
|
||||
Vector3 direction = transform.position - playerTransform.position;
|
||||
Quaternion rotation = Quaternion.LookRotation(direction);
|
||||
transform.rotation = Quaternion.Lerp(transform.rotation, rotation, rotSpeed * Time.deltaTime * 0.5f);
|
||||
if (dist >= attackDis)
|
||||
{
|
||||
shotMissle = false;
|
||||
state = 0;
|
||||
}
|
||||
}
|
||||
|
||||
transform.Translate(0, 0, speed * Time.deltaTime);
|
||||
|
||||
if (targetUI != null)
|
||||
targetUI.transform.position = cam.WorldToScreenPoint(transform.position);
|
||||
|
||||
if (targetUI.activeSelf)
|
||||
{
|
||||
if (targetUItimer > 0)
|
||||
targetUItimer -= Time.deltaTime;
|
||||
else
|
||||
targetUI.SetActive(false);
|
||||
}
|
||||
|
||||
if (chased && playerMissle == null)
|
||||
{
|
||||
targetUI.GetComponent<RectTransform>().localScale = new Vector3(2f, 2f, 2f);
|
||||
HideTargeting();
|
||||
chased = false;
|
||||
}
|
||||
}
|
||||
|
||||
void ShootMissle()
|
||||
{
|
||||
Instantiate(missle, missleLauncher.transform.position, missleLauncher.transform.rotation);
|
||||
state = 1;
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
|
||||
if (other.CompareTag("missle"))
|
||||
{
|
||||
|
||||
Instantiate(explosion, transform.position, transform.rotation);
|
||||
int i = Random.Range(0,3);
|
||||
if(i ==0)
|
||||
Instantiate(missleDrop, transform.position, transform.rotation);
|
||||
Destroy(gameObject, 0);
|
||||
Destroy(targetUI);
|
||||
}
|
||||
|
||||
if (other.CompareTag("Player"))
|
||||
{
|
||||
Instantiate(explosion, transform.position, transform.rotation);
|
||||
int i = Random.Range(0, 3);
|
||||
if (i == 0)
|
||||
Instantiate(missleDrop, transform.position, transform.rotation);
|
||||
Destroy(gameObject, 0);
|
||||
Destroy(targetUI);
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject targetUI;
|
||||
|
||||
public void ShowTargeting()
|
||||
{
|
||||
Debug.Log("Targeting showed");
|
||||
targetUI.SetActive(true);
|
||||
}
|
||||
|
||||
public void HideTargeting()
|
||||
{
|
||||
Debug.Log("Targeting hiden");
|
||||
targetUI.SetActive(false);
|
||||
}
|
||||
|
||||
public void ChasedByPlayerMissle(GameObject playerMissle)
|
||||
{
|
||||
this.playerMissle = playerMissle;
|
||||
chased = true;
|
||||
}
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0873d02480de394d95a0a860a14f76c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,179 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using static UnityEngine.GraphicsBuffer;
|
||||
|
||||
public class missle : MonoBehaviour
|
||||
{
|
||||
public bool kamikaze;
|
||||
public float speed = 60;
|
||||
public float rotSpeed = 100;
|
||||
public Transform playerTransform;
|
||||
public GameObject explosion;
|
||||
public Transform targetFlare;
|
||||
private Camera cam;
|
||||
public float targetUItimer;
|
||||
public GameObject trail;
|
||||
public GameObject playerMissle;
|
||||
public bool chased;
|
||||
|
||||
PickupManager pm;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
pm = GameObject.FindObjectOfType<PickupManager>();
|
||||
|
||||
targetUItimer = 10;
|
||||
|
||||
playerTransform = GameObject.FindWithTag("Player").transform;
|
||||
|
||||
if(!kamikaze)
|
||||
{
|
||||
SearchForFlares();
|
||||
}
|
||||
else
|
||||
{
|
||||
targetUI = Instantiate(targetUI);
|
||||
targetUI.transform.SetParent(GameObject.FindGameObjectWithTag("Canvas").transform);
|
||||
if (playerTransform.gameObject.GetComponent<PickupManager>().missleEnabled)
|
||||
ShowTargeting();
|
||||
targetUI.GetComponent<TargetingButton>().enemy = transform;
|
||||
cam = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();
|
||||
targetUI.SetActive(false);
|
||||
}
|
||||
|
||||
if(chased && playerMissle == null)
|
||||
{
|
||||
targetUI.GetComponent<RectTransform>().localScale = new Vector3(2f, 2f, 2f);
|
||||
HideTargeting();
|
||||
chased = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
if (targetFlare == null)
|
||||
{
|
||||
SearchForFlares();
|
||||
|
||||
transform.Translate(0, 0, speed * Time.deltaTime);
|
||||
|
||||
Vector3 direction = playerTransform.position - transform.position;
|
||||
Quaternion rotation = Quaternion.LookRotation(direction);
|
||||
transform.rotation = Quaternion.Lerp(transform.rotation, rotation, rotSpeed * Time.deltaTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.Translate(0, 0, speed * Time.deltaTime);
|
||||
|
||||
Vector3 direction = targetFlare.position - transform.position;
|
||||
Quaternion rotation = Quaternion.LookRotation(direction);
|
||||
transform.rotation = Quaternion.Lerp(transform.rotation, rotation, rotSpeed * 2 * Time.deltaTime);
|
||||
}
|
||||
|
||||
if (targetUI != null)
|
||||
targetUI.transform.position = cam.WorldToScreenPoint(transform.position);
|
||||
|
||||
if (kamikaze && targetUI.activeSelf)
|
||||
{
|
||||
if (targetUItimer > 0)
|
||||
targetUItimer -= Time.deltaTime;
|
||||
else
|
||||
targetUI.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
|
||||
if (other.CompareTag("missle"))
|
||||
{
|
||||
if (trail != null) {
|
||||
trail.transform.SetParent(null);
|
||||
trail.GetComponent<missleTrail>().StartTimer();
|
||||
}
|
||||
|
||||
Instantiate(explosion, transform.position, transform.rotation);
|
||||
Destroy(targetUI);
|
||||
Destroy(gameObject, 0);
|
||||
}
|
||||
|
||||
if (other.CompareTag("Player"))
|
||||
{
|
||||
if (trail != null)
|
||||
{
|
||||
trail.transform.SetParent(null);
|
||||
trail.GetComponent<missleTrail>().StartTimer();
|
||||
}
|
||||
Instantiate(explosion, transform.position, transform.rotation);
|
||||
Destroy(targetUI);
|
||||
Destroy(gameObject, 0);
|
||||
|
||||
}
|
||||
|
||||
if (other.CompareTag("flareProjectile")&&!kamikaze)
|
||||
{
|
||||
pm.flarePickup.RemoveFlareCount(1);
|
||||
|
||||
if (trail != null)
|
||||
{
|
||||
trail.transform.SetParent(null);
|
||||
trail.GetComponent<missleTrail>().StartTimer();
|
||||
}
|
||||
Instantiate(explosion, transform.position, transform.rotation);
|
||||
Destroy(targetUI);
|
||||
Destroy(other.gameObject, 0);
|
||||
Destroy(gameObject, 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void SearchForFlares()
|
||||
{
|
||||
if (targetFlare == null && pm.flarePickup.numOfFlares > 0)
|
||||
{
|
||||
GameObject[] flaresArr = GameObject.FindGameObjectsWithTag("flareProjectile");
|
||||
int closestIndex = 0;
|
||||
if (flaresArr.Length > 0)
|
||||
{
|
||||
for (int i = 0; i < flaresArr.Length; i++)
|
||||
{
|
||||
if (flaresArr[i] != null)
|
||||
{
|
||||
float dist1 = Vector3.Distance(transform.position, flaresArr[i].transform.position);
|
||||
float dist2 = Vector3.Distance(transform.position, flaresArr[closestIndex].transform.position);
|
||||
|
||||
if (dist1 < dist2)
|
||||
{
|
||||
closestIndex = i;
|
||||
}
|
||||
}
|
||||
targetFlare = flaresArr[closestIndex].transform;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject targetUI;
|
||||
|
||||
public void ShowTargeting()
|
||||
{
|
||||
if(kamikaze)
|
||||
targetUI.SetActive(true);
|
||||
}
|
||||
|
||||
public void HideTargeting()
|
||||
{
|
||||
if (kamikaze)
|
||||
targetUI.SetActive(false);
|
||||
}
|
||||
|
||||
public void ChasedByPlayerMissle(GameObject playerMissle)
|
||||
{
|
||||
this.playerMissle = playerMissle;
|
||||
chased = true;
|
||||
}
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 169447b0a2e6e2f4188231ad16cea547
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class misslePickup : MonoBehaviour
|
||||
{
|
||||
public Image timeLeftImg;
|
||||
public float time;
|
||||
private float t;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
t = time;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
t -= Time.deltaTime;
|
||||
|
||||
timeLeftImg.fillAmount = t / time;
|
||||
|
||||
if (t <= 0)
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c0b9cf729c515549895ba0d2435b44c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class missleRotation : MonoBehaviour
|
||||
{
|
||||
public float speed;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
transform.Rotate(0, 0, speed * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0467967dbf66f34892d2a0a866bf75a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class missleTrail : MonoBehaviour
|
||||
{
|
||||
public float time;
|
||||
private bool timer;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if(timer)
|
||||
time-=Time.deltaTime;
|
||||
|
||||
if (time < 0)
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
public void StartTimer()
|
||||
{
|
||||
GetComponent<ParticleSystem>().Stop();
|
||||
timer = true;
|
||||
}
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 872bf4e948f90834a93df9a4c097d154
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class playerPos : MonoBehaviour
|
||||
{
|
||||
public Transform Player;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
transform.position = new Vector3(Player.position.x, transform.position.y, Player.position.z);
|
||||
}
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 88976559a7de8d84f83a3e820f081fd9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
public class randomText : MonoBehaviour
|
||||
{
|
||||
public TMP_Text txt;
|
||||
|
||||
public string[] randomTexts;
|
||||
|
||||
void Start()
|
||||
{
|
||||
txt.text = randomTexts[Random.Range(0, randomTexts.Length)];
|
||||
}
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8285ae4f849d4b049973b921a6dfc43a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
|
||||
public class rotorRotation : MonoBehaviour
|
||||
{
|
||||
public float speed;
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Update()
|
||||
{
|
||||
transform.Rotate(0, speed * Time.deltaTime, 0);
|
||||
}
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c1109d12300e57949bfbd325faaea822
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,50 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
using UnityEngine.SocialPlatforms.Impl;
|
||||
|
||||
public class score : MonoBehaviour
|
||||
{
|
||||
public MenuControler menuControler;
|
||||
public PLayerLife playerLife;
|
||||
public TMP_Text scoretext;
|
||||
public TMP_Text finalScoreText;
|
||||
public float scoreAmount;
|
||||
public float pointIncreasedPerSecond;
|
||||
|
||||
public float highscoreAmount;
|
||||
public GameObject highscore;
|
||||
public TMP_Text HighScoreText;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
//highscoreAmount = PlayerPrefs.GetFloat("HighScore");
|
||||
scoreAmount = 0f;
|
||||
pointIncreasedPerSecond = 1f;
|
||||
highscore.SetActive(false);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
HighScoreText.text = "HIGHSCORE: " + (int)highscoreAmount;
|
||||
finalScoreText.text = "SCORE: " + (int)scoreAmount;
|
||||
|
||||
if (menuControler.playing && playerLife.Hp>0)
|
||||
{
|
||||
scoretext.text = (int)scoreAmount + "";
|
||||
scoreAmount += pointIncreasedPerSecond * Time.deltaTime;
|
||||
}
|
||||
|
||||
highscore.SetActive(scoreAmount > highscoreAmount);
|
||||
|
||||
}
|
||||
|
||||
public void SetHighscore(int highscore)
|
||||
{
|
||||
highscoreAmount += (float)highscore;
|
||||
}
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 12d360ba31659db4aa82464472478b4c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,281 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
using System;
|
||||
using GoogleMobileAds.Sample;
|
||||
|
||||
public class shopManager : MonoBehaviour
|
||||
{
|
||||
public score scoreScript;
|
||||
public soundManager soundmanager;
|
||||
|
||||
public bool[] owned;
|
||||
public bool[] show;
|
||||
public GameObject[] skins;
|
||||
public int[] cost;
|
||||
public Color[] buttonTextColor;
|
||||
|
||||
public int selectedSkin;
|
||||
public int equippedSkin;
|
||||
|
||||
public TMP_Text buttontext;
|
||||
public TMP_Text coinsText;
|
||||
public TMP_Text costText;
|
||||
public TMP_Text CoinText;
|
||||
|
||||
public int coins;
|
||||
public bool coinsGiven;
|
||||
public int gamecoins;
|
||||
|
||||
public Transform buyButton;
|
||||
public GameObject noBuyText;
|
||||
|
||||
public string dateNow;
|
||||
|
||||
public GameObject nextButton, prevButton;
|
||||
|
||||
public Transform Canvas;
|
||||
public GameObject adsLeft;
|
||||
|
||||
public GameObject RewardedAdButton;
|
||||
|
||||
public int rewardedAdsLeft;
|
||||
|
||||
[SerializeField] private RewardedAdController rewardedAdController;
|
||||
|
||||
[SerializeField] private PlayGamesManager PGM;
|
||||
|
||||
void Start()
|
||||
{
|
||||
dateNow = DateTime.Now.ToString("yyyyMMdd");
|
||||
//PlayerPrefs.DeleteAll();
|
||||
|
||||
if (PlayerPrefs.GetString("lastDate") == "" || PlayerPrefs.GetString("lastDate") != DateTime.Now.ToString("yyyyMMdd"))
|
||||
{
|
||||
PlayerPrefs.SetInt("rewardedAdsLeft", 3);
|
||||
PlayerPrefs.SetString("lastDate", DateTime.Now.ToString("yyyyMMdd"));
|
||||
}
|
||||
|
||||
PlayerPrefs.SetInt("skin1owned", 1);
|
||||
|
||||
selectedSkin = PlayerPrefs.GetInt("equippedSkin");
|
||||
EquipSkin(PlayerPrefs.GetInt("equippedSkin"));
|
||||
ShowSkin(PlayerPrefs.GetInt("equippedSkin"));
|
||||
|
||||
coinsText.text = coins.ToString();
|
||||
|
||||
rewardedAdsLeft = PlayerPrefs.GetInt("rewardedAdsLeft");
|
||||
|
||||
UpdateButton();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (GameObject.Find("player").GetComponent<PLayerLife>().life == false)
|
||||
{
|
||||
gamecoins = (int)scoreScript.scoreAmount;
|
||||
|
||||
if (!coinsGiven)
|
||||
{
|
||||
coins += gamecoins;
|
||||
|
||||
// Save data
|
||||
PGM.OpenSave(true);
|
||||
|
||||
coinsGiven = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CoinText.text = gamecoins.ToString();
|
||||
}
|
||||
|
||||
public void ShowSkin(int index)
|
||||
{
|
||||
for (int i = 0; i < skins.Length; i++)
|
||||
{
|
||||
if (i == index)
|
||||
skins[i].SetActive(true);
|
||||
else
|
||||
skins[i].SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void EquipSkin(int index)
|
||||
{
|
||||
if (owned[selectedSkin])
|
||||
{
|
||||
equippedSkin = selectedSkin;
|
||||
PlayerPrefs.SetInt("equippedSkin", equippedSkin);
|
||||
ShowSkin(selectedSkin);
|
||||
|
||||
soundmanager.PlayClick1();
|
||||
}
|
||||
}
|
||||
|
||||
public void NextSkin()
|
||||
{
|
||||
if (selectedSkin < owned.Length - 1)
|
||||
{
|
||||
soundmanager.PlayClick1();
|
||||
selectedSkin++;
|
||||
}
|
||||
ShowSkin(selectedSkin);
|
||||
UpdateButton();
|
||||
|
||||
}
|
||||
|
||||
public void PrevSkin()
|
||||
{
|
||||
if (selectedSkin >0)
|
||||
{
|
||||
selectedSkin--;
|
||||
soundmanager.PlayClick1();
|
||||
}
|
||||
ShowSkin(selectedSkin);
|
||||
UpdateButton();
|
||||
|
||||
}
|
||||
|
||||
public void UpdateButton()
|
||||
{
|
||||
if (equippedSkin == selectedSkin)
|
||||
{
|
||||
costText.text = null;
|
||||
buttontext.color = buttonTextColor[0];
|
||||
buttontext.text = "equipped";
|
||||
}
|
||||
else if (owned[selectedSkin])
|
||||
{
|
||||
costText.text = null;
|
||||
buttontext.color = buttonTextColor[0];
|
||||
buttontext.text = "equip";
|
||||
}
|
||||
else if (!owned[selectedSkin] && coins >= cost[selectedSkin])
|
||||
{
|
||||
costText.text = cost[selectedSkin].ToString();
|
||||
buttontext.color = buttonTextColor[0];
|
||||
buttontext.text = "buy";
|
||||
}
|
||||
else if (!owned[selectedSkin] && coins < cost[selectedSkin])
|
||||
{
|
||||
costText.text = cost[selectedSkin].ToString();
|
||||
buttontext.color = buttonTextColor[1];
|
||||
buttontext.text = "buy";
|
||||
}
|
||||
|
||||
if (selectedSkin == owned.Length - 1)
|
||||
nextButton.SetActive(false);
|
||||
else
|
||||
nextButton.SetActive(true);
|
||||
|
||||
if(selectedSkin == 0)
|
||||
prevButton.SetActive(false);
|
||||
else
|
||||
prevButton.SetActive(true);
|
||||
}
|
||||
|
||||
public void UpdateUI()
|
||||
{
|
||||
UpdateButton();
|
||||
coinsText.text = coins.ToString();
|
||||
|
||||
}
|
||||
|
||||
public void Buy()
|
||||
{
|
||||
if (!owned[selectedSkin] && coins > cost[selectedSkin] )
|
||||
{
|
||||
owned[selectedSkin] = true;
|
||||
|
||||
coins -= cost[selectedSkin];
|
||||
coinsText.text = coins.ToString();
|
||||
owned[selectedSkin+1] = true;
|
||||
soundmanager.PlayBuy();
|
||||
|
||||
// Save data
|
||||
PGM.OpenSave(true);
|
||||
}
|
||||
else if (owned[selectedSkin])
|
||||
{
|
||||
equippedSkin = selectedSkin;
|
||||
EquipSkin( equippedSkin );
|
||||
}
|
||||
else if( coins < cost[selectedSkin])
|
||||
{
|
||||
Transform noMonneyText = Instantiate(noBuyText, buyButton.position, buyButton.rotation).transform;
|
||||
noMonneyText.SetParent(buyButton);
|
||||
noMonneyText.transform.localPosition = Vector3.zero;
|
||||
soundmanager.PlayError();
|
||||
}
|
||||
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
public void ShowRewardedAd()
|
||||
{
|
||||
if (PlayerPrefs.GetInt("rewardedAdsLeft") > 0)
|
||||
{
|
||||
// SHOW REWARDED AD
|
||||
rewardedAdController.ShowAd();
|
||||
}
|
||||
else
|
||||
{
|
||||
adsLeftText adsleft = Instantiate(adsLeft, Canvas.position, Canvas.rotation).GetComponent<adsLeftText>();
|
||||
adsleft.transform.SetParent(Canvas);
|
||||
soundmanager.PlayError();
|
||||
adsleft.txt = "COME BACK TOMORROW";
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowRewardedAdsLeft()
|
||||
{
|
||||
PlayerPrefs.SetInt("rewardedAdsLeft", PlayerPrefs.GetInt("rewardedAdsLeft") - 1);
|
||||
rewardedAdsLeft = PlayerPrefs.GetInt("rewardedAdsLeft");
|
||||
adsLeftText adsleft = Instantiate(adsLeft, Canvas.position, Canvas.rotation).GetComponent<adsLeftText>();
|
||||
adsleft.transform.SetParent(Canvas);
|
||||
|
||||
adsleft.txt = (rewardedAdsLeft.ToString() + (rewardedAdsLeft == 1 ? " AD " : " ADs ") + "LEFT");
|
||||
}
|
||||
|
||||
public void RewardUser()
|
||||
{
|
||||
coins += 100;
|
||||
coinsText.text = coins.ToString();
|
||||
ShowRewardedAdsLeft();
|
||||
|
||||
// Save data
|
||||
PGM.OpenSave(true);
|
||||
}
|
||||
|
||||
public void EnableRewardedAdButton(bool enable)
|
||||
{
|
||||
RewardedAdButton.SetActive(enable);
|
||||
}
|
||||
|
||||
public String GetOwnedPlanesString()
|
||||
{
|
||||
String ownedPlanes = owned[0]?"1":"0";
|
||||
|
||||
for (int i = 1; i < owned.Length; i++)
|
||||
{
|
||||
ownedPlanes += ";" + (owned[i] ? "1" : "0");
|
||||
}
|
||||
|
||||
return ownedPlanes;
|
||||
}
|
||||
|
||||
public void ConvertOwnedPlanes(String ownedPlanesString)
|
||||
{
|
||||
String[] ownedPlanes = ownedPlanesString.Split(';');
|
||||
|
||||
|
||||
|
||||
for (int i = 0;i < ownedPlanes.Length; i++)
|
||||
{
|
||||
int planeOwned = int.Parse(ownedPlanes[i]);
|
||||
|
||||
owned[i] = (planeOwned == 1 ? true:false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf4f83412b3efc342bcfc7a55523efe5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class soundManager : MonoBehaviour
|
||||
{
|
||||
public AudioSource error;
|
||||
public AudioSource buy;
|
||||
public AudioSource click1;
|
||||
|
||||
public void PlayBuy()
|
||||
{
|
||||
buy.Play();
|
||||
}
|
||||
|
||||
public void PlayError()
|
||||
{
|
||||
error.Play();
|
||||
}
|
||||
|
||||
public void PlayClick1()
|
||||
{
|
||||
click1.Play();
|
||||
}
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6fe42cc955d94244b8b8b16d0a89de5b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,54 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class spawner : MonoBehaviour
|
||||
{
|
||||
private float timeBtwEnemySpawn;
|
||||
public float startTimeEnemySpawn;
|
||||
|
||||
private Vector3[] spawnOffset = {new Vector3(255f,0f,0f), new Vector3(-255f,0f,0f), new Vector3(0f,0f,255f), new Vector3(0f,0f,-255f)};
|
||||
|
||||
private float timeBtwPickupSpawn;
|
||||
public float startTimePickupSpawn;
|
||||
|
||||
public GameObject[] enemies;
|
||||
public GameObject[] pickups;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
timeBtwEnemySpawn = startTimeEnemySpawn;
|
||||
timeBtwPickupSpawn = startTimePickupSpawn;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if(timeBtwEnemySpawn <= 0)
|
||||
{
|
||||
|
||||
int rand = Random.Range(0, enemies.Length);
|
||||
Instantiate(enemies[rand], transform.position+ spawnOffset[Random.Range(0, spawnOffset.Length)], Quaternion.identity);
|
||||
timeBtwEnemySpawn = startTimeEnemySpawn;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
timeBtwEnemySpawn -= Time.deltaTime;
|
||||
}
|
||||
|
||||
if (timeBtwPickupSpawn <= 0)
|
||||
{
|
||||
|
||||
int rand = Random.Range(0, pickups.Length);
|
||||
Instantiate(pickups[rand], transform.position + spawnOffset[Random.Range(0, spawnOffset.Length)], Quaternion.identity);
|
||||
timeBtwPickupSpawn = startTimePickupSpawn;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
timeBtwPickupSpawn -= Time.deltaTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 241716245a1a5084c81b6ea5fbb24e9b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user