Beispiel #1
0
        private static IGameObject LoadTile(int tileNumber, Tileset tileset)
        {
            // -1 specifies no tile.
            if (tileNumber <= -1)
            {
                return null;
            }

            int x = tileNumber % (int)tileset.PassabilityMapping[0].Length;
            int y = tileNumber / (int)tileset.PassabilityMapping[0].Length;
            return tileset.GetTile(x, y);
        }
Beispiel #2
0
 public static IList<IGameObject> LoadTiles(String tilespec, Tileset tileset)
 {
     string[] lines = tilespec.Split(new string[]{Environment.NewLine}, StringSplitOptions.None);
     int[][] tiles = new int[lines.Length][];
     for (int i = 0; i < lines.Length; i++)
     {
         tiles[i] = new int[lines[i].Length];
         for (int j = 0; j < lines[i].Length; j++)
         {
             tiles[i][j] = MapCharToTileValue(lines[i][j]);
         }
     }
     return LoadTiles(tiles, tileset);
 }
Beispiel #3
0
 public static IList<IGameObject> LoadTiles(int[][] tilespec, Tileset tileset)
 {
     IList<IGameObject> tiles = new List<IGameObject>(tilespec.Length * tilespec[0].Length);
     for (int i = 0; i < tilespec.Length; i++)
     {
         for (int j = 0; j < tilespec[i].Length; j++)
         {
             IGameObject tile = LoadTile(tilespec[i][j], tileset);
             if (tile != null)
             {
                 tile.Position = new Vector2(j * tileset.TileSize.X, i * tileset.TileSize.Y);
                 tiles.Add(tile);
             }
         }
     }
     return tiles;
 }