public void Update()
        {
            //Debug.Log(aiController.gameObject.name + ": AttackState.Update()");

            aiController.UpdateTarget();

            if (aiController.MyTarget != null)
            {
                aiController.MyBaseCharacter.MyCharacterUnit.MyCharacterMotor.FaceTarget(aiController.MyTarget);
                if (!aiController.IsTargetInHitBox(aiController.MyTarget))
                {
                    // target is out of range, follow it
                    aiController.ChangeState(new FollowState());
                }
                else
                {
                    // target is in range, attack it
                    if (aiController.MyBaseCharacter.MyCharacterCombat.MyWaitingForAutoAttack == false)
                    {
                        // we were getting too much spam in logs from just passing this through rather than waiting until it was a valid action
                        aiController.AttackCombatTarget();
                    }
                }
                // check range and attack
            }
            else
            {
                //Debug.Log(aiController.gameObject.name + ": about to change to returnstate");
                aiController.ChangeState(new ReturnState());
            }
        }
示例#2
0
        public void Update()
        {
            //Debug.Log(aiController.gameObject.name + ": AttackState.Update()");

            aiController.UpdateTarget();

            if (aiController.MyTarget == null)
            {
                //Debug.Log(aiController.gameObject.name + ": about to change to returnstate");
                aiController.ChangeState(new ReturnState());
                return;
            }

            if (aiController.MyBaseCharacter.MyCharacterAbilityManager.MyWaitingForAnimatedAbility == true)
            {
                //Debug.Log(aiController.gameObject.name + ".AttackState.Update() MyWaitingForAnimatedAbility is true");
                // nothing to do, animated ability in progress
                return;
            }

            if (aiController.MyBaseCharacter.MyCharacterCombat.MyWaitingForAutoAttack == true)
            {
                //Debug.Log(aiController.gameObject.name + ".AttackState.Update() MyWaitingForAutoAttack == true");
                // nothing to do, auto-attack in progress
                return;
            }

            if (aiController.MyBaseCharacter.MyCharacterAbilityManager.MyIsCasting == true || aiController.MyBaseCharacter.MyCharacterAbilityManager.MyCurrentCastCoroutine != null)
            {
                //Debug.Log(aiController.gameObject.name + ".AttackState.Update() MyCurrentCast != null || MyIsCasting == true");
                // nothing to do, cast in progress
                return;
            }

            // face target before attack to ensure they are in the hitbox
            aiController.MyBaseCharacter.MyAnimatedUnit.MyCharacterMotor.FaceTarget(aiController.MyTarget);

            if (aiController.CanGetValidAttack(true))
            {
                return;
            }

            // no valid ability found, try auto attack range check
            if (!aiController.IsTargetInHitBox(aiController.MyTarget))
            {
                // target is out of range, follow it
                aiController.ChangeState(new FollowState());
                return;
            }

            // target is in range, attack it
            //aiController.AttackCombatTarget();
        }
示例#3
0
        private void MakeFollowDecision()
        {
            aiController.UpdateTarget();

            if (aiController.MyTarget != null)
            {
                //Debug.Log("current agro range is " + parent.MyAggroRange.ToString() + " and current distance to target is " + parent.MyDistanceToTarget);
                // evade if the target is out of aggro range.  In the future this could also be calculated as distance from start point if we would rather use a leash approach
                // temporarily disable leashing.

                /*
                 * if (Vector3.Distance(aiController.transform.position, aiController.MyStartPosition) > aiController.MyLeashDistance ) {
                 *  aiController.ChangeState(new EvadeState());
                 *  return;
                 * }
                 */
                /*
                 * if (aiController.MyDistanceToTarget > aiController.MyAggroRange) {
                 *  aiController.ChangeState(new EvadeState());
                 *  return;
                 * }
                 */

                if (aiController.CanGetValidAttack())
                {
                    aiController.ChangeState(new AttackState());
                    return;
                }
                if (aiController.IsTargetInHitBox(aiController.MyTarget))
                {
                    // they are in the hitbox and we can attack them
                    aiController.ChangeState(new AttackState());
                }
                else
                {
                    //Debug.Log(aiController.gameObject.name + ": FollowTarget: " + aiController.MyTarget.name);
                    // if within agro distance but out of hitbox range, move toward target
                    if (aiController.HasMeleeAttack() || (aiController.GetMinAttackRange() > 0f && (aiController.GetMinAttackRange() < aiController.MyDistanceToTarget)))
                    {
                        aiController.FollowTarget(aiController.MyTarget, aiController.GetMinAttackRange());
                    }
                    else
                    {
                        aiController.MyBaseCharacter.AnimatedUnit.MyCharacterMotor.StopFollowingTarget();
                    }
                }
            }
            else
            {
                // there is no target so start idling.  should we return to our start position instead?
                aiController.ChangeState(new ReturnState());
            }
        }
        public void Update()
        {
            //Debug.Log(aiController.gameObject.name + ": FollowState.Update()");
            aiController.UpdateTarget();

            if (aiController.MyTarget != null)
            {
                //Debug.Log("current agro range is " + parent.MyAggroRange.ToString() + " and current distance to target is " + parent.MyDistanceToTarget);
                // evade if the target is out of aggro range.  In the future this could also be calculated as distance from start point if we would rather use a leash approach
                // temporarily disable leashing.

                /*
                 * if (Vector3.Distance(aiController.transform.position, aiController.MyStartPosition) > aiController.MyLeashDistance ) {
                 *  aiController.ChangeState(new EvadeState());
                 *  return;
                 * }
                 */
                /*
                 * if (aiController.MyDistanceToTarget > aiController.MyAggroRange) {
                 *  aiController.ChangeState(new EvadeState());
                 *  return;
                 * }
                 */
                if (aiController.IsTargetInHitBox(aiController.MyTarget))
                {
                    // they are in the hitbox and we can attack them
                    aiController.ChangeState(new AttackState());
                }
                else
                {
                    //Debug.Log(aiController.gameObject.name + ": FollowTarget: " + aiController.MyTarget.name);
                    // if within agro distance but out of hitbox range, move toward target
                    aiController.FollowTarget(aiController.MyTarget);
                }
            }
            else
            {
                // there is no target so start idling.  should we return to our start position instead?
                aiController.ChangeState(new ReturnState());
            }
        }