//------------------------------------------------------------------- // This creates the door game object at the correct location and orientation. // roomGen: the roomgenerator that the door is part of // position: the position to spawn the door // quat: the rotation to spawn the door // ori: this determines which direction the door needs to teleport the player // index: the index of the room // offset: the offset to find the index of the room the door leads to //------------------------------------------------------------------- void Drawdoor(RoomGenerator roomGen, Vector3 position, Quaternion quat, Door.Orientation ori, int index, int offset) { GameObject door; int i = 1; bool success = false; // We start i at 1 because, we do NOT want to put the first key behind a locked door. for (; i < m_finalRooms.Count; ++i) { if (index + offset == m_finalRooms[i]) { success = true; break; } } if (success) { door = Instantiate(m_lockedDoor, position, quat, m_map[index].transform); door.GetComponent <Door>().type = (Door.Type)i; } else { door = Instantiate(m_door, position, quat, m_map[index].transform); } Door doorComp = door.GetComponent <Door>(); doorComp.orientation = ori; Debug.Assert(m_map.ContainsKey(roomGen.GetIndex())); doorComp.curRoom = m_map[roomGen.GetIndex()].GetComponent <SpriteRenderer>(); Debug.Assert(m_map.ContainsKey(roomGen.GetIndex() + offset), offset); doorComp.nextRoom = m_map[roomGen.GetIndex() + offset].GetComponent <SpriteRenderer>(); }
public DoorPlacement(Direction dir, Quaternion quat, Door.Orientation ori, int offset) { m_dir = dir; m_quat = quat; m_ori = ori; m_offset = offset; }