Ejemplo n.º 1
0
        private IEnumerator CheckDashAttack()
        {
            while (true)
            {
                yield return(new WaitForSeconds(GetRandomCheckAttackDelay()));

                if (!ShouldCheckDashAttack(StateMachine_.Player))
                {
                    continue;
                }

                BattlePlayer target = BattlePlayerUtil.GetClosestEnemyPlayerFor(StateMachine_.Player, whereCondition: (otherPlayer) => {
                    return(!AIUtil.DoesWallExistBetweenXZPoints(StateMachine_.Player.transform.position, otherPlayer.transform.position));
                });
                if (target == null)
                {
                    continue;
                }

                Vector2 playerToTargetVector = BattlePlayerUtil.XZVectorFromTo(StateMachine_.Player, target);

                if (playerToTargetVector.magnitude <= kDashAggroDistance)
                {
                    StateMachine_.SwitchState(AIStateMachine.State.DashAttack);
                }
            }
        }
Ejemplo n.º 2
0
 protected override void OnStateUpdated()
 {
     if (coroutine_ == null && InGameConstants.IsAllowedToChargeLasers(StateMachine_.Player))
     {
         coroutine_ = CoroutineWrapper.DoAfterDelay(GetRandomCheckAttackDelay(), () => {
             StateMachine_.SwitchState(AIStateMachine.State.Attack);
         });
     }
 }
Ejemplo n.º 3
0
        private void HandleFullyChargedLaser()
        {
            delayedAttackAction_ = CoroutineWrapper.DoAfterDelay(StateMachine_.AIConfiguration.RandomReactionTime(), () => {
                StateMachine_.InputState.LaserPressed = false;

                // NOTE (darren): why delay here? to simulate AI watching laser hit / miss target :)
                delayedAttackAction_ = CoroutineWrapper.DoAfterDelay(StateMachine_.AIConfiguration.RandomReactionTime(), () => {
                    StateMachine_.SwitchState(AIStateMachine.State.Idle);
                });
            });
        }
Ejemplo n.º 4
0
        protected override void OnStateEntered()
        {
            Vector2 dashDirection = StateMachine_.DashDirection;

            StateMachine_.InputState.LerpMovementVectorTo(dashDirection, () => {
                StateMachine_.InputState.Dash();

                coroutine_ = CoroutineWrapper.DoAfterDelay(StateMachine_.AIConfiguration.RandomReactionTime(), () => {
                    StateMachine_.SwitchState(AIStateMachine.State.Idle);
                });
            });
        }
        private void Continue()
        {
            // TODO (darren): do this is a different way later
            // when we have actual AI selection (customization)
            if (InGameConstants.FillWithAI)
            {
                int missingPlayersCount = Math.Max(0, GameConstants.Instance.PlayersToFill - RegisteredPlayers.AllPlayers.Count);
                RegisteredPlayersUtil.RegisterAIPlayers(missingPlayersCount);
            }

            StateMachine_.Continue();
        }
Ejemplo n.º 6
0
        protected override void OnStateUpdated()
        {
            UpdateTarget();

            if (target_ == null)
            {
                StateMachine_.SwitchState(AIStateMachine.State.Idle);
                return;
            }

            UpdateFuzzyTargetPosition();
            HeadTowardsFuzzyTargetPosition();
        }
Ejemplo n.º 7
0
        private void HandleScoringFinished()
        {
            BattleCamera.Instance.ClearTransformsOfInterest();
            BattlePlayerPart.RemoveCollidersFromAll();

            CoroutineWrapper.DoAfterDelay(kResetCameraDelay, () => {
                if (PlayerScores.HasWinner)
                {
                    StateMachine_.HandleGameFinished();
                }
                else
                {
                    StateMachine_.Continue();
                }
            });
        }
Ejemplo n.º 8
0
        protected override void OnStateEntered()
        {
            if (!InGameConstants.IsAllowedToChargeLasers(StateMachine_.Player))
            {
                StateMachine_.SwitchState(AIStateMachine.State.Idle);
                return;
            }

            fuzzyTargetPosition_ = null;
            StateMachine_.InputState.LaserPressed = true;
            if (ChargedLaserComponent_.FullyCharged)
            {
                HandleFullyChargedLaser();
            }
            else
            {
                ChargedLaserComponent_.OnFullCharge += HandleFullyChargedLaser;
            }
        }
Ejemplo n.º 9
0
        // PRAGMA MARK - Internal
        private void HandleBattlePlayerShotLaser(Laser laser, BattlePlayer battlePlayer)
        {
            if (battlePlayer == StateMachine_.Player)
            {
                return;
            }

            // NOTE (darren): do calculations in XZ space because height doesn't matter in PHASERBEAK
            Vector2 laserDirection    = laser.transform.forward.Vector2XZValue();
            Vector2 laserToSelfVector = (StateMachine_.Player.transform.position - laser.transform.position).Vector2XZValue();

            float angleDistance = Vector2.Angle(laserDirection, laserToSelfVector);

            if (angleDistance > 30.0f)
            {
                return;
            }

            StateMachine_.Dash(GenerateValidDashDirection());
        }
Ejemplo n.º 10
0
        protected override void OnStateUpdated()
        {
            if (target_ == null || !BattlePlayer.ActivePlayers.Contains(target_))
            {
                StateMachine_.SwitchState(AIStateMachine.State.Idle);
                return;
            }

            Vector2 playerToTargetVector = BattlePlayerUtil.XZVectorFromTo(StateMachine_.Player, target_);

            Vector2 targetDirection = playerToTargetVector.normalized;

            if (playerToTargetVector.magnitude <= predictedDashDistance_)
            {
                StateMachine_.Dash(targetDirection);
            }
            else
            {
                StateMachine_.InputState.LerpMovementVectorTowards(targetDirection);
            }
        }
Ejemplo n.º 11
0
 private void GoToMainMenu()
 {
     StateMachine_.GoToMainMenu();
 }
Ejemplo n.º 12
0
 private void PlayAgain()
 {
     StateMachine_.GoToPlayerCustomization();
 }
Ejemplo n.º 13
0
 private void HandleLevelSelected(CoopLevelConfig config)
 {
     CoopLevelManager.SetCurrentLevelConfig(config);
     StateMachine_.GoToPlayerCustomization();
 }
Ejemplo n.º 14
0
 private void GoToTitleScreen()
 {
     StateMachine_.GoToMainMenu();
 }
Ejemplo n.º 15
0
 private void FinishBattle()
 {
     StateMachine_.HandleBattleFinished();
 }