Ejemplo n.º 1
0
        // Algorithm that tries to move the monster closer to the target.
        public BattleTile MoveCloser(BattleTile target, BattleTile current)
        {
            TargetList = new List <BattleTile>();
            BattleTile newLocation = new BattleTile(current);

            MoveCloser(target, new BattleTile(current), 0, 0, current.GetMove());
            foreach (BattleTile t in TargetList)
            {
                // Manhattand Distance is used to select the closest tile to the target whether or not it is within range.
                if (ManhattanDistance(t.Row, t.Column, target.Row, target.Column) < ManhattanDistance(newLocation.Row, newLocation.Column, target.Row, target.Column))
                {
                    newLocation = t;
                }
            }

            // Returns the new monster location closest to the target. Might be the current location in which case the monster did not move.
            return(Grid[newLocation.Column][newLocation.Row]);
        }