public void Move(Player actor, Tile tile)
        {
            if (Constants.Debug) Console.WriteLine("{0} moved {1}", actor.Name, Direction);
            actor.Tile.Player = null;

            actor.X = tile.X;
            actor.Y = tile.Y;

            tile.Player = actor;
            actor.Tile = tile;
        }
Esempio n. 2
0
        public static Map CreateFromArray(string[] data)
        {
            Map map = new Map();
            for (int y = 0; y < data.Length; y++)
            {
                string line = data[y];
                List<Tile> list = new List<Tile>();
                for (int x = 0; x < line.Length; x++)
                {
                    char symbol = line[x];
                    Tile tile = new Tile(x, y);
                    tile.Symbol = symbol;
                    if (symbol != ' ') tile.IsSolid = true;

                    list.Add(tile);
                }
                map.Tiles.Add(list);
            }
            return map;
        }
Esempio n. 3
0
 public void CreateBasicMap(int width, int length)
 {
     Random rand = new Random();
     Console.WriteLine("Creating map {0} wide by {1} long", width, length);
     Tiles = new List<List<Tile>>();
     for (int y = 0; y < length; y++)
     {
         List<Tile> list = new List<Tile>();
         for (int x = 0; x < width; x++)
         {
             Tile tile = new Tile(x, y);
             if (rand.NextDouble() > 0.7) tile.IsSolid = true;
             list.Add(tile);
         }
         Tiles.Add(list);
     }
 }
 public static double GetDistance(Tile tileA, Tile tileB)
 {
     return GetDistance(tileA.X, tileA.Y, tileB.X, tileB.Y);
 }