/// <summary> /// Put Pit, Gold, Wumpus in the current room /// </summary> /// <param name="room">current room</param> /// <param name="row">room row</param> /// <param name="col">room col</param> private void FillRoomContent(Room room, int row, int col) { // get the type Room.Type type = (Room.Type)cave[row, col]; // put stuff in switch (type) { // pit case Room.Type.Pit: MakePit(room); break; // gold case Room.Type.Gold: MakeGold(room); break; // wumpus case Room.Type.Wumpus: MakeWumpus(room); break; // safe, leave it there } }
private GameObject FindRoomPrefab(Vector2Int index, Room.Type type) { List <GameObject> potentialRooms = new List <GameObject>(); foreach (GameObject roomPrefab in roomPrefabs) { Room room = roomPrefab.GetComponent <Room>(); if (room.type == type) { NeighboursDescriptor neighbours = GetNeighbours(index); if (((neighbours.up == true && room.up != Room.CanHaveNeighbour.No) || (neighbours.up == false && room.up != Room.CanHaveNeighbour.Yes)) && ((neighbours.right == true && room.right != Room.CanHaveNeighbour.No) || (neighbours.right == false && room.right != Room.CanHaveNeighbour.Yes)) && ((neighbours.down == true && room.down != Room.CanHaveNeighbour.No) || (neighbours.down == false && room.down != Room.CanHaveNeighbour.Yes)) && ((neighbours.left == true && room.left != Room.CanHaveNeighbour.No) || (neighbours.left == false && room.left != Room.CanHaveNeighbour.Yes))) { potentialRooms.Add(roomPrefab); } } } if (potentialRooms.Count == 0) { Debug.LogError("Can't find suitable room!"); return(null); } return(potentialRooms[Random.Range(0, potentialRooms.Count)]); }
public List <Room> GetRoomsOfType(Room.Type type) { switch (type) { case Room.Type.Cabin: return(cabins); case Room.Type.Bathhouse: return(bathhouses); } return(null); }
/// <summary> /// Used to debug /// Print out the cave dataset /// </summary> private void PrintCave() { string message = ""; for (int row = caveStats.boardSize - 1; row >= 0; row--) { for (int col = 0; col < caveStats.boardSize; col++) { Room.Type type = (Room.Type)cave[row, col]; message += "[" + type.ToString() + "]"; } print(message); message = ""; } }
/// <summary> /// Get influence of a particular room /// </summary> /// <param name="row">row</param> /// <param name="col">col</param> /// <returns>string like: null, "Stench", "Glitter", "Breeze"</returns> private void GetRoomInfluence(int row, int col, string[] result) { // check valid if (!isValidLocation(row, col)) { return; } // get room if (cave == null) { Debug.Log("Cave dataset is NULL"); return; } Room.Type roomType = (Room.Type)cave[row, col]; int index; // safe if (roomType == Room.Type.Safe) { return; } // pit if (roomType == Room.Type.Pit) { index = (int)PlayerController.Percept.Breeze; result[index] = "Breeze"; } // gold if (roomType == Room.Type.Gold) { index = (int)PlayerController.Percept.Glitter; result[index] = "Glitter"; } // wumpus if (roomType == Room.Type.Wumpus) { index = (int)PlayerController.Percept.Stench; result[index] = "Stench"; } // bump, scream will be implemented in other functions }
private void ChangeRoomType(int gridX, int gridY, Room.Type roomType) { castleMap[gridX, gridY].roomType = roomType; }
private void InitializeRoom(int gridX, int gridY, Room.Type roomType) { castleMap[gridX, gridY] = new GameObject().AddComponent <Room>(); castleMap[gridX, gridY].roomPalette = roomArchetype.roomPalette; castleMap[gridX, gridY].roomType = roomType; }