Exemple #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);
                }
            }
        }
Exemple #2
0
 protected override void OnStateUpdated()
 {
     if (coroutine_ == null && InGameConstants.IsAllowedToChargeLasers(StateMachine_.Player))
     {
         coroutine_ = CoroutineWrapper.DoAfterDelay(GetRandomCheckAttackDelay(), () => {
             StateMachine_.SwitchState(AIStateMachine.State.Attack);
         });
     }
 }
Exemple #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);
                });
            });
        }
Exemple #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);
                });
            });
        }
Exemple #5
0
        protected override void OnStateUpdated()
        {
            UpdateTarget();

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

            UpdateFuzzyTargetPosition();
            HeadTowardsFuzzyTargetPosition();
        }
Exemple #6
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;
            }
        }
        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);
            }
        }