コード例 #1
0
    /// <summary>
    /// All entities choose their skill and target
    /// </summary>
    /// <returns></returns>
    private IEnumerator PrepTurn()
    {
        Debug.Log(string.Format("===== TURN {0} =====", _turnNumber++));

        // To check if damage and dpp was correctly handled. TODO: Need to remove after!
        foreach (BattleEntityMoveInfo currEnt in _entityBattleInfos)
        {
            Debug.Log("The Current entity is: " + currEnt.Source + ", his health is: " + currEnt.Source.Hp + ", his DPP is " + currEnt.Source.Dpp);
        }

        foreach (BattleEntityMoveInfo selecEnemy in Enemies)
        {
            if (!selecEnemy.Source.IsDead)
            {
                // Choose the skill you for the enemy
                var selecSkillEnemy = new CoroutineData <Skill>(this, selecEnemy.Source.ChooseEnemySkill());
                yield return(selecSkillEnemy.Coroutine);

                selecEnemy.Skill = selecSkillEnemy.Result;

                // Choose target for skill
                selecEnemy.Target = Allies.Random().Source;
                Debug.Log("The selected Enemy: " + selecEnemy.Source + " , the selected Skill is: " + selecEnemy.Skill +
                          " , the selected target is: " + selecEnemy.Target);
            }
        }

        while (_entityBattleInfos.Any(e => e.Source.IsAlly && e.Target == null))
        {
            var cdTarget = new CoroutineData <BattleEntityMoveInfo>(this, SelectOrigin());
            yield return(cdTarget.Coroutine);

            var selecAlly = cdTarget.Result;
            Debug.Log("The selected Ally: " + selecAlly.Source + " , the selected Skill is: " + selecAlly.Skill +
                      " , the selected target is: " + selecAlly.Target);
        }

        Debug.Log("All entities have a target.");
    }