示例#1
0
    private void Awake()
    {
        if (instance_index > 0)
        {
            return;
        }

        MasterManager instance = GameObject.FindObjectOfType <MasterManager>();

        if (instance != null)
        {
            instance_index++;
        }



        QualitySettings.vSyncCount = 0;
        ManagerLoadScene           = GetComponent <LoadSceneManager>();
        ManagerGlobalData          = GetComponent <GlobalDataManager>();
        ManagerSound    = GetComponent <SoundManager>();
        ManagerInput    = GetComponent <InputManager>();
        ManagerSprite   = GetComponent <SpriteManager>();
        ManagerPopup    = GetComponent <PopupManager>();
        ManagerLocalize = GetComponent <LocalizeManager>();

        //added all manager in the manager list
        managerList.Add(ManagerLoadScene);
        managerList.Add(ManagerGlobalData);
        managerList.Add(ManagerSound);
        managerList.Add(ManagerSprite);
        managerList.Add(ManagerInput);
        managerList.Add(ManagerPopup);
        managerList.Add(ManagerLocalize);
        StartCoroutine(IE_BootAllManager());

        string path = Application.dataPath;

        //If mobileCreate a copy of the data json
        if (Application.platform == RuntimePlatform.Switch ||
            Application.platform == RuntimePlatform.Android ||
            Application.platform == RuntimePlatform.IPhonePlayer)
        {
            path = Application.persistentDataPath;
        }
        else
        {
            path = Application.dataPath;
        }

        TextAsset _jsonString = (TextAsset)Resources.Load("JSON/EnemyData", typeof(TextAsset));

        System.IO.File.WriteAllText(path + Utility.JsonFileList[Constants.JSONIndex.DATA_ENEMY], _jsonString.text);

        _jsonString = (TextAsset)Resources.Load("JSON/ItemData", typeof(TextAsset));
        System.IO.File.WriteAllText(path + Utility.JsonFileList[Constants.JSONIndex.DATA_ITEM], _jsonString.text);

        _jsonString = (TextAsset)Resources.Load("JSON/WorkData", typeof(TextAsset));
        System.IO.File.WriteAllText(path + Utility.JsonFileList[Constants.JSONIndex.DATA_WORK], _jsonString.text);

        _jsonString = (TextAsset)Resources.Load("JSON/Config", typeof(TextAsset));
        System.IO.File.WriteAllText(path + Utility.JsonFileList[Constants.JSONIndex.DATA_CONFIG], _jsonString.text);

        _jsonString = (TextAsset)Resources.Load("JSON/Credit", typeof(TextAsset));
        System.IO.File.WriteAllText(path + Utility.JsonFileList[Constants.JSONIndex.DATA_CREDIT], _jsonString.text);

        ManagerGlobalData.LoadallData();

        //keep this gameobject the entire project
        DontDestroyOnLoad(gameObject);
    }
示例#2
0
 void OnApplicationQuit()
 {
     Debug.Log("Application ending after " + Time.time.ToString("0.0") + " seconds");
     ManagerGlobalData.SaveAllData();
 }