Esempio n. 1
0
        static void Main()
        {
            ConsoleKey key;
            Tile playerTile = new Tile('@', 0x80, new Guid("11111111111111111111111111111111"));
            mr.currentMap.addTileAt(playerX, playerY, playerTile, true);
            mr.RenderLocalMap();

            //keep processing key presses until the player wants to quit
            while ((key = Console.ReadKey(true).Key) != ConsoleKey.Q)
            {
                //put the square they were standing on before back to normal
                mr.currentMap.removeTileAt(playerX, playerY, 0);
                //change the player's location if they pressed an arrow key
                switch (key)
                {
                    case ConsoleKey.UpArrow:
                        MovePlayer(playerX, playerY - 1);
                        break;
                    case ConsoleKey.DownArrow:
                        MovePlayer(playerX, playerY + 1);
                        break;
                    case ConsoleKey.LeftArrow:
                        MovePlayer(playerX - 1, playerY);
                        break;
                    case ConsoleKey.RightArrow:
                        MovePlayer(playerX + 1, playerY);
                        break;
                }
                //now add the player to the new square
                mr.currentMap.addTileAt(playerX, playerY, playerTile, true);
                mr.RenderLocalMap();
            }
        }
Esempio n. 2
0
 public Tile getVisibleTileAt(int x, int y)
 {
     Tile ret = new Tile();
     try
     {
         ret = mapData[x, y][0];
     }
     catch (IndexOutOfRangeException)
     {
         ret.contentID = new Guid("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00");
     }
     return ret;
 }
Esempio n. 3
0
 public int addTileAt(int x, int y, Tile tileToAdd, bool onTop = true)
 {
     try
     {
         if (onTop == true)
         {
             mapData[x, y].Insert(0, tileToAdd);
             return 0;
         }
         else
         {
             mapData[x, y].Add(tileToAdd);
             return mapData[x, y].Count;
         }
     }
     catch (IndexOutOfRangeException)
     {
         return -1;
     }
 }