コード例 #1
0
    public void OnGameFinsih(params object[] objs)
    {
        WorldBase world = (WorldBase)objs[0];

        world.eventSystem.DispatchEvent(GameUtils.c_scoreChange, null);
        List <PlayerComponent> rankList = world.GetSingletonComp <RankComponent>().rankList;
        int diamond = rankList.Count;

        for (int i = 0; i < rankList.Count; i++)
        {
            ConnectionComponent cc = rankList[i].Entity.GetComp <ConnectionComponent>();

            PlayerSettlement_c msg = new PlayerSettlement_c();
            msg.rank              = i + 1;
            msg.diamond           = diamond--;
            msg.score             = rankList[i].score;
            msg.historicalHighest = rankList[i].score;

            if (cc.m_session != null)
            {
                cc.m_session.player.Diamond += msg.diamond;
                ProtocolAnalysisService.SendMsg(cc.m_session, msg);
            }
            else
            {
                //TODO 将奖励发放给离线玩家
            }
        }
    }
コード例 #2
0
    void ReceviceCmdMsg(CommandMsg msg, params object[] objs)
    {
        //Debug.Log("ReceviceCmdMsg " + msg.index + " currentframe " + m_world.FrameCount);

        //立即返回确认消息
        AffirmMsg amsg = new AffirmMsg();

        amsg.index = msg.index;
        amsg.time  = msg.serverTime;
        ProtocolAnalysisService.SendCommand(amsg);

        if (m_world.IsStart)
        {
            //TODO 如果全部都与本地预测相同则不再重计算
            for (int i = 0; i < msg.msg.Count; i++)
            {
                //Debug.Log("RecordCommand " + Serializer.Serialize(msg.msg[i]));
                RecordCommand(msg.msg[i]);
            }

            Recalc();
        }
        else
        {
            //存入未执行命令列表
            //Debug.Log("存入未执行命令列表");
            //GameDataCacheComponent gdcc = m_world.GetSingletonComp<GameDataCacheComponent>();
            //gdcc.m_noExecuteCommandList.Add(msg);
        }
    }
コード例 #3
0
    public void ReceviceSelectCharacter(SyncSession session, PlayerSelectCharacter_s msg)
    {
        if (session.player == null)
        {
            Debug.LogError("玩家未登录");
        }

        bool isHave = false;

        //判断该角色是否在玩家的拥有角色列表
        for (int i = 0; i < session.player.OwnCharacter.Count; i++)
        {
            if (session.player.OwnCharacter[i] == msg.characterID)
            {
                isHave = true;
            }
        }

        //如果是,替换玩家角色
        if (isHave)
        {
            session.player.characterID = msg.characterID;
            PlayerSelectCharacter_c m = new PlayerSelectCharacter_c();
            m.code = ServiceErrorCode.c_Success;

            ProtocolAnalysisService.SendMsg(session, m);
        }
        else
        {
            PlayerSelectCharacter_c m = new PlayerSelectCharacter_c();
            m.code = ServiceErrorCode.c_DontOwnCharacter;

            ProtocolAnalysisService.SendMsg(session, m);
        }
    }
コード例 #4
0
    void StartGame(Player[] players)
    {
        WorldBase world = WorldManager.CreateWorld <DemoWorld>();

        //TODO 模式选择没用了
        world.SyncRule = SyncRule.Status;

        world.m_RandomSeed = new Random().Next(); //随机一个种子

        for (int i = 0; i < players.Length; i++)
        {
            ConnectionComponent conn = new ConnectionComponent();
            conn.m_session  = players[i].session;
            conn.m_playerID = players[i].playerID;

            SyncComponent sc = new SyncComponent();

            world.CreateEntityImmediately("Player" + players[i].playerID, conn, sc);

            players[i].session.m_connect = conn;

            world.eventSystem.DispatchEvent(ServiceEventDefine.c_playerJoin, conn.Entity);

            Debug.Log("Send Game Start");
            //派发游戏开始消息
            PlayerMatchMsg_c msg = new PlayerMatchMsg_c();
            msg.predictTime = 0;
            msg.isMatched   = true;

            ProtocolAnalysisService.SendMsg(players[i].session, msg);
        }

        world.IsStart = true;
    }
