public void addTile(EventType typeToTrigger, Tile tileToBeAdded) { if(!linkedTileDict.Keys.Contains(typeToTrigger)){ linkedTileDict.Add(typeToTrigger, new List<Tile>()); } linkedTileDict[typeToTrigger].Add(tileToBeAdded); }
public void parseOneselfAndAddThineSelfToThouDictionaryOfLinkedTileObjects_Cheers(Tile[,] mapOfTiles) { int numberOfLinkingTiles = (int)int.Parse(unparsedCoordinateString.Substring(0,2)); for (int i = 0; i <= numberOfLinkingTiles-1; i++) { int xCoordinate = (int)int.Parse(unparsedCoordinateString.Substring(((i * 6) + 2), 2))-1; int yCoordinate = (int)int.Parse(unparsedCoordinateString.Substring(((i * 6) + 4), 2))-1; int triggerType = (int)int.Parse(unparsedCoordinateString.Substring(((i * 6) + 6), 2)); addTile((EventType)Enum.Parse(typeof(EventType), "" + triggerType), mapOfTiles[xCoordinate, yCoordinate]); } }
public Map(Tile[,] mapTop, Tile[,] mapBottom, List<Enemy> enemies, World world) { _tileMaps = new List<Tile[,]>(); _tileMaps.Add(mapBottom); _tileMaps.Add(mapTop); _enemies = enemies; if (mapTop.GetLength(0) != mapBottom.GetLength(0) || mapBottom.GetLength(1) != mapTop.GetLength(1)) throw new Exception("Invalid map lengths."); _width = mapTop.GetLength(0) - 1; _height = mapBottom.GetLength(1) - 1; _world = world; _camera = _world.Camera; }
public TileInfo(Rectangle bounds, Tile tile) { Bounds = bounds; Tile = tile; }
public static Tile[,] loadMap(String fileLoaction, Dictionary<int, Texture2D> textureDict) { Tile[,] map = new Tile[50, 50]; using (Stream fileStream = TitleContainer.OpenStream(fileLoaction)) { using (StreamReader reader = new StreamReader(fileStream)) { for (int i = 0; i <= map.GetLength(0) - 1; i++) { String temp = reader.ReadLine(); String[] tempArray = temp.Split('|'); for (int c = 0; c <= map.GetLength(1) - 1; c++) { int tileID = int.Parse(tempArray[c].Substring(0, 2)); int imageID = int.Parse(tempArray[c].Substring(2, 2)); switch (tileID) { case 0: map[c,i] = null; break; case 1: map[c, i] = new FloorTile(TileType.Passable, tileID, textureDict[1]); map[c, i].Position = new Vector2(c*Tile.Width,i*Tile.Height); break; case 2: map[c, i] = new WallTile(TileType.NonPassable, tileID, textureDict[2]); map[c, i].Position = new Vector2(c*Tile.Width,i*Tile.Height); break; case 3: map[c, i] = new DoorTile(TileType.NonPassable, tileID, textureDict[3], textureDict[14]); map[c, i].Position = new Vector2(c*Tile.Width,i*Tile.Height); break; case 4: map[c, i] = new FloorTile(TileType.Passable, tileID, textureDict[4]); map[c, i].Position = new Vector2(c*Tile.Width,i*Tile.Height); break; case 5: map[c, i] = new FloorTile(TileType.Hole, tileID, textureDict[5]); map[c, i].Position = new Vector2(c*Tile.Width,i*Tile.Height); break; case 6: map[c, i] = new WaterTile(TileType.Passable, tileID, textureDict[6], textureDict[9], textureDict[10], false, false); map[c, i].Position = new Vector2(c*Tile.Width,i*Tile.Height); break; case 7: map[c, i] = new LavaTile(TileType.Hole, tileID, textureDict[7], textureDict[8], false); map[c, i].Position = new Vector2(c*Tile.Width,i*Tile.Height); break; case 8: map[c, i] = new LavaTile(TileType.Passable, tileID, textureDict[7], textureDict[8], true); map[c, i].Position = new Vector2(c*Tile.Width,i*Tile.Height); break; case 9: map[c, i] = new WaterTile(TileType.Passable, tileID, textureDict[6], textureDict[9], textureDict[10], false, false); map[c, i].Position = new Vector2(c*Tile.Width,i*Tile.Height); break; case 10: map[c, i] = new WaterTile(TileType.Passable, tileID, textureDict[6], textureDict[9], textureDict[10], true, false); map[c, i].Position = new Vector2(c*Tile.Width,i*Tile.Height); break; case 11: map[c, i] = new SwitchTile(TileType.NonPassable, tileID, textureDict[11], textureDict[11], SwitchType.LightningSwitch, tempArray[c].Substring(6)); map[c, i].Position = new Vector2(c*Tile.Width,i*Tile.Height); break; case 12: map[c, i] = new SwitchTile(TileType.NonPassable, tileID, textureDict[12], textureDict[12], SwitchType.FireSwitch, tempArray[c].Substring(6)); map[c, i].Position = new Vector2(c*Tile.Width,i*Tile.Height); break; case 13: map[c, i] = new SwitchTile(TileType.NonPassable, tileID, textureDict[13], textureDict[13], SwitchType.IceSwitch, tempArray[c].Substring(6)); map[c, i].Position = new Vector2(c*Tile.Width,i*Tile.Height); break; case 14: map[c, i] = new StairTile(TileType.NonPassable, tileID, textureDict[14]); map[c, i].Position = new Vector2(c*Tile.Width,i*Tile.Height); break; } } } } } return map; }