コード例 #1
0
    void OnConnect(C2G.Connect packet, C2G.ConnectAck ack)
    {
        Debug.Log("OnConnect : ");
        DailyIndex     = ack.daily_index;
        WeeklyIndex    = ack.weekly_index;
        ServerTimeSpan = ack.server_time - DateTime.Now;

        GameConfig.Instance.Init(ack.config_values);
        EventHottimeManager.Instance.Init(ack.events);

        if (ack.info_files != null)
        {
            SHSavedData.Instance.SaveGameInfo(ack.info_files, ack.info_version);
        }
        SHSavedData.Instance.LoadData();

        PlayerInfo = new ClientPlayerData(ack.player_info);

        GuildManager.Instance.SetGuildInfo(ack.guild);
#if !FINAL_BUILD
        CheatCommandHandlers.Uninitialize();
        if (PlayerInfo.can_cheat == true)
        {
            CheatCommandHandlers.Initialize();
        }
#endif

        QuestManager.Instance.Init(ack.player_info.quests);

        if (ack.detail_data != null)
        {
            SaveDataManger.Instance.InitFromData(ack.detail_data);
        }
        else
        {
            if (SaveDataManger.Instance.InitFromFile() == false)
            {
                C2G.Connect _Connect = new C2G.Connect();
                _Connect.request_info = true;
                _Connect.request_data = true;
                game_server.JsonAsync <C2G.Connect, C2G.ConnectAck>(_Connect, OnConnect);
                return;
            }
        }

        switch (ack.player_info.unread_mail)
        {
        case pe_UnreadMailState.MainMenuOpen:
            SetUnreadMail(pe_UnreadMailState.MainMenuOpen);
            break;

        case pe_UnreadMailState.UnreadMail:
            SetUnreadMail(pe_UnreadMailState.UnreadMail);
            break;
        }

        if (string.IsNullOrEmpty(PlayerInfo.nickname) == true)
        {
            Popup.Instance.Show(ePopupMode.Nickname, false, new EventDelegate.Callback(OnNicknameSetCallback));
        }
        else
        {
            ConnectState = eConnectState.connected;

            ChattingMain.Instance.Init();
        }
    }
コード例 #2
0
    void OnLoginAuto(C2L.LoginAuto packet, C2L.LoginAutoAck ack)
    {
        if (ack.result == C2L.eLoginResult.SessionExpired)
        {
            SHSavedData.AccountIdx = -1;
            if (SHSavedData.LoginPlatform == LoginPlatform.Facebook && Facebook.Unity.FB.IsLoggedIn)
            {
                Facebook.Unity.FB.LogOut();
            }
            if (SHSavedData.LoginPlatform == LoginPlatform.GooglePlay && UM_GameServiceManager.Instance.IsConnected)
            {
                UM_GameServiceManager.Instance.Disconnect();
            }
            SHSavedData.LoginPlatform = PacketEnums.LoginPlatform.Invalid;
            ConnectState = eConnectState.idle;
            return;
        }

        if (ack.result != C2L.eLoginResult.Successed)
        {
            if (ack.result == C2L.eLoginResult.NeedAgree)
            {
                Popup.Instance.Show(ePopupMode.Policy, new System.Action(ProcessLoginAuto));
                return;
            }
            //Debug.LogError(ack.result);

            ConnectState = eConnectState.idle;

            if (Localization.Exists("LoginResult_" + ack.result) == true)
            {
                Popup.Instance.ShowMessageKey("LoginResult_" + ack.result);
            }
            else
            {
                Popup.Instance.ShowMessage(ack.result.ToString());
            }

            return;
        }

        ConnectState = eConnectState.connecting;

        SHSavedData.AccessToken = ack.access_token;
        //         if (ack.request_info == false)
        //             SHSavedData.Instance.LoadData(true);
        //         if (ack.request_data == false)
        //             SaveDataManger.Instance.InitFromFile();

        game_server.InitPacketNamespace("C2G");
        game_server.InitSession(SHSavedData.AccountIdx, ack.access_token, ack.reconnect_index);

        if (ExceptionHandler.Instance != null)
        {
            ExceptionHandler.Instance.SendLastReport();
        }

        ack.request_data = true;
        ack.request_info = true;

        C2G.Connect _Connect = new C2G.Connect();
        _Connect.request_info = ack.request_info;
        _Connect.request_data = ack.request_data;
        game_server.JsonAsync <C2G.Connect, C2G.ConnectAck>(_Connect, OnConnect);
    }