コード例 #5
0
    void RecevicePursueMsg(PursueMsg msg, params object[] objs)
    {
        //立即返回确认消息
        AffirmMsg amsg = new AffirmMsg();

        amsg.frame = msg.frame;
        amsg.time  = msg.serverTime;
        ProtocolAnalysisService.SendCommand(amsg);

        PlayerCommandRecordComponent pcrc = m_world.GetEntity(msg.id).GetComp <PlayerCommandRecordComponent>();

        //for (int i = 0; i < msg.m_commandList.Count; i++)
        //{
        //    pcrc.RecordCommand(deserializer.Deserialize<T>( msg.m_commandList[i]));
        //}

        Recalc(msg.recalcFrame);  //从接收到命令的第一帧开始重计算
        clearReson = "RecevicePursueMsg";

        AdvanceCalc(msg.frame + msg.advanceCount); //提前计算

        ConnectStatusComponent csc = m_world.GetSingletonComp <ConnectStatusComponent>();

        csc.aheadFrame = msg.advanceCount;
    }
コード例 #6
0
    public static void SendStartMsg(WorldBase world)
    {
        //获取所有的Player组件,并派发
        List <EntityBase> list = world.GetEntityList(s_playerFilter);

        StartSyncMsg startMsg = CreateStartMsg(world);

        SyncEntityMsg playerInfo = new SyncEntityMsg();

        playerInfo.frame = world.FrameCount;
        playerInfo.infos = new List <EntityInfo>();

        for (int i = 0; i < list.Count; i++)
        {
            playerInfo.infos.Add(CreatePlayerComponentInfo(list[i]));
        }

        for (int i = 0; i < list.Count; i++)
        {
            ConnectionComponent cc          = list[i].GetComp <ConnectionComponent>();
            SyncEntityMsg       serviceInfo = CreateServiceMsg(world, cc.m_session);

            ProtocolAnalysisService.SendMsg(cc.m_session, playerInfo);
            ProtocolAnalysisService.SendMsg(cc.m_session, serviceInfo);
            ProtocolAnalysisService.SendMsg(cc.m_session, startMsg);
        }
    }
コード例 #7
0
    public override void BeforeFixedUpdate(int deltaTime)
    {
        //Debug.Log("GetEntityList A");

        List <EntityBase> list = GetEntityList();

        //Debug.Log("list Res -> " + GetEntityList(new string[] { "CommandComponent", "ConnectionComponent" }).Count);

        //Debug.Log("GetEntityList B " + list.Count);

        for (int i = 0; i < list.Count; i++)
        {
            ConnectionComponent comp = list[i].GetComp <ConnectionComponent>();
            T cmd = (T)comp.GetCommand(m_world.FrameCount);
            cmd.id    = list[i].ID;
            cmd.frame = m_world.FrameCount;

            list[i].ChangeComp(cmd);

            //Debug.Log("USE cmd id "+ list[i].ID + " frame " + cmd.frame + " content " + Serializer.Serialize(cmd));

            //到了这一帧还没有发送命令的,给预测一个并广播给所有前端
            if (comp.LastInputFrame < m_world.FrameCount)
            {
                for (int j = 0; j < list.Count; j++)
                {
                    ConnectionComponent conn = list[j].GetComp <ConnectionComponent>();
                    ProtocolAnalysisService.SendMsg(conn.m_session, cmd);
                }
            }
        }
    }
コード例 #8
0
    public override void BeforeFixedUpdate(int deltaTime)
    {
        List <EntityBase> list = GetEntityList();

        for (int i = 0; i < list.Count; i++)
        {
            ConnectionComponent comp = list[i].GetComp <ConnectionComponent>();
            comp.m_isInframe = true;

            T cmd = (T)comp.GetCommand(m_world.FrameCount);
            cmd.id    = list[i].ID;
            cmd.frame = m_world.FrameCount;

            list[i].ChangeComp(cmd);

            //Debug.Log("USE cmd id "+ list[i].ID + " frame " + cmd.frame + " content " + Serializer.Serialize(cmd));

            //到了这一帧还没有发送命令的,给预测一个并广播给所有前端
            //if (comp.LastInputFrame < m_world.FrameCount)
            {
                for (int j = 0; j < list.Count; j++)
                {
                    cmd.time = ServiceTime.GetServiceTime();

                    ConnectionComponent conn = list[j].GetComp <ConnectionComponent>();
                    ProtocolAnalysisService.SendMsg(conn.m_session, cmd);
                    //Debug.Log("预测并广播 " + cmd.frame);
                }
            }
        }
    }
