private void AddRoom(Room newRoom) { CreateRoom (newRoom); var roomCount = rooms.Count; if (roomCount > 0) { AddTunnel (newRoom); } lastX = newRoom.GetCenterX (); lastY = newRoom.GetCenterY (); if (roomCount > 0) { tiles [lastX - 1, lastY] = Map.Treasure; bool coin = Random.Range (0.0F, 1.0F) > 0.75F; if (coin) { tiles [lastX + 1, lastY] = Map.Enemy; } else { tiles [lastX + 1, lastY] = Map.Zombie; } if (this.ExitInd == 0) { tiles [lastX + 2, lastY + 2] = Map.Exit; this.ExitInd--; } else { this.ExitInd--; } } rooms.Enqueue (newRoom); }
private void AddTunnel(Room newRoom) { var newX = newRoom.GetCenterX (); var newY = newRoom.GetCenterY (); if (pseudorandom.Next(0, 1) == 1) { // horizontal, then vertical CreateHorizontalTunnel(lastX, newX, lastY); CreateVerticalTunnel (lastY, newY, newX); } else { CreateHorizontalTunnel(lastX, newX, newY); CreateVerticalTunnel (lastY, newY, lastX); } }