private void Start() { if (!tutorial) { Time.timeScale = 1; } upgrades = UpgradeSystem.Get(); increaseScoreMilestone = initialMilestone; WaveSystem.OnStartWaveFirstTime += StartGivingPoints; Fairy.OnFairyDeath += CheckFairies; Fairy.OnFairyEscaped += AddTimesEscaped; Enemy.OnDeath += AddPoints; upgrades.AssignUpgrades(); maxFairies = (int)upgrades.GetUpgrade(0).GetCurrentAmount(); shoot.rechargeTime = upgrades.GetUpgrade(1).GetCurrentAmount(); towerFireRate = upgrades.GetUpgrade(2).GetCurrentAmount(); fairySpeed = (int)upgrades.GetUpgrade(3).GetCurrentAmount(); turretSpawner.fireRate = towerFireRate; upgradePointsGiveMilestone = upgradePointsGiveMilestonesOriginal; for (int i = 0; i < confetti.Length; i++) { confetti[i].Stop(); } }
public void AssignData() { id = data.id; animation = GetComponent <UIAnimation>(); button = GetComponentInChildren <Button>(); nameText = transform.GetChild(1).GetChild(0).GetComponent <Text>(); levelText = transform.GetChild(1).GetChild(1).GetComponent <Text>(); differenceText = transform.GetChild(1).GetChild(2).GetComponent <Text>(); costText = transform.GetChild(1).GetChild(3).GetComponent <Text>(); currentColor = Color.white; SpriteState state; button.image.sprite = data.buttonIdle; state.disabledSprite = data.buttonDisabled; state.pressedSprite = data.buttonPressed; button.spriteState = state; isUnlocked = data.isUnlocked; currentLevel = data.currentLevel; maxLevel = data.amountPerLevel.Length; UpgradeSystem.Get().AddUpgrade(this); button.onClick.AddListener(BuyUpgrade); if (OnUpgradePurcharsed != null) { OnUpgradePurcharsed(id); } }
public void ForcedChangeScene() { if (SceneManager.GetActiveScene().name == "Gameplay") { Destroy(GameManager.Get().gameObject); Destroy(WaveSystem.Get().gameObject); Destroy(TurretSpawner.Get().gameObject); Destroy(Highscore.Get().gameObject); Destroy(MilestoneManager.Get().gameObject); UpgradeSystem upgrades = UpgradeSystem.Get(); if (upgrades) { upgrades.CleanList(); } } else if (SceneManager.GetActiveScene().name == "Upgrade Screen") { AkSoundEngine.StopAll(); } if (sceneName == "Gameplay") { AkSoundEngine.StopAll(); UpgradeSystem upgrades = UpgradeSystem.Get(); if (upgrades) { upgrades.CleanList(); } LoaderManager.Get().LoadScene(sceneName); UILoadingScreen.Get().SetVisible(true); } else if (sceneName == "Upgrade Screen") { AkSoundEngine.StopAll(); UpgradeSystem upgrades = UpgradeSystem.Get(); if (upgrades) { upgrades.CleanList(); } SceneManager.LoadScene(sceneName); } else { SceneManager.LoadScene(sceneName); } Time.timeScale = 1; }
// // Start is called before the first frame update void Start() { upgradeSystem = UpgradeSystem.Get(); Upgrade.OnUpgradePurcharsed = UpdateText; upgradeSystem.parent = parentForUpgrades; upgradeSystem.AssignUpgrades(); for (int i = 0; i < upgradeSystem.allUpgrades.Count; i++) { UpdateText(upgradeSystem.allUpgrades[i].id); } mainCanvas.SetActive(true); backgroundCanvas.SetActive(false); }
public void ResetEverything() { upgrades = UpgradeSystem.Get(); if (upgrades) { upgrades.ResetUpgrades(); } PlayerPrefs.SetInt("isFirstTimePlaying", 1); buttonAppearCounter = 0; button.SetActive(false); SceneManager.LoadScene("Home Screen"); }
// Start is called before the first frame update private void Start() { int goToTutorial = PlayerPrefs.GetInt("isFirstTimePlaying", 1); if (goToTutorial == 1) { PlayerPrefs.SetInt("isFirstTimePlaying", 1); } else if (goToTutorial == 0) { PlayerPrefs.SetInt("isFirstTimePlaying", 0); } Debug.Log(goToTutorial); upgrades = UpgradeSystem.Get(); button.SetActive(false); }
private void GameOver() { int originalPoints = PlayerPrefs.GetInt("UpgradePoints", 0); PlayerPrefs.SetInt("UpgradePoints", originalPoints + upgradePointsCurrentMatch); UpgradeSystem.Get().UpdatePoints(); movement.enabled = false; shoot.enabled = false; GameOverPanel.SetActive(true); TurretSpawner.Get().preview = false; TurretSpawner.Get().StopAllOutlines(); if (OnLevelGameOver != null) { OnLevelGameOver(); } AkSoundEngine.PostEvent("perder", gameOverSound); }
public void RepeatScene() { if (SceneManager.GetActiveScene().name == "Gameplay") { Destroy(GameManager.Get().gameObject); Destroy(WaveSystem.Get().gameObject); Destroy(TurretSpawner.Get().gameObject); Destroy(Highscore.Get().gameObject); Destroy(MilestoneManager.Get().gameObject); } SceneManager.LoadScene(SceneManager.GetActiveScene().name); Time.timeScale = 1; UpgradeSystem upgrades = UpgradeSystem.Get(); if (upgrades) { upgrades.CleanList(); } }
public void BuyUpgrade() { animation.ExecuteCurves(); if (UpgradeSystem.Get().BuyUpgrade(id)) { switch (id) { case 0: AkSoundEngine.PostEvent("upgrade_max", UpgradeSystem.Get().fairyMaxSound); break; case 1: AkSoundEngine.PostEvent("upgrade_cooldown", UpgradeSystem.Get().meteorCooldownSound); break; case 2: AkSoundEngine.PostEvent("upgrade_tower", UpgradeSystem.Get().towerSound); break; case 3: AkSoundEngine.PostEvent("upgrade_speed", UpgradeSystem.Get().fairySpeedSound); break; default: break; } } else { AkSoundEngine.PostEvent("upgrade_error", UpgradeSystem.Get().errorSound); } if (OnUpgradePurcharsed != null) { OnUpgradePurcharsed(id); } }
public void ChangeScene() { if (SceneManager.GetActiveScene().name == "Gameplay") { Destroy(GameManager.Get().gameObject); Destroy(WaveSystem.Get().gameObject); Destroy(TurretSpawner.Get().gameObject); Destroy(Highscore.Get().gameObject); Destroy(MilestoneManager.Get().gameObject); UpgradeSystem upgrades = UpgradeSystem.Get(); if (upgrades) { upgrades.CleanList(); } AkSoundEngine.StopAll(); } else if (SceneManager.GetActiveScene().name == "Upgrade Screen") { AkSoundEngine.StopAll(); } if (sceneName == "Upgrade Screen") { AkSoundEngine.StopAll(); UpgradeSystem upgrades = UpgradeSystem.Get(); if (upgrades) { upgrades.CleanList(); } int goToTutorial = PlayerPrefs.GetInt("isFirstTimePlaying", 1); if (goToTutorial == 1) { SceneManager.LoadScene("Tutorial"); } else if (goToTutorial == 0) { SceneManager.LoadScene(sceneName); } } else if (sceneName == "Gameplay") { AkSoundEngine.StopAll(); UpgradeSystem upgrades = UpgradeSystem.Get(); if (upgrades) { upgrades.CleanList(); } int goToTutorial = PlayerPrefs.GetInt("isFirstTimePlaying", 1); if (goToTutorial == 1) { SceneManager.LoadScene("Tutorial"); } else if (goToTutorial == 0) { LoaderManager.Get().LoadScene(sceneName); UILoadingScreen.Get().SetVisible(true); } } else { SceneManager.LoadScene(sceneName); } Time.timeScale = 1; }