Ejemplo n.º 1
0
        //更新服务器列表   当服务端返回eMsgToGCFromLS_NotifyServerBSAddr(513)此消息时调用
        public void UpdateServerAddr(Stream stream)
        {
            LSToGC.ServerBSAddr pMsg;
            if (!ProtobufMsg.MessageDecode <LSToGC.ServerBSAddr>(out pMsg, stream))
            {
                return;
            }

            SelectServerData.Instance.Clean();
            for (int i = 0; i < pMsg.serverinfo.Count; i++)
            {
                string addr  = pMsg.serverinfo.ElementAt(i).ServerAddr;
                int    state = pMsg.serverinfo.ElementAt(i).ServerState;
                string name  = pMsg.serverinfo.ElementAt(i).ServerName;
                int    port  = pMsg.serverinfo.ElementAt(i).ServerPort;
                //添加到服务器列表中
                SelectServerData.Instance.SetServerList(i, name, (SelectServerData.ServerState)state, addr, port);
            }

            NetworkManager.Instance.Close();
            NetworkManager.Instance.canReconnect = false;

            SelectServerData.Instance.SetDefaultServer();
            //与之绑定的事件是SdkServerCheckSuccess
            EventCenter.Broadcast((Int32)GameEventEnum.GameEvent_SdkServerCheckSuccess);
        }
Ejemplo n.º 2
0
        //接收GateServer信息    广播登录成功信息
        public void RecvGateServerInfo(Stream stream)
        {
            BSToGC.AskGateAddressRet pMsg = ProtobufMsg.MessageDecode <BSToGC.AskGateAddressRet>(stream);
            SelectServerData.Instance.GateServerAdress = pMsg.ip;
            SelectServerData.Instance.GateServerPort   = pMsg.port;
            SelectServerData.Instance.GateServerToken  = pMsg.token;
            SelectServerData.Instance.SetGateServerUin(pMsg.user_name);
            NetworkManager.Instance.canReconnect = false;
            NetworkManager.Instance.Close();

            NetworkManager.Instance.Init(pMsg.ip, pMsg.port, NetworkManager.ServerType.GateServer, true);
            EventCenter.Broadcast((Int32)GameEventEnum.GameEvent_LoginSuccess); //登陆成功事件来移除绑定事件
        }
