Exemplo n.º 1
0
 // 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;
     }
 }
Exemplo n.º 2
0
 public void StartLocation()
 {
     parentLocation = GameObject.Find("Locations");
     parentLocation.GetComponentsInChildren <Transform>(true);
     locations = parentLocation.GetComponentsInChildren <Transform>(true);
     GameModel.currentPlayer = GameObject.Find("Player");
     // Loops through the locations transform array
     for (int i = 0; i < locations.Length; i++)
     {
         //trys to find a game object that matches the locations name
         if (locations[i].name == GameModel.currentLocale.Name)
         {
             //When successful it sets this locations assets to active
             locations[i].gameObject.SetActive(true);
         }
     }
     SpawnItems.LoadGameObjects();
 }