Example #1
0
        private void Update()
        {
            if (DebugPauseNextFrame)
            {
                Debugger.Break();
                UnityEngine.Debug.Break();
                DebugPauseNextFrame = false;
            }

            DebugUtil.HandleInput();

            float deltaTime       = Time.deltaTime;
            float playerTime      = deltaTime;
            float playerFireScale = deltaTime * PlayerFireDeltaTimeScale * Player.RetributionTimeScale;

            UpdateStatuses(deltaTime);

            if (Player.IsAlive)
            {
                float fireStrategyDt = playerFireScale * Player.FireSpeedScale;
                if (CurrentFireStrategy.UpdateActivates(fireStrategyDt, out float fireStrategyOverflowDt))
                {
                    // Be polite and cap to 2 frames. In case you want to set fire speed to level 999.
                    const float MaxOverflow = 1f / 30f;
                    fireStrategyOverflowDt = Math.Min(fireStrategyOverflowDt, MaxOverflow);
                    FireCurrentStrategy(fireStrategyOverflowDt);

                    _Othello.Fire(fireStrategyOverflowDt);
                }

                UpdateFireStrategy(playerTime);
                WeaponRain(deltaTime);
                OneUpRain(deltaTime);


                float enemyTimeScale = TimeScaleManager.GetTimeScaleModifier(TimeScaleType.Enemy);
                float enemyDeltaTime = deltaTime * enemyTimeScale;
                Director.RunFrame(enemyDeltaTime, deltaTime);

                _PowerupManager.PassiveUpdate(playerFireScale, deltaTime);
                ManagedGameTasks.RunFrames(deltaTime);
            }

            NotificationManager.RunFrame(deltaTime);
        }
Example #2
0
        public void SetFireType(int index, bool skipDropDown = false, bool skipMessage = false, bool endlessTime = false)
        {
            // Immediately fire BFG if it's charging
            if (BfgBulletSpawner.Instance.isActiveAndEnabled)
            {
                FireCurrentStrategy(0f);
            }

            FireStrategies.Index = index;
            CurrentFireStrategy.Reset();
            CurrentFireStrategy.OnActivate();

            if (!skipDropDown)
            {
                DebugUi.SetDropdownFiretype(FireStrategies.Index, true, endlessTime);
            }

            WeaponResetTimer.Reset();
            if (index != DefaultFireTypeIndex)
            {
                if (endlessTime)
                {
                    WeaponResetTimer.ActivationInterval = float.MaxValue;
                }
                else
                {
                    WeaponResetTimer.ActivationInterval = InitialWeaponTime;
                }
            }
            else
            {
                WeaponResetTimer.ActivationInterval = InitialWeaponTime;
            }

            if (!skipMessage)
            {
                NotificationManager.AddNotification(CurrentFireStrategy.NotificationName(WeaponLevel));
            }

            if (endlessTime)
            {
                SaveUtil.LastWeapon = index;
            }
        }
Example #3
0
        private void FireCurrentStrategy(float fireStrategyOverflowDt)
        {
            var bullets = CurrentFireStrategy.GetBullets(WeaponLevel, Player.FirePosition);

            if (CurrentFireStrategy.UpdateOnFire)
            {
                foreach (var bullet in bullets)
                {
                    bullet.RunFrame(fireStrategyOverflowDt, fireStrategyOverflowDt);
                }
            }

            FirePlayerBullets(bullets);

            var clip = bullets[0]?.FireSound;

            if (clip != null)
            {
                Player.PlaySoundAtCenter(clip);
            }
        }