Ejemplo n.º 3
0
    /////////////////////消息接收//////////////////////////
    private void HandleNetMsg(Stream stream, int n32ProtocalID)
    {
        Debug.Log("n32ProtocalID =  " + (GSToGC.MsgID)n32ProtocalID);

        switch (n32ProtocalID)
        {
        case (int)LSToGC.MsgID.eMsgToGCFromLS_NotifyServerBSAddr:    //513  选择服务器返回
            MessageHandler.Instance.OnNotifyServerAddr(ProtobufMsg.MessageDecode <ServerBSAddr>(stream));
            break;

        case (int)BSToGC.MsgID.eMsgToGCFromBS_AskGateAddressRet:    //203 开始游戏后返回
            MessageHandler.Instance.OnNotifyGateServerInfo(ProtobufMsg.MessageDecode <AskGateAddressRet>(stream));
            break;

        case (int)BSToGC.MsgID.eMsgToGCFromBS_OneClinetLoginCheckRet:    //204  开始游戏先返回
            MessageHandler.Instance.OnOneClinetLoginCheckRet(ProtobufMsg.MessageDecode <ClinetLoginCheckRet>(stream));
            break;

        case (int)GSToGC.MsgID.eMsgToGCFromGS_NotifyUserBaseInfo:
            MessageHandler.Instance.OnNotifyUserBaseInfo(ProtobufMsg.MessageDecode <UserBaseInfo>(stream));        //用户基本信息
            break;

        case (int)GCToCS.MsgNum.eMsgToGSToCSFromGC_RequestMatchTeamList:
            MessageHandler.Instance.OnRequestMatchTeamList();
            break;

        case (int)GSToGC.MsgID.eMsgToGCFromGS_NotifyMatchTeamBaseInfo:
            MessageHandler.Instance.OnNotifyMatchTeamBaseInfo(ProtobufMsg.MessageDecode <NotifyMatchTeamBaseInfo>(stream));    //通知匹配队伍基本信息 显示匹配界面
            break;

        case (int)GSToGC.MsgID.eMsgToGCFromGS_NotifyMatchTeamPlayerInfo:
            MessageHandler.Instance.OnNotifyMatchTeamPlayerInfo(ProtobufMsg.MessageDecode <NotifyMatchTeamPlayerInfo>(stream));    //匹配队伍玩家信息
            break;

        case (int)GSToGC.MsgID.eMsgToGCFromGS_NotifyMatchTeamSwitch:
            MessageHandler.Instance.OnNotifyMatchTeamSwitch(ProtobufMsg.MessageDecode <NotifyMatchTeamSwitch>(stream));     //匹配界面显示
            break;

        case (int)GSToGC.MsgID.eMsgToGCFromGS_NotifyBattleMatherCount:
            MessageHandler.Instance.OnNotifyBattleMatherCount(ProtobufMsg.MessageDecode <BattleMatcherCount>(stream));
            break;

        case (int)GSToGC.MsgID.eMsgToGCFromGS_NotifyBattleSeatPosInfo:
            MessageHandler.Instance.OnNotifyBattleSeatPosInfo(ProtobufMsg.MessageDecode <BattleSeatPosInfo>(stream));     // 座位设置 这里显示的英雄选择窗口
            break;

        case (int)GSToGC.MsgID.eMsgToGCFromGS_NotifyTryToChooseHero:
            MessageHandler.Instance.OnNotifyToChooseHero(ProtobufMsg.MessageDecode <TryToChooseHero>(stream));     //   试图选择英雄
            break;

        case (int)GSToGC.MsgID.eMsgToGCFromGS_NotifyBattleHeroInfo:
            MessageHandler.Instance.OnNotifyBattleHeroInfo(ProtobufMsg.MessageDecode <HeroInfo>(stream));      //   确认战斗英雄信息
            break;

        case (int)GSToGC.MsgID.eMsgToGCFromGS_NotifyHeroList:    //英雄选择列表
            MessageHandler.Instance.OnNotifyHeroList(ProtobufMsg.MessageDecode <HeroList>(stream));
            break;

        case (int)GSToGC.MsgID.eMsgToGCFromGS_NotifyBattleBaseInfo:
            MessageHandler.Instance.OnNotifyBattleBaseInfo(ProtobufMsg.MessageDecode <BattleBaseInfo>(stream));     // 战斗基本信息  设置地图id
            break;

        case (int)GSToGC.MsgID.eMsgToGCFromGS_NotifyBattleStateChange:
            MessageHandler.Instance.OnNotifyBattleStateChange(ProtobufMsg.MessageDecode <BattleStateChange>(stream));    //战斗状态改变
            break;

        case (Int32)GSToGC.MsgID.eMsgToGCFromGS_BroadcastBattleHeroInfo:
            MessageHandler.Instance.OnBroadcastBattleHeroInfo(ProtobufMsg.MessageDecode <BroadcastBattleHeroInfo>(stream));    //战斗英雄信息
            break;

        case (Int32)GSToGC.MsgID.eMsgToGCFromGS_NotifyHeroInfo:
            MessageHandler.Instance.OnNotifyHeroInfo(ProtobufMsg.MessageDecode <NotifyHeroInfo>(stream));   //英雄信息
            break;
            //case (Int32)GSToGC.MsgID.eMsgToGCFromGS_NotifyGameObjectAppear:
            //   MessageHandler.Instance.OnNotifyGameObjectAppear(ProtobufMsg.MessageDecode<GOAppear>(stream));  //通知客户端显示游戏对象

            //   break;
        }
    }