コード例 #9
0
    public override void BeforeFixedUpdate(int deltaTime)
    {
        List <EntityBase> list = GetEntityList();

        if (list.Count > 1)
        {
            Debug.LogError("CommandSyncSystem Error exist two selfComponet!");
            return;
        }

        if (list.Count > 0)
        {
            EntityBase          entity = list[0];
            FrameCountComponent fc     = m_world.GetSingletonComp <FrameCountComponent>();
            T comp = new T();

            BuildCommand(comp);
            entity.ChangeComp(comp);

            //缓存起来
            RecordComponent rc = m_world.GetSingletonComp <RecordComponent>();
            rc.m_inputCache = comp;

            ChangeComponentMsg msg = new ChangeComponentMsg();
            msg.frame           = fc.count;
            msg.id              = entity.ID;
            msg.info            = new ComponentInfo();
            msg.info.m_compName = comp.GetType().Name;
            msg.info.content    = Serializer.Serialize(comp);

            ProtocolAnalysisService.SendCommand(msg);
        }
    }
コード例 #10
0
    public override void BeforeFixedUpdate(int deltaTime)
    {
        List <EntityBase> list = GetEntityList();

        if (list.Count > 1)
        {
            Debug.LogError("CommandSyncSystem Error exist two selfComponet!");
            return;
        }

        if (list.Count > 0)
        {
            EntityBase entity = list[0];
            T          comp   = new T();

            comp.frame = m_world.FrameCount;
            comp.id    = entity.ID;

            BuildCommand(comp);
            entity.ChangeComp(comp);

            //缓存起来
            RecordComponent rc = m_world.GetSingletonComp <RecordComponent>();
            rc.m_inputCache = comp;

            ProtocolAnalysisService.SendCommand(comp);
        }
    }
コード例 #11
0
    static void ReceviceSyncMsg(SyncSession session, T msg)
    {
        //Debug.Log("ReceviceSyncMsg " + msg.id + " content " +  Serializer.Serialize(msg));

        //消息确认
        AffirmMsg amsg = new AffirmMsg();

        amsg.index = msg.frame;
        amsg.time  = msg.time;
        ProtocolAnalysisService.SendMsg(session, amsg);

        ConnectionComponent connectComp = session.m_connect;

        if (connectComp != null)
        {
            WorldBase world = connectComp.Entity.World;

            if (msg.frame > world.FrameCount)
            {
                //广播这帧
                BroadcastCommand(world, connectComp, msg, false);
                connectComp.AddCommand(msg);
            }
            else
            {
                //当成最新的一帧来处理
                msg.frame = world.FrameCount;
                connectComp.AddCommand(msg);
            }

            ControlSpeed(connectComp, world, msg.frame);
        }
    }
コード例 #12
0
    static void ReceviceSameCmdMsg(SyncSession session, SameCommand msg)
    {
        //消息确认
        AffirmMsg amsg = new AffirmMsg();

        amsg.index = msg.frame;
        amsg.time  = msg.time;
        ProtocolAnalysisService.SendMsg(session, amsg);

        ConnectionComponent connectComp = session.m_connect;

        if (connectComp != null)
        {
            WorldBase world = connectComp.Entity.World;

            //取上一帧的数据
            T scmd = (T)connectComp.GetCommand(msg.frame - 1).DeepCopy();

            if (msg.frame > world.FrameCount)
            {
                scmd.frame = msg.frame;

                connectComp.AddCommand(scmd);
                BroadcastSameCommand(world, connectComp, msg, true);
            }
            else
            {
                scmd.frame = world.FrameCount;
                connectComp.AddCommand(scmd);
            }

            ControlSpeed(connectComp, world, msg.frame);
        }
    }
