Beispiel #1
0
    public float judgeAbility(Unit user, Tile move, out Tile target)
    {
        HashSet <Tile> possibleTargets = GetAvailableTargets(move);

        target = null;
        if (possibleTargets.Count == 0)
        {
            return(0);
        }

        float value    = 0;
        float maxValue = 0;

        foreach (Tile q in possibleTargets)
        {
            value = 0;
            if (q.Unit.damageTaken < user.Character.Level + 10)
            {
                value = 0;
            }
            else
            {
                value  = q.Unit.damageTaken;
                value += 5;
                HashSet <Unit> enemyUnits = UnitManager.Instance.GetUnitsByHostility(user);
                foreach (Unit u in enemyUnits)
                {
                    if (Melee.StaticGetTiles(u.Tile).Contains(move))
                    {
                        value -= 1;
                    }
                    if (Ranged.staticGetTiles(u.Tile).Contains(move))
                    {
                        value -= 1;
                    }
                }
            }

            if (value > maxValue)
            {
                target   = q;
                maxValue = value;
            }
        }
        return(maxValue);
    }