Ejemplo n.º 4
0
    void HandleNetMsg(Stream stream, int n32ProtocalID)
    {
        Debug.Log("n32ProtocalID =  " + (GSToGC.MsgID)n32ProtocalID);

        switch (n32ProtocalID)
        {
        case (int)GSToGC.MsgID.eMsgToGCFromGS_BroadcastBattleHeroInfo:
            MessageHandler.Instance.OnBroadcastBattleHeroInfo(ProtobufMsg.MessageDecode <BroadcastBattleHeroInfo>(stream));   //战斗英雄信息 heroid
            break;

        case (int)GSToGC.MsgID.eMsgToGCFromGS_NotifyGameObjectAppear:
            MessageHandler.Instance.OnNotifyGameObjectAppear(ProtobufMsg.MessageDecode <GOAppear>(stream));     //通知客户端显示游戏对象
            break;

        case (Int32)GSToGC.MsgID.eMsgToGCFromGS_NotifyGameObjectRunState:
            MessageHandler.Instance.OnNotifyGameObjectRunState(ProtobufMsg.MessageDecode <RunningState>(stream));   //runState
            break;

        case (Int32)GSToGC.MsgID.eMsgToGCFromGS_NotifySkillModelStartForceMoveTeleport:
            MessageHandler.Instance.OnNotifySkillModelStartForceMoveTeleport(ProtobufMsg.MessageDecode <NotifySkillModelStartForceMoveTeleport>(stream));   //开始传输位置
            break;

        case (Int32)GSToGC.MsgID.eMsgToGCFromGS_NotifyGameObjectFreeState:
            MessageHandler.Instance.OnNotifySGameObjectFreeState(ProtobufMsg.MessageDecode <FreeState>(stream));   //进入自由状态
            break;

        case (Int32)GSToGC.MsgID.eMsgToGCFromGS_NotifySkillInfo:                                            //技能信息 包含技能id 冷却时间  英雄id guid
            MessageHandler.Instance.OnNotifySkillInfo(ProtobufMsg.MessageDecode <NotifySkillInfo>(stream)); //进入自由状态
            break;

        case (Int32)GSToGC.MsgID.eMsgToGCFromGS_NotifyGameObjectReleaseSkillState:                                                //通知客户端释放技能
            MessageHandler.Instance.OnNotifyGameObjectReleaseSkillState(ProtobufMsg.MessageDecode <ReleasingSkillState>(stream)); //释放技能
            break;

        case (Int32)GSToGC.MsgID.eMsgToGCFromGS_NotifySkillModelEmit:
            MessageHandler.Instance.OnNotifySkillModelEmit(ProtobufMsg.MessageDecode <EmitSkill>(stream));    //产生特效
            break;

        case (Int32)GSToGC.MsgID.eMsgToGCFromGS_NotifySkillModelBufEffect:    //buff效果
            MessageHandler.Instance.OnNotifySkillModelBufEffect(ProtobufMsg.MessageDecode <BuffEffect>(stream));
            break;

        case (Int32)GSToGC.MsgID.eMsgToGCFromGS_NotifySkillModelHitTarget:    //新技能受击
            MessageHandler.Instance.OnNotifySkillModelHitTarget(ProtobufMsg.MessageDecode <HitTar>(stream));
            break;

        case (Int32)GSToGC.MsgID.eMsgToGCFromGS_NotifySkillModelRange:                                        //范围技能
            MessageHandler.Instance.OnNotifySkillModelRange(ProtobufMsg.MessageDecode <RangeEffect>(stream)); //范围技能
            break;

        case (Int32)GSToGC.MsgID.eMsgToGCFromGS_NotifySkillModelEmitDestroy:                                              //新飞行物体销毁
            MessageHandler.Instance.OnNotifySkillModelEmitDestroy(ProtobufMsg.MessageDecode <DestroyEmitEffect>(stream)); //销毁特效
            break;

        case (Int32)GSToGC.MsgID.eMsgToGCFromGS_NotifyHPInfo:    //HP信息
            MessageHandler.Instance.OnNotifyHPInfo(ProtobufMsg.MessageDecode <NotifyHPInfo>(stream));
            break;

        case (Int32)GSToGC.MsgID.eMsgToGCFromGS_NotifyMPInfo:
            MessageHandler.Instance.OnNotifyMPInfo(ProtobufMsg.MessageDecode <NotifyMPInfo>(stream));
            break;

        case (Int32)GSToGC.MsgID.eMsgToGCFromGS_NotifyHPChange:    //hp改变
            MessageHandler.Instance.OnNotifyHPChange(ProtobufMsg.MessageDecode <HPChange>(stream));
            break;

        case (Int32)GSToGC.MsgID.eMsgToGCFromGS_NotifyMPChange:    //通知魔法值改变
            MessageHandler.Instance.OnNotifyMPChange(ProtobufMsg.MessageDecode <MpChange>(stream));
            break;

        case (Int32)GSToGC.MsgID.eMsgToGCFromGS_NotifyGameObjectDeadState:
            MessageHandler.Instance.OnNotifyGameObjectDeadState(ProtobufMsg.MessageDecode <DeadState>(stream));     //通知游戏对象进入死亡状态
            break;

        case (Int32)GSToGC.MsgID.eMsgToGCFromGS_NotifyGameObjectReliveState:
            MessageHandler.Instance.OnNotifyGameObjectReliveState(ProtobufMsg.MessageDecode <NotifyGameObjectReliveState>(stream));    //重生状态
            break;
        }
    }