コード例 #13
0
    public void RecveviceBuyCharacter(SyncSession session, PlayerBuyCharacter_s msg)
    {
        for (int i = 0; i < session.player.OwnCharacter.Count; i++)
        {
            if (session.player.OwnCharacter[i] == msg.characterID)
            {
                PlayerBuyCharacter_c result = new PlayerBuyCharacter_c();
                result.code = ServiceErrorCode.c_HasOwnCharacter;

                ProtocolAnalysisService.SendMsg(session, result);
                return;
            }
        }
        ShopDataGenerate data = DataGenerateManager <ShopDataGenerate> .GetData(msg.characterID);

        if (data.m_cost <= session.player.Diamond)
        {
            session.player.Diamond -= (int)data.m_cost;
            session.player.OwnCharacter.Add(data.m_item_id.ToString());

            PlayerBuyCharacter_c result = new PlayerBuyCharacter_c();
            result.code = ServiceErrorCode.c_Success;

            ProtocolAnalysisService.SendMsg(session, result);
        }
        else
        {
            PlayerBuyCharacter_c result = new PlayerBuyCharacter_c();
            result.code = ServiceErrorCode.c_NotEnoughDiamond;

            ProtocolAnalysisService.SendMsg(session, result);
        }
    }
コード例 #14
0
    public void PushSyncEnity(ConnectionComponent connect, EntityBase entity)
    {
        if (connect.m_session != null &&
            !connect.m_session.Connected)
        {
            return;
        }

        SyncEntityMsg msg = new SyncEntityMsg();

        msg.frame = m_world.FrameCount;

        msg.infos       = new List <EntityInfo>();
        msg.destroyList = new List <int>();

        for (int i = 0; i < connect.m_waitSyncEntity.Count; i++)
        {
            msg.infos.Add(CreateEntityInfo(connect.m_waitSyncEntity[i], connect.m_session));
        }

        for (int i = 0; i < connect.m_waitDestroyEntity.Count; i++)
        {
            msg.destroyList.Add(connect.m_waitDestroyEntity[i]);
        }

        connect.m_waitDestroyEntity.Clear();
        connect.m_waitSyncEntity.Clear();
        if (msg.infos.Count > 0 || msg.destroyList.Count > 0)
        {
            ProtocolAnalysisService.SendMsg(connect.m_session, msg);
        }
    }
コード例 #15
0
 public override void OnUpdate()
 {
     if (NetworkManager.IsConnect)
     {
         role_login_s msg = new role_login_s();
         ProtocolAnalysisService.SendCommand(msg);
     }
 }
コード例 #16
0
        public void PushStartSyncMsg(SyncSession session)
        {
            StartSyncMsg msg = new StartSyncMsg();

            msg.frame        = m_world.FrameCount + 1;
            msg.intervalTime = UpdateEngine.IntervalTime;

            ProtocolAnalysisService.SendMsg(session, msg);
        }
コード例 #17
0
    void ReSendMessage(int frame, int id)
    {
        QueryCommand qc = new QueryCommand();

        qc.frame = frame;
        qc.id    = id;

        ProtocolAnalysisService.SendCommand(qc);
    }
コード例 #18
0
    void SelfCommandLogic(EntityBase entity)
    {
        //Debug.Log("SelfCommandLogic " + m_world.FrameCount);

        if (m_world.IsLocal)
        {
            //构建一份新指令并发送
            T ncmd = new T();

            ncmd.frame = m_world.FrameCount;
            ncmd.id    = entity.ID;

            BuildCommand(ncmd);

            entity.ChangeComp(ncmd);
        }
        else
        {
            //先取服务器缓存
            AddComp(entity);
            PlayerCommandRecordComponent rc = entity.GetComp <PlayerCommandRecordComponent>(ComponentType.PlayerCommandRecordComponent);

            T cmd = (T)rc.GetInputCahae(m_world.FrameCount);
            cmd = (T)cmd.DeepCopy();
            entity.ChangeComp(cmd);

            //构建一份新指令并发送
            T ncmd = new T();

            ncmd.frame = m_world.FrameCount + 1;
            ncmd.id    = entity.ID;

            BuildCommand(ncmd);

            if (ncmd.EqualsCmd(cmd))
            {
                sameCmdCache.frame = m_world.FrameCount + 1;
                sameCmdCache.time  = ClientTime.GetTime();
                sameCmdCache.id    = entity.ID;

                if (NetworkManager.IsConnect)
                {
                    ProtocolAnalysisService.SendCommand(sameCmdCache);
                }
            }
            else
            {
                ncmd.frame = m_world.FrameCount + 1;
                ncmd.time  = ClientTime.GetTime();
                if (NetworkManager.IsConnect)
                {
                    ProtocolAnalysisService.SendCommand(ncmd);
                }
            }
        }
    }
