public LocalArea(StreamReader stream, Dictionary<string, Tile> tiles) { string line; //1st line is the name Name = stream.ReadLine().ToLower(); //Read in 10 lines of 10 characters each. Look up the tile and make the //matching sprite for (int j = 0; j < MapSizeY; j++) { //Get a line of map characters line = stream.ReadLine(); for (int i = 0; i < MapSizeX; i++) { MapTile mapTile = new MapTile(); Map[i, j] = mapTile; mapTile.Tile = tiles[line[i].ToString()]; mapTile.SetSprite(i, j); } } //Read game objects until the blank line while (!stream.EndOfStream && (line = stream.ReadLine().Trim()) != "") { //Each line is an x,y coordinate and a tile shortcut //Look up the tile and construct the sprite string[] elements = line.Split(','); int x = Convert.ToInt32(elements[0]); int y = Convert.ToInt32(elements[1]); MapTile mapTile = Map[x, y]; mapTile.ObjectTile = tiles[elements[2]]; mapTile.SetObjectSprite(x, y); if (mapTile.ObjectTile.IsTransparent) { mapTile.ObjectSprite.ColorKey = Color.FromArgb(75, 75, 75); } } }
private bool checkNextTile(MapTile mapTile, int x, int y) { checkDoors(mapTile, x, y); checkIndoors(mapTile, x, y); //If the next tile is a blocker then we can't move if (mapTile.Tile.IsBlock) return false; return true; }
private void checkIndoors(MapTile mapTile, int x, int y) { if (mapTile.Tile.Category == "inside" &! _inside) { indoors(); } else if (mapTile.Tile.Category != "inside" && _inside) { outdoors(); } }
private void checkDoors(MapTile mapTile, int x, int y) { if (mapTile.Tile.Category == "door" && mapTile.Tile.IsBlock == true) { mapTile.Tile = _tiles["G"]; mapTile.SetSprite(x, y); mapTile.Tile.IsBlock = false; } }