Пример #1
0
        // Update is called on fixed time intervals.
        private void FixedUpdate()
        {
            // Should elevator start counting and not started counting yet?
            if (GameManager.ElevatorCounting == true && _ElevatorStartedCounting == false)
            {
                // Yes.
                _ElevatorStartedCounting = true;
                _TickerCounter.ReSetTickCounter(1);
            }

            // Is time to resetCountdown?
            if (_TickerCounter.IsItTimeToCalculate() == true)
            {
                // Decrease the oxigen, if above zero.
                if (GameManager.CurrentAirBubbles > 0)
                {
                    // Is elevator counting?
                    if (GameManager.ElevatorCounting == true)
                    {
                        // Yes.
                        GameManager.CurrentAirBubbles -= 2;
                        GameManager.AddAirScore();
                    }
                    else
                    {
                        GameManager.CurrentAirBubbles--;
                    }

                    _IsTimeToDraw = true;
                }
                else
                {
                    // Is elevator counting?
                    if (GameManager.ElevatorCounting == true)
                    {
                        // Yes.
                        // Chage state to level compete.
                        GameManager.LevelCompleted = true;
                    }
                    else
                    {
                        // No.
                        // In this case, player died.
                        _SoundSource.PlayOneShot(_DeathSound);
                        GameManager.PlayerIsDead = true;
                    }
                }
            }
        }
Пример #2
0
        // Fixed update is called on fixed time intervals.
        private void FixedUpdate()
        {
            if (GameManager.IsGamePaused == false)
            {
                // Is time to resetCountdown?
                if (_TickerCounter.IsItTimeToCalculate() == true)
                {
                    // Yes.
                    // Get random sunbeam: 1 to 7.
                    _NextSunbeam = Mathf.FloorToInt(Random.Range(1.0f, 7.99f));

                    // Get random tick count: from 4 to 45.
                    _TickerCounter.ReSetTickCounter(Mathf.FloorToInt(Random.Range(4.0f, 45.99f)));

                    _IsTimeToDraw = true;
                }
            }
        }