コード例 #19
0
    public override void NoRecalcLateFixedUpdate(int deltaTime)
    {
        if (!isDebug)
        {
            return;
        }

        DebugMsg msg = new DebugMsg();

        msg.frame = m_world.FrameCount;
        msg.infos = new List <EntityInfo>();

        for (int i = 0; i < m_world.m_entityList.Count; i++)
        {
            EntityBase eb    = m_world.m_entityList[i];
            EntityInfo einfo = new EntityInfo();
            einfo.id = eb.ID;

            einfo.infos = new List <ComponentInfo>();

            foreach (var item in eb.m_compDict)
            {
                if (item.Value.GetType().IsSubclassOf(typeof(PlayerCommandBase)))
                {
                    CommandComponent cc   = (CommandComponent)item.Value;
                    ComponentInfo    info = new ComponentInfo();
                    cc.time         = 0;
                    info.m_compName = item.Value.GetType().Name;
                    info.content    = Serializer.Serialize(item.Value);

                    einfo.infos.Add(info);
                }
                else if (IsFilter(item.Value.GetType().Name))
                {
                    ComponentInfo info = new ComponentInfo();
                    info.m_compName = item.Value.GetType().Name;
                    info.content    = Serializer.Serialize(item.Value);

                    einfo.infos.Add(info);
                }
            }

            if (einfo.infos.Count > 0)
            {
                msg.infos.Add(einfo);
            }
        }

        List <EntityBase> list = GetEntityList();

        for (int i = 0; i < list.Count; i++)
        {
            ConnectionComponent cc = list[i].GetComp <ConnectionComponent>();
            ProtocolAnalysisService.SendMsg(cc.m_session, msg);
        }
    }
コード例 #20
0
    static void ReceviceSyncMsg(SyncSession session, T msg)
    {
        //Debug.Log("ReceviceSyncMsg " + msg.id + " content " +  Serializer.Serialize(msg));

        //消息确认
        AffirmMsg amsg = new AffirmMsg();

        amsg.index = msg.frame;
        amsg.time  = msg.time;
        ProtocolAnalysisService.SendMsg(session, amsg);

        ConnectionComponent connectComp = session.m_connect;

        if (connectComp != null)
        {
            WorldBase world = connectComp.Entity.World;

            if (world.FrameCount <= msg.frame + 4)
            {
                connectComp.AddCommand(msg);
            }

            //msg.frame = world.FrameCount + 1;

            //    //广播这帧
            //    if(connectComp.AddCommand(msg))
            //    {
            //        //BroadcastCommand(world, connectComp, msg, false);
            //    }
            //}
            //else
            //{
            //    //Debug.Log("丢弃掉 " + msg.frame);

            //    //直接丢弃掉落后帧

            //    //Debug.Log("帧相等! " + msg.frame);

            //    //if (!connectComp.m_isInframe)
            //    //{
            //    //    //当成最新的一帧来处理
            //    //    msg.frame = world.FrameCount + 1;
            //    //    connectComp.AddCommand(msg);
            //    //}
            //    //else
            //    //{
            //    //    Debug.Log("在一帧之内插入了数据! " + msg.frame);

            //    //    msg.frame = world.FrameCount + 1;
            //    //    connectComp.AddCommand(msg);
            //    //}
            //}

            ControlSpeed(connectComp, world, msg.frame);
        }
    }
