public void OnClick() { if (Scroller.IsBackgroundScrolling()) { return; } int currentLevel = GameController.Instance.GetLevel(); if (ChangeDirection == Direction.Down) { if (GameController.Instance.GetNextLevelCost() <= GameController.Instance.GetMoney() && !_isPricetagHidden) { AudioController.Instance.PlayAudioEffect(BuyLevelSound, BuyLevelSoundVolume); GameController.Instance.AddMaxLevel(); } if (currentLevel < GameController.Instance.GetMaxLevel()) { AudioController.Instance.PlayAudioEffect(MoveDownSound, MoveDownSoundVolume); ChangeLevel(++currentLevel); } } else if (ChangeDirection == Direction.Up && currentLevel > 1) { AudioController.Instance.PlayAudioEffect(MoveUpSound, MoveDownSoundVolume); ChangeLevel(--currentLevel); } }
public IEnumerator StartAnimation() { GameObject instantiatedAnimatedPrestigeGameObject = Instantiate(AnimatedPrestige); ParticleSystem particleSystem = instantiatedAnimatedPrestigeGameObject.GetComponent <ParticleSystem>(); OreProbabilitesGameObject.SetActive(false); ShadowGameObject.SetActive(false); SliderGameObject.SetActive(false); PriceTagGameObject.SetActive(false); GameObject rock = GameObject.FindWithTag("Rock"); if (rock != null) { Destroy(rock); } AudioController.Instance.PlayAudioEffectInLoop(CrystalSound, CrystalSoundVolume); StartCoroutine(ChangeLevel()); while (!_isLevelChangeFinished) { if (!Scroller.IsBackgroundScrolling()) { Scroller.ScrollBackground(Direction.Up); } yield return(null); } particleSystem.Stop(); Destroy(instantiatedAnimatedPrestigeGameObject, particleSystem.main.duration); AudioController.Instance.StopAndDestroyLoopedAudioEffects(); OreProbabilitesGameObject.SetActive(true); ShadowGameObject.SetActive(true); SliderGameObject.SetActive(true); PriceTagGameObject.SetActive(true); GameController.Instance.SpawnRock(); }