Esempio n. 1
0
    public IEnumerator Init()
    {
        DontDestroyOnLoad(gameObject);

        canvas      = UIUtil.FindChild <Canvas>(transform, "UI");
        camera_fade = UIUtil.FindChild <Image>(canvas.transform, "CameraFade");

        ui_setting = UIUtil.FindChild <UISetting>(canvas.transform, "UISetting");
        ui_textbox = UIUtil.FindChild <UITextBox>(canvas.transform, "UITextBox");
        ui_npc     = UIUtil.FindChild <UINpc>(canvas.transform, "UINpc");
        ui_ticker  = UIUtil.FindChild <UITicker>(canvas.transform, "UITicker");
        camera_fade.gameObject.SetActive(true);
        camera_fade.color = Color.black;

        advertisement = GetComponent <Advertisement>();
        if (null == advertisement)
        {
            throw new MissingComponentException("Advertisement");
        }

        ui_textbox.Init();

        if (Application.platform != RuntimePlatform.Android)
        {
            Database.Connect(Database.Type.MetaData, Application.streamingAssetsPath + "/meta_data.db");
        }
        else
        {
            string dbName       = "meta_data.db";
            string sourceDBPath = Path.Combine(Application.streamingAssetsPath, dbName);
            string targetDBPath = Path.Combine(Application.persistentDataPath, dbName);

            Debug.Log("src:" + sourceDBPath + "(modify:" + File.GetLastWriteTime(sourceDBPath) + "), target:" + targetDBPath + ")" + "(modify:" + File.GetLastWriteTime(targetDBPath) + ")");
            if (false == File.Exists(targetDBPath) || File.GetLastWriteTime(sourceDBPath) != File.GetLastWriteTime(targetDBPath))
            {
                UnityWebRequest request = new UnityWebRequest(Application.streamingAssetsPath + "/" + dbName);
                request.downloadHandler = new DownloadHandlerBuffer();
                yield return(request.SendWebRequest());

                File.WriteAllBytes(targetDBPath, request.downloadHandler.data);
                Debug.Log("new version meta file(target path:" + targetDBPath + ")");
            }

            Database.Connect(Database.Type.MetaData, targetDBPath);
        }
        Database.Connect(Database.Type.UserData, Application.persistentDataPath + "/user_data.db");
        Stat.Manager.Instance.Init();
        ResourceManager.Instance.Init();
        AchieveManager.Instance.Init();
        SkillManager.Instance.Init();
        ItemManager.Instance.Init();
        MonsterManager.Instance.Init();
        AudioManager.Instance.Init();

        player = new Player();
        player.meta.Init();

        ui_setting.gameObject.SetActive(true);
        ui_setting.Init();
        ui_setting.gameObject.SetActive(false);
        ui_npc.Init();
    }