コード例 #21
0
    public void RecevicePlayerLogin(SyncSession session, PlayerLoginMsg_s e)
    {
        //玩家已登录
        if (m_onLinePlayer.ContainsKey(e.playerID))
        {
            return;
        }

        Debug.Log("RecevicePlayerLogin");

        if (session.player != null)
        {
            Debug.Log("" + session.player.playerID + " 已经登录,不需要重复登录! ");
        }

        //string clauseContent = "ID ='" + e.playerID + "'";
        //var result = DataBaseService.database.Query(c_playerTableName,null, clauseContent, null,null,null,null);

        //if(result.MoveToNext())
        //{
        //    Debug.Log("查询到记录! ");

        //    session.player = GetOldPlayer(result);

        //    result.Close();
        //}
        //else
        //{
        //result.Close();
        //Debug.Log("未查询到记录!");

        session.player = GetNewPlayer();
        Dictionary <string, string> value = new Dictionary <string, string>();

        value.Add("ID", e.playerID);

        //DataBaseService.database.Insert(c_playerTableName, null, value);
        //}

        session.player.playerID = e.playerID;
        session.player.nickName = e.nickName;
        session.player.session  = session;

        PlayerLoginMsg_c msg = new PlayerLoginMsg_c();

        msg.code         = ServiceErrorCode.c_Success;
        msg.characterID  = session.player.characterID;
        msg.ownCharacter = session.player.OwnCharacter;
        msg.diamond      = session.player.Diamond;
        msg.coin         = session.player.Coin;
        ProtocolAnalysisService.SendMsg(session, msg);

        //派发玩家登陆事件
        m_service.OnPlayerLogin(session.player);
    }
コード例 #22
0
    void ReceviceCommandMsg(T cmd, params object[] objs)
    {
        //Debug.Log("ReceviceCommandMsg frame " + cmd.frame + " frame " + Serializer.Serialize(cmd));

        if (SyncDebugSystem.isDebug)
        {
            SyncDebugSystem.RecordMsg("cmd_commandComponent", cmd.frame, Serializer.Serialize(cmd));
        }

        //立即返回确认消息
        AffirmMsg amsg = new AffirmMsg();

        amsg.index = cmd.frame;
        amsg.time  = cmd.time;
        ProtocolAnalysisService.SendCommand(amsg);

        if (m_world.IsStart)
        {
            EntityBase entity = m_world.GetEntity(cmd.id);
            AddComp(entity); //自动添加记录组件

            PlayerCommandRecordComponent pcrc   = entity.GetComp <PlayerCommandRecordComponent>(ComponentType.PlayerCommandRecordComponent);
            PlayerCommandBase            record = pcrc.GetInputCahae(cmd.frame);

            //判断和本地的预测有没有冲突
            if (record == null || !record.EqualsCmd(cmd))
            {
                pcrc.SetConflict(cmd.frame, true);
            }
            else
            {
                pcrc.SetConflict(cmd.frame, false);
            }

            if (pcrc.lastInputFrame < cmd.frame)
            {
                pcrc.lastInputFrame = cmd.frame;
            }

            pcrc.RecordCommand(cmd);

            //数据完整校验
            if (cmd.frame != 0 && pcrc.GetAllMessage(cmd.frame) && !pcrc.GetAllMessage(cmd.frame - 1))
            {
                ReSendMessage(cmd.frame - 1, cmd.id);
            }

            //Recalc();
        }
        else
        {
            GameDataCacheComponent gdcc = m_world.GetSingletonComp <GameDataCacheComponent>();
            gdcc.m_noExecuteCommandList.Add(cmd);
        }
    }
コード例 #23
0
        void PushDestroyEntity(SyncSession session, int entityID)
        {
            DestroyEntityMsg msg = new DestroyEntityMsg();

            msg.id    = entityID;
            msg.frame = m_world.FrameCount;

            ProtocolAnalysisService.SendMsg(session, msg);

            Debug.Log("PushDestroyEntity 3");
        }
コード例 #24
0
        public void PushSingletonComp(SyncSession session, string compName)
        {
            SingletonComponent          comp = m_world.GetSingletonComp(compName);
            ChangeSingletonComponentMsg msg  = new ChangeSingletonComponentMsg();

            msg.info.m_compName = compName;
            msg.info.content    = Serializer.Serialize(comp);
            msg.frame           = m_world.FrameCount;

            ProtocolAnalysisService.SendMsg(session, msg);
        }
