コード例 #1
0
ファイル: Services.cs プロジェクト: zx0688/SwipeAdventure
        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();
        }
コード例 #2
0
ファイル: WechatAPIService.cs プロジェクト: wenrenwang/WeChat
        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
            });
        }