예제 #1
0
 // The AI function of enemies. They always use abilities once they are available from cooldown.
 // Otherwise they do basic attacks to random targets.
 public Queue<Action> ActionAI(List<Combatant> targets, List<Combatant> allies)
 {
     if (ability.GetCD() <= 0)
     {
         ability.PutOnCD();
         if (ability.needsTarget)
         {
             AbilityTargeted targetableAbility = ability as AbilityTargeted;
             targetableAbility.SetTarget(GetTargetable(targets)[0]);
             return targetableAbility.GetActions(this, allies, targets);
         }
         else
         {
             return ability.GetActions(this, allies, targets);
         }
     }
     else
     {
         AbilityTargeted basicAttack = new AbilityBasicAttack();
         basicAttack.SetTarget(GetTargetable(targets)[0]);
         return basicAttack.GetActions(this, allies, targets);
     }
 }
    // Called after an enemy is chosen for a particular action
    void CleanupActions()
    {
        // For an attack action
        if (choseAttack) {
            state = State.Resolve;
            AbilityBasicAttack basicAttack = new AbilityBasicAttack();
            basicAttack.SetTarget(target);
            Queue<Action> abilityActions = basicAttack.GetActions(combatants[currentIndex], crewMembers, enemies);
            while (abilityActions.Count > 0) {
                actions.Add(abilityActions.Dequeue());
            }
        }

        // For an ability action
        if (choseAbility) {
            // Get the ability of the current crew and set its target to the selected enemy
            AbilityTargeted ability = combatants[currentIndex].ability as AbilityTargeted;
            ability.SetTarget(target);
            if (ability != null) {
                Combatant me = combatants[currentIndex];
                Queue<Action> abilityActions = ability.GetActions(me, crewMembers, enemies);
                while (abilityActions.Count > 0) {
                    actions.Add(abilityActions.Dequeue());
                }
                combatants[currentIndex].ability.PutOnCD(); // Put ability on cooldown
            }
        }

        // Retrieve status effects and activate them at the end of turn

        state = State.Resolve;
    }