// ---------------------------------------------------------------- // Start // ---------------------------------------------------------------- public void Initialize(Room _myRoom, RoomDoorData data) { base.InitializeAsProp(_myRoom, data); myID = data.myID; worldToIndex = data.worldToIndex; roomToKey = data.roomToKey; doorToID = data.doorToID; timeWhenBorn = Time.time; }
// ---------------------------------------------------------------- // Serializing // ---------------------------------------------------------------- override public PropData ToData() { RoomDoorData data = new RoomDoorData { pos = PosLocal, myID = myID, worldToIndex = worldToIndex, roomToKey = roomToKey, doorToID = doorToID, travelMind = new TravelMindData(travelMind), }; return(data); }
// Debug public void Debug_PrintIncompleteRoomLinks() { // Loop through every RoomDoor in every Room, and make sure it has a matching RoomDoor in another Room! int numIncompleteLinks = 0; string str = ""; foreach (RoomData roomFrom in roomDatas.Values) { foreach (RoomDoorData doorFrom in roomFrom.roomDoorDatas) { int worldToIndex = doorFrom.worldToIndex; if (worldToIndex == -1) { worldToIndex = WorldIndex; } // Haven't defined worldToIndex? Stay in my world. WorldData worldTo = GameManagers.Instance.DataManager.GetWorldData(worldToIndex); RoomData roomTo = worldTo.GetRoomData(doorFrom.roomToKey); if (roomTo == null) { numIncompleteLinks++; str += "\n No RoomTo: " + roomFrom.RoomKey + " to room " + doorFrom.roomToKey; continue; } RoomDoorData doorTo = roomTo.GetRoomDoor(doorFrom.doorToID); if (doorTo == null) { numIncompleteLinks++; str += "\n No DoorTo: " + roomFrom.RoomKey + " to door " + doorFrom.roomToKey; continue; } // Ok, the room AND door exist! Now check that they match up. if (doorTo.roomToKey != roomFrom.RoomKey) { numIncompleteLinks++; str += "\n Door room mismatch: " + roomFrom.RoomKey + " to room " + roomTo.RoomKey; continue; } if (doorTo.myID != doorFrom.doorToID) { numIncompleteLinks++; str += "\n Door door mismatch: " + roomFrom.RoomKey + " to room " + roomTo.RoomKey; continue; } } } if (numIncompleteLinks > 0) { Debug.Log("W" + WorldIndex + ": " + numIncompleteLinks + " Incomplete Room Links..." + str + "\n\n"); } }
public Vector2 GetRoomDoorPos(string doorID, bool doPrintWarning = true) { RoomDoorData rdd = GetRoomDoor(doorID); if (rdd != null) { return(rdd.pos); } // Oops, no door with this ID. if (doPrintWarning) { Debug.LogWarning("Oops, GetRoomDoorPos! No RoomDoor with doorID. Room: W" + WorldIndex + " " + RoomKey + ", doorID: " + doorID); } return(DefaultPlayerStartPos()); }