Example #1
0
    private IEnumerator EnterGameCoroutine(ulong characterId, List <int> ret)
    {
        using (new BlockingLayerHelper(0))
        {
            var playerData = PlayerDataManager.Instance;
            playerData.Guid = characterId;
            var msg = Instance.EnterGame(characterId);
            yield return(msg.SendAndWaitUntilDone());

            Logger.Debug(msg.State.ToString());

            if (msg.State == MessageState.Reply)
            {
                if (msg.ErrorCode == (int)ErrorCodes.OK)
                {
                    Logger.Debug("EnterGame.Reply");
                    playerData.CreateSysnc(characterId);
                    playerData.ResetLoginApplyState();
                    playerData.ApplyBags();
                    playerData.ApplySkills();
                    playerData.ApplyMissions(-1);
                    playerData.ApplyFlagData();
                    playerData.ApplyExtData();
                    playerData.ApplyExtData64();
                    playerData.ApplyMails();
                    playerData.ApplyBooks();
                    playerData.ApplyQueueData();
                    // playerData.ApplytReviewState();
                    playerData.ServerId           = msg.Response.ServerId;
                    playerData.CharacterGuid      = characterId;
                    playerData.CharacterFoundTime = Extension.FromServerBinary(msg.Response.FoundTime);

                    var _friend = UIManager.Instance.GetController(UIConfig.FriendUI);
                    if (_friend != null)
                    {
                        _friend.CallFromOtherClass("ApplyAllInfo", new object[] {});
                    }

                    var chat = UIManager.Instance.GetController(UIConfig.ChatMainFrame);
                    if (chat != null)
                    {
                        chat.CallFromOtherClass("EnterGame", new object[] {});
                    }

                    var url = @"http://ip.ws.126.net/ipquery";
                    GameUtils.InvokeWebServer(url, AnalyzeIpAddress);
                    playerData.ApplyCityData();
                    playerData.ApplyTrading();
                    playerData.ApplyTeam();
                    playerData.InitTrigger();
                    playerData.ApplyActivityState();
                    playerData.ApplyAcitvityCompensate();
                    playerData.ApplyOperationActivity();
                    playerData.ApplyAnchorRoomInfo();
                    playerData.ApplyAnchorIsInRoom();
                    playerData.ApplyMount();
                    EventDispatcher.Instance.DispatchEvent(new Event_ApplyUnionWarInfo());
                    //bug统计id
                    PlatformHelper.BuglySetUserId(characterId.ToString());

                    //umeng登录
                    PlatformHelper.ProfileSignIn(characterId.ToString());
                    Game.Instance.LoginTime = Game.Instance.ServerTime;
                    playerData.tmpTime      = Game.Instance.ServerTime;

                    GameLogic.IsFristLogin = true;

                    PlayerDataManager.Instance.ReviewState = GameSetting.Instance.ReviewState;

                    // 增加长时间不上线推送
                    PlatformHelper.ClearAllLocalNotification();
                    int[] days = { 1, 2, 6 };
                    for (var i = 0; i < 3; i++)
                    {
                        var key = string.Format("OffLineDays{0}", days[i]);
                        PlatformHelper.DeleteLocalNotificationWithKey(key);
                        var _now         = Game.Instance.ServerTime;
                        var _targetTime1 = new DateTime(_now.Year, _now.Month, _now.Day, 18, 40, 0);
                        var targetTime   = _targetTime1.AddDays(days[i]);
                        var time         = (targetTime - Game.Instance.ServerTime).TotalSeconds;
                        var message      = GameUtils.GetDictionaryText(240161 + i);
                        PlatformHelper.SetLocalNotification(key, message, time);
                    }
                    //superVip 预加载
                    playerData.ApplySuperVipData(false);

                    //预加载ui资源
                    ResourceManager.Instance.LoadResourceIntoCacheAsync();
                    EventDispatcher.Instance.DispatchEvent(new UIEvent_VisibleEyeCanBeStart(true));
                }
                else
                {
                    PlayCG.Instance.Destroy();
                    //UIManager.Instance.ShowNetError(msg.ErrorCode);
                    Logger.Debug("EnterGame..................." + msg.ErrorCode);
                }
            }
            else
            {
                PlayCG.Instance.Destroy();
                //GameUtils.ShowLoginTimeOutTip();
            }

            if (ret != null)
            {
                ret.Clear();
                ret.Add((int)msg.State);
                ret.Add(msg.ErrorCode);
            }
        }
    }