public override void OnInspectorGUI() { base.DrawDefaultInspector(); RoomLoader loader = (RoomLoader)target; if (GUILayout.Button("Unserialize")) { Undo.RecordObject(loader, "Unserialize Room"); loader.Unserialize(loader.currentRoom); } if (GUILayout.Button("Serialize")) { EditorUtility.SetDirty(loader.currentRoom); Undo.RecordObject(loader.currentRoom, "Serialize Room"); loader.Serialize(); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } }
public void Change_Room(Vector2 new_pos, Direcao dir) { if (!player.can_change_rooms) { return; } else { StartCoroutine(player.Cooldown_Change_Rooms()); } RoomData next_room = null; Vector3 offset = Vector2.zero; switch (dir) { case Direcao.UP: next_room = roomLoader.currentRoom.roomUp; new_pos = new Vector2(new_pos.x, -new_pos.y); offset = Vector2.down; break; case Direcao.RIGHT: next_room = roomLoader.currentRoom.roomToTheRight; new_pos = new Vector2(-new_pos.x, new_pos.y); offset = Vector2.left; break; case Direcao.LEFT: next_room = roomLoader.currentRoom.roomToTheLeft; new_pos = new Vector2(-new_pos.x, new_pos.y); offset = Vector2.left; break; case Direcao.DOWN: next_room = roomLoader.currentRoom.roomDown; new_pos = new Vector2(new_pos.x, -new_pos.y); offset = Vector2.down; break; } if (next_room == null) { // Debug.Log("Trying to access room " + dir + " but none found."); return; } if (!cleared_rooms.Contains(next_room.name)) { enemyLoader.Spawn(next_room.levelEnemyData); } roomLoader.Unserialize(next_room); roomLoader.currentRoom = next_room; Update_Player_New_Room(offset); foreach (GameObject go in GameObject.FindGameObjectsWithTag("RoomAlteration")) { Destroy(go); } foreach (GameObject go in GameObject.FindGameObjectsWithTag("Arrow")) { StartCoroutine(go.GetComponentInChildren <Projectile>().Destroy()); } foreach (GameObject go in GameObject.FindGameObjectsWithTag("Trap")) { Destroy(go); } Enemy.Reset_Frozen(); // Load_Room_Alterations(next_room.id); }