Beispiel #1
0
        public async UniTaskVoid Init()
        {
            DontDestroyOnLoad(this);
            GameTime.Init(DateTime.Now.Second);

            // UpdateTextUI ("Loading assets...");
            await assets.Init(Progress.Create <float> (x => UpdateProgressUI(x)));

            // UpdateTextUI ("Loading network...");
            await network.Init(Progress.Create <float> (x => UpdateProgressUI(x)));

            // UpdateTextUI ("Loading game data...");
            await data.Init(Progress.Create <float> (x => UpdateProgressUI(x)));

            // UpdateTextUI ("Loading profile...");
            await player.Init(Progress.Create <float> (x => UpdateProgressUI(x)));

            await enemy.Init(Progress.Create <float> (x => UpdateProgressUI(x)));

            //UpdateTextUI ("Loading scene...");

            Scene s = SceneManager.GetActiveScene();

            if (s.name != "Main")
            {
                await SceneManager.LoadSceneAsync("Main").ToUniTask(Progress.Create <float> (x => UpdateProgressUI(x)));
            }

            //await UniTask.DelayFrame (2);
            //UpdateProgressUI (1);

            state = MState.INITED;
            OnInited?.Invoke();
        }
Beispiel #2
0
        private void HandleInit()
        {
            List <Contact> list       = new List <Contact>();
            var            initResult = client.Init(mPass_ticket, mBaseReq);

            if (initResult != null && initResult.BaseResponse.ret == 0)
            {
                Self = CreateContact(initResult.User);
                OnGetUser?.Invoke(this, new GetUserEvent()
                {
                    Self = Self
                });
                foreach (var item in initResult.ContactList)
                {
                    list.Add(CreateContact(item));
                }

                mSyncKey = initResult.SyncKey;
                // 开启系统通知
                var statusNotifyRep = client.Statusnotify(Self.ID, Self.ID, mPass_ticket, mBaseReq);
                if (statusNotifyRep != null && statusNotifyRep.BaseResponse != null && statusNotifyRep.BaseResponse.ret == 0)
                {
                    CurrentStatus = ClientStatusType.WeixinSync;
                    IsLogin       = true;
                }
                else
                {
                    LogHandler.i("WechatAPIService", "HandleInit()", statusNotifyRep);
                    CurrentStatus = ClientStatusType.GetUUID;
                    return;
                }
            }
            else
            {
                LogHandler.i("WechatAPIService", "HandleInit()", initResult);
                CurrentStatus = ClientStatusType.GetUUID;
                return;
            }

            if (!InitContactAndGroups())
            {
                CurrentStatus = ClientStatusType.WeixinInit;
                IsLogin       = false;
                return;
            }


            OnInited?.Invoke(this, new InitedEvent()
            {
                LastContact = list
            });
        }