コード例 #1
0
    private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        if (scene.name == "Level")
        {
            levelData = GameObject.Find("Level Control").GetComponent <LevelData>();
        }
        else if (scene.name == "Level Selector")
        {
            statsPanel      = GameObject.Find("Stats Panel");
            reputationPanel = GameObject.Find("Reputation Panel");

            updateStatsPanel();
            updateReputationPanel();

            if (won)
            {
                completedCities.Add(currentCityName);
            }

            //necessary because cities are deleted when scene is exited and so don't remember their state
            foreach (string cityName in completedCities)
            {
                LevelSelectorCity completedCity = getCity(cityName);
                completedCity.setState(LevelSelectorCity.State.Completed);
            }
        }
    }
コード例 #2
0
 //returns city of given name. necessary because city reference gets wiped when going to level scene
 private LevelSelectorCity getCity(string name)
 {
     if (SceneManager.GetActiveScene().name == "Level Selector")
     {
         Transform citiesParent = GameObject.Find("Cities").transform;
         for (int i = 0; i < citiesParent.childCount; i++)
         {
             LevelSelectorCity city = citiesParent.GetChild(i).GetComponent <LevelSelectorCity>();
             if (city.cityName == name)
             {
                 return(city);
             }
         }
     }
     return(null);
 }
コード例 #3
0
 public void setCity(LevelSelectorCity city)
 {
     this.city       = city;
     currentCityName = city.cityName;
     won             = false;
 }