// Is called when a player changes location to load/unload the correct assets. public void LoadLocation() { if (GameModel.sceneChanged == true) { for (int i = 0; i < locations.Length; i++) { if (locations[i].name == GameModel.nextLocale.Name) { //unloads the items from the previous scene SpawnItems.UnloadGameObjects(); //sets the next locations assets to be active locations[i].gameObject.SetActive(true); //sets the current locations assets to inactive GameObject.Find(GameModel.currentLocale.Name).SetActive(false); // Failsafe to tell the game that a scene has changed GameModel.sceneChanged = false; GameModel.currentLocale = GameModel.nextLocale; GameModel.cPlayer.LocationId = GameModel.currentLocale.Name; GameModel.ds.updatePlayer(GameModel.cPlayer); PlayerSpawn(GameModel.currentPlayer); SpawnItems.LoadGameObjects(); GameModel.menuController.exitText(); break; } } } else { GameModel.sceneChanged = true; } }
public static void Logout() { SpawnItems.UnloadGameObjects(); if (finished) { ds.DropItems(); SceneManager.LoadScene(0); } }