コード例 #25
0
 protected override void HandleUnknownRequest(ProtocolRequestBase requestInfo)
 {
     try
     {
         //解析并派发
         ProtocolAnalysisService.AnalysisAndDispatchMessage(this, requestInfo);
     }
     catch (Exception e)
     {
         Debug.LogError("AnalysisAndDispatchMessage :" + requestInfo.Key + "\nException: " + e.ToString());
     }
 }
コード例 #26
0
    static void BroadcastSameCommand(WorldBase world, ConnectionComponent connectComp, SameCommand cmd, bool includeSelf)
    {
        cmd.time = ServiceTime.GetServiceTime();

        List <EntityBase> list = world.GetEntiyList(new string[] { "ConnectionComponent" });

        for (int i = 0; i < list.Count; i++)
        {
            ConnectionComponent cp = list[i].GetComp <ConnectionComponent>();
            ProtocolAnalysisService.SendMsg(cp.m_session, cmd);
        }
    }
コード例 #27
0
    void PushStartSyncMsg(SyncSession session)
    {
        Debug.Log("PushStartSyncMsg " + m_world.FrameCount);

        StartSyncMsg msg = new StartSyncMsg();

        msg.frame             = m_world.FrameCount;
        msg.advanceCount      = 1; //客户端提前一帧
        msg.intervalTime      = UpdateEngine.IntervalTime;
        msg.createEntityIndex = m_world.EntityIndex;

        ProtocolAnalysisService.SendMsg(session, msg);
    }
コード例 #28
0
    public override void OnEnterStatus()
    {
        NetworkManager.Init <ProtocolService>();
        NetworkManager.SetServer("47.106.106.108", 2012);
        NetworkManager.Connect();

        ProtocolAnalysisService.Init();

        //GlobalEvent.AddTypeEvent<role_login_c>(Recevice);

        WorldManager.Init(1000);
        WorldManager.CreateWorld <DemoWorld>();
    }
コード例 #29
0
    static void SendPursueMsg(ConnectionComponent connectComp, float speed)
    {
        if (connectComp.UpdateSpeed != speed)
        {
            PursueMsg pmsg = new PursueMsg();
            pmsg.updateSpeed = speed;

            pmsg.advanceCount = CalcAdvanceFrame(connectComp);

            connectComp.UpdateSpeed = speed;
            ProtocolAnalysisService.SendMsg(connectComp.m_session, pmsg);
        }
    }
コード例 #30
0
    public override void NoRecalcLateFixedUpdate(int deltaTime)
    {
        if (!isDebug)
        {
            return;
        }
        Debug.Log("SyncDebugSystem " + m_world.FrameCount);

        DebugMsg msg = new DebugMsg();

        msg.frame = m_world.FrameCount;
        msg.infos = new List <EntityInfo>();

        for (int i = 0; i < m_world.m_entityList.Count; i++)
        {
            EntityBase eb    = m_world.m_entityList[i];
            EntityInfo einfo = new EntityInfo();
            einfo.id = eb.ID;

            einfo.infos = new List <ComponentInfo>();

            foreach (var item in eb.m_compDict)
            {
                if (item.Value.GetType().IsSubclassOf(typeof(MomentComponentBase)))
                {
                    ComponentInfo info = new ComponentInfo();
                    info.m_compName = item.Value.GetType().Name;
                    info.content    = Serializer.Serialize(item.Value);

                    einfo.infos.Add(info);

                    if (info.m_compName == "MoveComponent" ||
                        info.m_compName == "CommandComponent")
                    {
                        Debug.Log(".id " + einfo.id + " m_compName " + info.m_compName + " content : " + info.content);
                    }
                }
            }

            msg.infos.Add(einfo);
        }

        List <EntityBase> list = GetEntityList();

        for (int i = 0; i < list.Count; i++)
        {
            ConnectionComponent cc = list[i].GetComp <ConnectionComponent>();
            ProtocolAnalysisService.SendMsg(cc.m_session, msg);
        }
    }