Ejemplo n.º 1
0
    void Awake()
    {
        Debug.Log("RUNNING AWAKE FUNCTION OF GLOBALOBJECT.CS");
        if (GlobalObject.instance == null)
        {
            GlobalObject.instance = this;
            DontDestroyOnLoad(this.gameObject);
            //Register for OnSceneLoaded event
            SceneManager.sceneLoaded += this.OnSceneLoaded;
        }
        else if (instance != this)
        {
            Debug.LogError("DUPLICATE GLOBAL OBJECT FOUND! DELETING THIS ONE");
            Destroy(this.gameObject);
        }

        //Build list of commander scripts from prefabs
        foreach (GameObject commanderPrefab in this.commanderList)
        {
            Commander commander = commanderPrefab.GetComponent <Commander>();
            this.loadedCommanders.Add(commander);
        }

        //Build list of all cards for use with card selection manager or wherever else it is needed
        this.CreateCardEntryList();

        //Do something based on loaded scene
        if (SceneManager.GetActiveScene().name != "BossSelect" &&
            SceneManager.GetActiveScene().name != "Game" &&
            SceneManager.GetActiveScene().name != "GameCommanders" &&
            SceneManager.GetActiveScene().name != "CommanderSelect" &&
            SceneManager.GetActiveScene().name != "Map" &&
            SceneManager.GetActiveScene().buildIndex != GameConstants.SCENE_INDEX_POST_BATTLE_CARD_SELECT)
        {
            Debug.LogWarning("WARNING! Scene Manger is Loading a non specified scene which it assumes is the card select!!!");
        }

        //Build the strings dictionary
        ReadWriteCSV.CsvFileReader fileReader = new ReadWriteCSV.CsvFileReader("Assets/Resources/Localization/localization-en.csv");
        List <string> stringList = fileReader.BuildStringsList();

        for (int i = 0; i < stringList.Count; i++)
        {
            if (i % 2 == 0)
            {
                stringDictionary.Add(stringList[i], stringList[i + 1]);
            }
        }
    }