示例#1
0
            // 点击开始,进入游戏
            public void OnEnterGame()
            {
                if (mSelectIndex < 0)
                {
                    ui.UIWidgetHelp.GetInstance().ShowNoticeDlg(xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_90"));
                    return;
                }

                // 保存本地玩家ID
                UnitID uid = new UnitID();

                uid.type    = (byte)EUnitType.UNITTYPE_PLAYER;
                uid.obj_idx = (uint)mData [mSelectIndex].uuid;

                Game.GetInstance().LocalPlayerID     = uid;
                Game.GetInstance().LocalPlayerTypeID = ActorHelper.RoleIdToTypeId(mData [mSelectIndex].rid);
                Game.GetInstance().LocalPlayerName   = System.Text.Encoding.UTF8.GetString(mData [mSelectIndex].name);

                // 保存选择的角色索引
                GlobalSettings.GetInstance().LastActorIndex = mSelectIndex;
                GlobalSettings.GetInstance().Save();

                // Enter Game
                C2SEnterGame c2sEnterGame = new C2SEnterGame();

                c2sEnterGame.uuid = mData[mSelectIndex].uuid;
                NetClient.GetBaseClient().SendData <C2SEnterGame>(NetMsg.MSG_ENTER_GAME, c2sEnterGame);

                GlobalConfig.GetInstance().LoginInfo.Name = System.Text.Encoding.UTF8.GetString(mData[mSelectIndex].name);
                GlobalConfig.GetInstance().LoginInfo.RId = mData [mSelectIndex].uuid.ToString();
                GlobalConfig.GetInstance().LoginInfo.Job = mData [mSelectIndex].rid.ToString();
                GlobalConfig.GetInstance().LoginInfo.Level = mData[mSelectIndex].level.ToString();
                ControlServerLogHelper.GetInstance().PostRoleInfo();

                // 注册FCM
                DBOSManager.getOSBridge().registerFCM();

                DBOSManager.getOSBridge().registerPush();

                // 为确保进入场景的角色等级判断正确,这里要赋值给LocalPlayerManager
                LocalPlayerManager.Instance.LocalActorAttribute.Level = mData[mSelectIndex].level;

                Game.Instance.IsCreateRoleEnter = false;

                xc.ui.ugui.UIManager.Instance.ShowWaitScreen(true);

                // 点击选角按钮
                ControlServerLogHelper.Instance.PostPlayerFollowRecord(PlayerFollowRecordSceneId.ClickSelectActorButton);
                ControlServerLogHelper.Instance.PostCloudLadderEventAction(CloudLadderMarkEnum.select_role);
            }
示例#2
0
            /// <summary>
            /// 响应注册的网络消息
            /// </summary>
            /// <param name="protocol"></param>
            /// <param name="data"></param>
            void HandleCreateRole(ushort protocol, byte[] data)
            {
                if (protocol != NetMsg.MSG_CREATE_ROLE)
                {
                    return;
                }

                var create_role = S2CPackBase.DeserializePack <S2CCreateRole>(data);

                if (create_role.result != 1) // 创建不成功
                {
                    string content = "";

                    DBErrorCode           db_error_code = (DBErrorCode)DBManager.GetInstance().GetDB(typeof(DBErrorCode).Name);
                    DBErrorCode.ErrorInfo errorInfo     = db_error_code.GetErrorInfo(create_role.result);
                    if (errorInfo == null)
                    {
                        content = xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_35");
                    }
                    else
                    {
                        content = errorInfo.mDesc;
                    }

                    GameDebug.LogError(string.Format("服务端报错: {0}", content));
                    UINotice.GetInstance().ShowMessage(content);

                    UIManager.Instance.ShowWaitScreen(false);
                    return;
                }

                // 保存本地玩家ID
                UnitID uid = new UnitID();

                uid.type    = (byte)EUnitType.UNITTYPE_PLAYER;
                uid.obj_idx = (uint)create_role.uuid;
                Game.GetInstance().LocalPlayerID     = uid;
                Game.GetInstance().LocalPlayerTypeID = ActorHelper.RoleIdToTypeId(mVocationId);
                Game.GetInstance().LocalPlayerName   = mNameInputField.text;

                // 保存角色职业信息
                GlobalConfig.GetInstance().LoginInfo.RId = create_role.uuid.ToString();
                GlobalConfig.GetInstance().LoginInfo.Job = mVocationId.ToString();
                GlobalConfig.GetInstance().LoginInfo.Level = "0";
                GlobalConfig.GetInstance().LoginInfo.CreateRoleTime = create_role.now.ToString();

                // 通知服务端
                var enter_game = new C2SEnterGame();

                enter_game.uuid = create_role.uuid;
                NetClient.GetBaseClient().SendData <C2SEnterGame>(NetMsg.MSG_ENTER_GAME, enter_game);

                // 通知控制服
                ControlServerLogHelper.GetInstance().PostRoleInfo();

                // 通知sdk,sendRoleInfo2SDK要求等级最小为1,需要特殊处理
                GlobalConfig.GetInstance().LoginInfo.Level = "1";
                SDKControler.getSDKControler().sendRoleInfo2SDK((int)SDKControler.RoleEvent.CREATE_ROLE);

                // 创角埋点数据上报
                if (xc.Const.Region == xc.RegionType.KOREA)
                {
                    xc.BuriedPointHelper.ReportTapjoyEvnet("account generate");
                }

                // 注册FCM
                DBOSManager.getOSBridge().registerFCM();

                // 注册推送服务
                DBOSManager.getOSBridge().registerPush();
            }