public void Initialize(HudGameplayController hudGameplay) { SetState(CoinObjectState.Coin); _currentChestCounter = null; _hudGameplayController = hudGameplay; _hudCoinTarget = hudGameplay.GetCoinHudTargetTransform(); }
private void SetState(CoinObjectState state) { _state = state; var isCoin = state == CoinObjectState.Coin; _animator.SetBool("Coin", isCoin); _coinSpriteObj.SetActive(isCoin); _animator.SetBool("Chest", !isCoin); _chestSpriteObj.SetActive(!isCoin); _currentSpriteObj = isCoin ? _coinSpriteObj : _chestSpriteObj; if (isCoin && _currentChestCounter != null) { _currentChestCounter.OnFinish(); _currentChestCounter = null; } }
private IEnumerator RunChestCountdown() { _currentChestCounter = Instantiate <ChestCounterLogic>(_chestCounterPrefab); _hudGameplayController.AddToGameplayUI(_currentChestCounter.transform); _currentChestCounter.Initialize(_chestSpriteObj.transform); float countDown = _chestSpawnCountdown; while (countDown > 0.0f && _currentChestCounter != null) { _currentChestCounter.UpdateValue(countDown); countDown -= Time.deltaTime; yield return(null); } if (_state == CoinObjectState.Chest) { SetState(CoinObjectState.Coin); } }