Exemple #1
0
    public void OnEnter()
    {
        LancherPrefs.SetString(LancherPrefsConst.AssemblyName, Assembly.GetExecutingAssembly().FullName);

#if NO_CODE
        //在没有代码的情况下 需要IOS和其他平台分开处理
        dllNameArray = LancherPathConst.DLLPath;
#else
        context.loadingDLLProgress.progress = 1;

        //在有代码的情况下直接添加入口类即可
        var entry = context.gameObject.GetComponent <Main>();

        if (entry == null)
        {
            entry = context.gameObject.AddComponent <Main>();
        }

        //entry.OnGameStart(context.serverInfo.resServerUrl, context.serverInfo.loginServerUrl, context.serverInfo.opChannel);

        entry.OnInit();
#endif
        if (dllNameArray != null && dllNameArray.Length > 0)
        {
            LoadDLL();
        }
        else
        {
        }
    }
    /// <summary>
    /// 判断是否是new的逻辑
    /// </summary>
    private void ReadGameFile()
    {
        if (LancherPrefs.HasKey(LancherPrefsConst.NoticePrefs) == false)
        {
            return;
        }
        string gamefile = LancherPrefs.GetString(LancherPrefsConst.NoticePrefs);

        string[] gamefiles = gamefile.Split('_');
        if (passedNotice == null)
        {
            passedNotice = new List <string>();
        }
        passedNotice.AddRange(gamefiles);
    }
    /// <summary>
    /// 在退出的时候保存一些信息
    /// </summary>
    private void SaveWhenDestory()
    {
        int count = passedNotice.Count;
        var sb    = new StringBuilder();

        if (count > 0)
        {
            sb.Append(passedNotice[0]);
        }
        for (int i = 1; i < count; i++)
        {
            sb.Append("_");
            sb.Append(passedNotice[i]);
        }
        LancherPrefs.SetString(LancherPrefsConst.NoticePrefs, sb.ToString());
        LancherPrefs.Save();
    }
    /// <summary>
    /// 加载服务器Json后
    /// </summary>
    /// <param name="_www"></param>
    /// <returns></returns>
    private Promise <LancherLoadData> LoadServerJson(LancherLoadData _www)
    {
        var promise = new Promise <LancherLoadData>();

        context.serverInfo = JsonUtility.FromJson <TgameSvrInfo>(LancherEncodingUtils.GetString(_www.bytes));

        if (context.serverInfo != null)
        {
            //成功获取到服务器的信息
            LancherPrefs.SetInt(LancherPrefsConst.Need_Code, context.serverInfo.needCode ? 1 : 0);

            LancherPrefs.SetString(LancherPrefsConst.Channel, context.serverInfo.opChannel);

            promise.Resolve(_www);

            CompareGameVersion();
        }
        else
        {
            promise.Reject(new Exception(LancherConstTable.ParseServerFileError));
        }

        return(promise);
    }