Exemple #1
0
    private Tile MakeAiActionTarget(BaseAction action)
    {
        List <Tile> possibleTargets = action.GetTargetTiles(GameMap.instance, currentUnit.tile);
        List <int>  advantages      = new List <int>();

        foreach (Tile t in possibleTargets)
        {
            List <Unit> aiTargets = action.GetValidTargets(action.GetAoeTiles(GameMap.instance, t, currentUnit.tile));
            advantages.Add(action.CalcTotalAdvantage(currentUnit, aiTargets));
        }
        int maxAdvantage      = 0;
        int maxAdvantageIndex = -1;

        for (int i = 0; i < advantages.Count; i++)
        {
            if (advantages[i] > maxAdvantage)
            {
                maxAdvantage      = advantages[i];
                maxAdvantageIndex = i;
            }
        }
        if (maxAdvantageIndex > -1)
        {
            return(possibleTargets[maxAdvantageIndex]);
        }
        else
        {
            return(null);
        }
    }