public void init() { bool c = false; bool o = true; MazeRoom no_room = new MazeRoom(); no_room.TileNum = 0; RoomDirections.Add(no_room); MazeRoom SealedRoom = new MazeRoom(); SealedRoom.TileNum = 1; RoomDirections.Add(SealedRoom); MazeRoom FourWay = new MazeRoom(); FourWay.SetAllExits(o, o, o, o); FourWay.TileNum = 2; MazeRoom VerticalHall = new MazeRoom(); VerticalHall.SetAllExits(o, c, o, c); VerticalHall.TileNum = 3; RoomDirections.Add(VerticalHall); MazeRoom HorizontalHall = new MazeRoom(); HorizontalHall.TileNum = 4; HorizontalHall.SetAllExits(c, o, c, o); MazeRoom SealedWest = new MazeRoom(); SealedWest.SetAllExits(o, o, o, c); SealedWest.TileNum = 5; RoomDirections.Add(SealedWest); MazeRoom SealedEast = new MazeRoom(); SealedEast.SetAllExits(o, c, o, o); SealedEast.TileNum = 6; RoomDirections.Add(SealedEast); MazeRoom SealedNorth = new MazeRoom(); SealedNorth.SetAllExits(c, o, o, o); SealedNorth.TileNum = 7; RoomDirections.Add(SealedNorth); MazeRoom SealedSouth = new MazeRoom(); SealedSouth.SetAllExits(o, o, c, o); SealedSouth.TileNum = 8; RoomDirections.Add(SealedSouth); MazeRoom SouthExit = new MazeRoom(); SouthExit.SetAllExits(c, c, o, c); SouthExit.TileNum = 9; RoomDirections.Add(SouthExit); MazeRoom NorthExit = new MazeRoom(); NorthExit.SetAllExits(o, c, c, c); NorthExit.TileNum = 10; MazeRoom WestExit = new MazeRoom(); WestExit.SetAllExits(c, c, c, o); WestExit.TileNum = 11; RoomDirections.Add(WestExit); MazeRoom EastExit = new MazeRoom(); EastExit.SetAllExits(c, o, c, c); EastExit.TileNum = 12; RoomDirections.Add(EastExit); }
public void RevealRoomTile(int x, int y, List <TileGraphic> tileset) { //Console.WriteLine("An item exists here"); //Now we need to extract some data to process it MazeRoom temproom = mazemap.GetRoom(new Vector2 <int, int>(x, y)); //roompair.Value; Vector2 <int, int> Location = new Vector2 <int, int>(x, y); int RoomX = Location.X; int RoomY = Location.Y; //Console.WriteLine("Room X is " + RoomX + " | Room Y is " + RoomY); //It is time to check neighboors by using containskey. //This method using containskey seems to not even work. Will test later. //Todo -> Re test room neighboor checking using containskey, for now the function //getroomkeystate of mazemap object will do. Vector2 <int, int> North = new Vector2 <int, int>(RoomX, RoomY - 1); Vector2 <int, int> East = new Vector2 <int, int>(RoomX + 1, RoomY); Vector2 <int, int> South = new Vector2 <int, int>(RoomX, RoomY + 1); Vector2 <int, int> West = new Vector2 <int, int>(RoomX - 1, RoomY); //Todo //Remove stuff like TempExit references they are unused. //We also need an instance of the struct which the class MazeRoom Provides MazeRoom.ExitData TempExitData = new MazeRoom.ExitData(); //Okay now after this we can use contains key and set the data for each direction as well. if (mazemap.rooms.ContainsKey(North)) { TempExitData.NorthExit = true; } if (mazemap.rooms.ContainsKey(East)) { TempExitData.EastExit = true; } if (mazemap.rooms.ContainsKey(South)) { TempExitData.SouthExit = true; } if (mazemap.rooms.ContainsKey(West)) { TempExitData.WestExit = true; } temproom.LocalExits = TempExitData; //TempExitData isn't used string TileControlName = RoomX + "," + RoomY; Vector2 <int, int> RoomPos = new Vector2 <int, int>(RoomX, RoomY); PictureBox Tile = new PictureBox(); Control TileCtn = this.Controls[TileControlName]; Tile = (PictureBox)TileCtn; //A fix to see if 4 ways can work. if (Tile != null) { Tile.Image = tileset[1].localtile; //Save the value int neighboor_count = mazemap.CountNeighboors(RoomX, RoomY); if (neighboor_count == 4) { Tile.Image = tileset[2].localtile; } //We need to know exact states bool NorthNeighboor = mazemap.getroomkeystate(RoomX, RoomY - 1); bool SouthNeighboor = mazemap.getroomkeystate(RoomX, RoomY + 1); bool EastNeighboor = mazemap.getroomkeystate(RoomX + 1, RoomY); bool WestNeighboor = mazemap.getroomkeystate(RoomX - 1, RoomY); //use these instead for exit metadata later. =p temproom.SetAllExits(NorthNeighboor, EastNeighboor, WestNeighboor, SouthNeighboor); /* * Corner Tile Numbers * NorthEast 13 * SouthEast 14 * NorthWest 15 * SouthWest 16 */ //solving hallways first if (neighboor_count == 2) { if (NorthNeighboor && SouthNeighboor) { Tile.Image = tileset[3].localtile; } if (EastNeighboor && WestNeighboor) { Tile.Image = tileset[4].localtile; } //Dealing with corner tiles below. //NorthEast Neighboor Case if (NorthNeighboor && EastNeighboor) { Tile.Image = tileset[13].localtile; } //SouthEast Neighboor Case if (SouthNeighboor && EastNeighboor) { Tile.Image = tileset[14].localtile; } //NorthWest Neighboor Case if (NorthNeighboor && WestNeighboor) { Tile.Image = tileset[15].localtile; } //SouthWest Neighboor Case if (SouthNeighboor & WestNeighboor) { Tile.Image = tileset[16].localtile; } } //Solving one way exits/entrances if (neighboor_count == 1) { if (NorthNeighboor) { Tile.Image = tileset[10].localtile; } if (SouthNeighboor) { Tile.Image = tileset[9].localtile; } if (EastNeighboor) { Tile.Image = tileset[12].localtile; } if (WestNeighboor) { Tile.Image = tileset[11].localtile; } } //Now the hardest one. Three ways. if (neighboor_count == 3) { if (!SouthNeighboor) { Tile.Image = tileset[8].localtile; //Console.WriteLine("South Sealed at " + RoomX + "," + RoomY); } if (!NorthNeighboor) { Tile.Image = tileset[7].localtile; //Console.WriteLine("North Sealed at " + RoomX + "," + RoomY); } if (!EastNeighboor) { Tile.Image = tileset[6].localtile; //Console.WriteLine("East Sealed at " + RoomX + "," + RoomY); } if (!WestNeighboor) { if (NorthNeighboor && SouthNeighboor && EastNeighboor) { //Attempting to eliminate a bug Tile.Image = tileset[5].localtile; } } } } }