Example #1
0
        private bool fightable(Unit u)
        {
            int  x       = (int)u.x;
            int  y       = (int)u.y;
            Unit current = new Unit("Footman", 0, 0, playerNum, 0, ref gameData);

            if (gameData.isTraversible(x, y - 1) && gameData.target(allUnits, x, y - 1, current, 0).owner == -1)
            {
                return(true);                                                                                                 //check north && target(allUnits, x, y, current, 0).owner == -1
            }
            if (gameData.isTraversible(x, y + 1) && gameData.target(allUnits, x, y + 1, current, 0).owner == -1)
            {
                return(true);                                                                                                 //check south && target(allUnits, x, y, current, 0).owner == -1
            }
            if (gameData.isTraversible(x - 1, y) && gameData.target(allUnits, x - 1, y, current, 0).owner == -1)
            {
                return(true);                                                                                                 //check west && target(allUnits, x, y, current, 0).owner == -1
            }
            if (gameData.isTraversible(x + 1, y) && gameData.target(allUnits, x + 1, y, current, 0).owner == -1)
            {
                return(true);                                                                                                 //check east && target(allUnits, x, y, current, 0).owner == -1
            }
            return(false);
        }