コード例 #1
0
    public void UpdateState()
    {
        if (aiPlayer.targetedEnemy == null || reEvalutateTarget)
        {
            switch (aiPlayer.targetChoose)
            {
            case Strategy.TargetPref.Closest:
                FindClosestTarget();
                break;

            case Strategy.TargetPref.Lowest:
                FindLowestHealthTarget();
                break;

            case Strategy.TargetPref.Active:
                FindActivePlayerTarget();
                break;

            default:
                FindClosestTarget();
                break;
            }
            reEvalutateTarget = false;
        }
        if (aiPlayer.targetedEnemy != null)
        {
            if (aiPlayer.targetedEnemy.GetComponent <EnemyHealth>().isDead)
            {
                reEvalutateTarget = true;
            }
            MoveAndShoot();
            if (aiPlayer.activeSpecialAbility == null)
            {
                if (Time.time > lastAbilityCast + timeBetweenCasts + lastAbilityDelay)
                {
                    EvaluateSpecial();
                }
            }
            else
            {
                lastAbilityCast = Time.time;
                //Use Special based on its action
                switch (aiPlayer.activeSpecialAbility.GetCoopAction())
                {
                case AbilityHelper.CoopAction.TargetHurt:
                    lastAbilityDelay = aiPlayer.activeSpecialAbility.timeToCast;
                    UseOffensiveTargetSpecial();
                    break;

                case AbilityHelper.CoopAction.AOEHurt:
                    lastAbilityDelay = aiPlayer.activeSpecialAbility.timeToCast;
                    UseOffensiveTargetSpecial();
                    break;

                case AbilityHelper.CoopAction.Equip:
                    lastAbilityDelay = aiPlayer.activeSpecialAbility.timeToCast;
                    aiPlayer.activeSpecialAbility.Execute(aiPlayer.player, aiPlayer.gameObject, aiPlayer.gameObject);
                    break;

                case AbilityHelper.CoopAction.InstantHeal:
                    lastAbilityDelay = aiPlayer.activeSpecialAbility.timeToCast;
                    aiPlayer.activeSpecialAbility.Execute(aiPlayer.player, aiPlayer.gameObject, aiPlayer.gameObject);
                    break;

                case AbilityHelper.CoopAction.AOEHeal:
                    lastAbilityDelay = aiPlayer.activeSpecialAbility.timeToCast;
                    UseDefensiveTargetSpecial();
                    break;

                default:
                    aiPlayer.activeSpecialAbility = null;
                    break;
                }

                aiPlayer.activeSpecialAbility = null;
            }
        }

        aiPlayer.CheckLocalVision(); //Update visible enemies
        WatchActiveplayerForFlee();
        HandleDestinationAnimation(aiPlayer.targetedEnemy, aiPlayer.abilities.Basic);
    }
コード例 #2
0
ファイル: DefendState.cs プロジェクト: jishclurk/CapstoneGame
    public void UpdateState()
    {
        if (!(aiPlayer.navMeshAgent.remainingDistance > aiPlayer.navMeshAgent.stoppingDistance)) //giant ugly if statement that says don't start shooting until you reach your destination
        {
            if (aiPlayer.targetedEnemy == null || reEvalutateTarget)
            {
                switch (aiPlayer.targetChoose)
                {
                case Strategy.TargetPref.Closest:
                    FindClosestTarget();
                    break;

                case Strategy.TargetPref.Lowest:
                    FindLowestHealthTarget();
                    break;

                case Strategy.TargetPref.Active:
                    FindActivePlayerTarget();
                    break;

                default:
                    FindClosestTarget();
                    break;
                }
                reEvalutateTarget = false;
            }
            if (aiPlayer.targetedEnemy != null)
            {
                MoveAndShoot();
                if (aiPlayer.activeSpecialAbility == null)
                {
                    if (Time.time > lastAbilityCast + timeBetweenCasts + lastAbilityDelay)
                    {
                        EvaluateSpecial();
                    }
                }
                else
                {
                    lastAbilityCast = Time.time;
                    //Use Special based on its action
                    switch (aiPlayer.activeSpecialAbility.GetCoopAction())
                    {
                    case AbilityHelper.CoopAction.TargetHurt:
                        lastAbilityDelay = aiPlayer.activeSpecialAbility.timeToCast;
                        UseOffensiveTargetSpecial();
                        break;

                    case AbilityHelper.CoopAction.AOEHurt:
                        lastAbilityDelay = aiPlayer.activeSpecialAbility.timeToCast;
                        UseOffensiveTargetSpecial();
                        break;

                    case AbilityHelper.CoopAction.Equip:
                        lastAbilityDelay = aiPlayer.activeSpecialAbility.timeToCast;
                        aiPlayer.activeSpecialAbility.Execute(aiPlayer.player, aiPlayer.gameObject, aiPlayer.gameObject);
                        break;

                    case AbilityHelper.CoopAction.InstantHeal:
                        lastAbilityDelay = aiPlayer.activeSpecialAbility.timeToCast;
                        aiPlayer.activeSpecialAbility.Execute(aiPlayer.player, aiPlayer.gameObject, aiPlayer.gameObject);
                        break;

                    case AbilityHelper.CoopAction.AOEHeal:
                        lastAbilityDelay = aiPlayer.activeSpecialAbility.timeToCast;
                        UseDefensiveTargetSpecial();
                        break;

                    default:
                        aiPlayer.activeSpecialAbility = null;
                        break;
                    }

                    aiPlayer.activeSpecialAbility = null;
                }
            }
        } // end ugly if statement

        aiPlayer.CheckLocalVision(); //Update visible enemies
        HandleDestinationAnimation(aiPlayer.targetedEnemy, aiPlayer.abilities.Basic);
    }