Esempio n. 1
0
    static void SendWaitSyncComponent(IProtocolMessageInterface msg)
    {
        LockStepDemo.GameLogic.Component.WaitSyncComponent e = (LockStepDemo.GameLogic.Component.WaitSyncComponent)msg;
        Dictionary <string, object> data = new Dictionary <string, object>();

        NetworkManager.SendMessage("waitsynccomponent", data);
    }
    public static void SendMsg(SyncSession session, IProtocolMessageInterface msg)
    {
        string key = msg.GetType().Name.ToLower();

        switch (key)
        {
        case  "changecomponentmsg": SendChangeComponentMsg(session, (Protocol.ChangeComponentMsg)msg); break;

        case  "changesingletoncomponentmsg": SendChangeSingletonComponentMsg(session, (Protocol.ChangeSingletonComponentMsg)msg); break;

        case  "debugmsg": SendDebugMsg(session, (Protocol.DebugMsg)msg); break;

        case  "destroyentitymsg": SendDestroyEntityMsg(session, (Protocol.DestroyEntityMsg)msg); break;

        case  "pursuemsg": SendPursueMsg(session, (Protocol.PursueMsg)msg); break;

        case  "startsyncmsg": SendStartSyncMsg(session, (Protocol.StartSyncMsg)msg); break;

        case  "syncentitymsg": SendSyncEntityMsg(session, (Protocol.SyncEntityMsg)msg); break;

        case  "commandcomponent": SendCommandComponent(session, (CommandComponent)msg); break;

        default:
            Debug.LogError("SendCommand Exception : 不支持的消息类型!" + key);
            break;
        }
    }
    static void SendDebugMsg(IProtocolMessageInterface msg)
    {
        Protocol.DebugMsg           e    = (Protocol.DebugMsg)msg;
        Dictionary <string, object> data = new Dictionary <string, object>();

        data.Add("frame", e.frame);
        {
            List <object> list2 = new List <object>();
            for (int i2 = 0; i2 < e.infos.Count; i2++)
            {
                Dictionary <string, object> data2 = new Dictionary <string, object>();
                data2.Add("id", e.infos[i2].id);
                {
                    List <object> list4 = new List <object>();
                    for (int i4 = 0; i4 < e.infos[i2].infos.Count; i4++)
                    {
                        Dictionary <string, object> data4 = new Dictionary <string, object>();
                        data4.Add("m_compname", e.infos[i2].infos[i4].m_compName);
                        data4.Add("content", e.infos[i2].infos[i4].content);
                        list4.Add(data4);
                    }
                    data2.Add("infos", list4);
                }
                list2.Add(data2);
            }
            data.Add("infos", list2);
        }
        NetworkManager.SendMessage("debugmsg", data);
    }
Esempio n. 4
0
 public static void SendCommand(IProtocolMessageInterface cmd)
 {
     if (cmd is LockStepDemo.GameLogic.Component.WaitSyncComponent)
     {
         SendWaitSyncComponent(cmd);
     }
     else if (cmd is Protocol.ChangeComponentMsg)
     {
         SendChangeComponentMsg(cmd);
     }
     else if (cmd is Protocol.ChangeSingletonComponentMsg)
     {
         SendChangeSingletonComponentMsg(cmd);
     }
     else if (cmd is Protocol.DestroyEntityMsg)
     {
         SendDestroyEntityMsg(cmd);
     }
     else if (cmd is Protocol.SyncEntityMsg)
     {
         SendSyncEntityMsg(cmd);
     }
     else
     {
         throw new Exception("SendCommand Exception : 不支持的消息类型!" + cmd.GetType());
     }
 }
Esempio n. 5
0
    static void SendDestroyEntityMsg(IProtocolMessageInterface msg)
    {
        Protocol.DestroyEntityMsg   e    = (Protocol.DestroyEntityMsg)msg;
        Dictionary <string, object> data = new Dictionary <string, object>();

        data.Add("frame", e.frame);
        data.Add("id", e.id);
        NetworkManager.SendMessage("destroyentitymsg", data);
    }
    static void SendPursueMsg(IProtocolMessageInterface msg)
    {
        Protocol.PursueMsg          e    = (Protocol.PursueMsg)msg;
        Dictionary <string, object> data = new Dictionary <string, object>();

        data.Add("frame", e.frame);
        data.Add("advancecount", e.advanceCount);
        NetworkManager.SendMessage("pursuemsg", data);
    }
    static void SendStartSyncMsg(IProtocolMessageInterface msg)
    {
        Protocol.StartSyncMsg       e    = (Protocol.StartSyncMsg)msg;
        Dictionary <string, object> data = new Dictionary <string, object>();

        data.Add("frame", e.frame);
        data.Add("intervaltime", e.intervalTime);
        NetworkManager.SendMessage("startsyncmsg", data);
    }
    static void SendStartSyncMsg(IProtocolMessageInterface msg)
    {
        Protocol.StartSyncMsg       e    = (Protocol.StartSyncMsg)msg;
        Dictionary <string, object> data = new Dictionary <string, object>();

        data.Add("frame", e.frame);
        data.Add("advancecount", e.advanceCount);
        data.Add("intervaltime", e.intervalTime);
        data.Add("createentityindex", e.createEntityIndex);
        data.Add("syncrule", (int)e.SyncRule);
        NetworkManager.SendMessage("startsyncmsg", data);
    }
Esempio n. 9
0
    static void SendChangeSingletonComponentMsg(IProtocolMessageInterface msg)
    {
        Protocol.ChangeSingletonComponentMsg e    = (Protocol.ChangeSingletonComponentMsg)msg;
        Dictionary <string, object>          data = new Dictionary <string, object>();

        data.Add("frame", e.frame);
        {
            Dictionary <string, object> data2 = new Dictionary <string, object>();
            data2.Add("m_compname", e.info.m_compName);
            data2.Add("content", e.info.content);
            data.Add("info", data2);
        }
        NetworkManager.SendMessage("changesingletoncomponentmsg", data);
    }
    static void SendCommandComponent(IProtocolMessageInterface msg)
    {
        CommandComponent            e    = (CommandComponent)msg;
        Dictionary <string, object> data = new Dictionary <string, object>();

        data.Add("isforward", e.isForward);
        data.Add("isback", e.isBack);
        data.Add("isright", e.isRight);
        data.Add("isleft", e.isLeft);
        data.Add("isfire", e.isFire);
        data.Add("id", e.id);
        data.Add("frame", e.frame);
        NetworkManager.SendMessage("commandcomponent", data);
    }
Esempio n. 11
0
    public static void SendMsg(SyncSession session, IProtocolMessageInterface msg)
    {
        string key = msg.GetType().Name.ToLower();

        switch (key)
        {
        case  "affirmmsg": SendAffirmMsg(session, (Protocol.AffirmMsg)msg); break;

        case  "changecomponentmsg": SendChangeComponentMsg(session, (Protocol.ChangeComponentMsg)msg); break;

        case  "changesingletoncomponentmsg": SendChangeSingletonComponentMsg(session, (Protocol.ChangeSingletonComponentMsg)msg); break;

        case  "commandmsg": SendCommandMsg(session, (Protocol.CommandMsg)msg); break;

        case  "debugmsg": SendDebugMsg(session, (Protocol.DebugMsg)msg); break;

        case  "destroyentitymsg": SendDestroyEntityMsg(session, (Protocol.DestroyEntityMsg)msg); break;

        case  "pursuemsg": SendPursueMsg(session, (Protocol.PursueMsg)msg); break;

        case  "querycommand": SendQueryCommand(session, (Protocol.QueryCommand)msg); break;

        case  "startsyncmsg": SendStartSyncMsg(session, (Protocol.StartSyncMsg)msg); break;

        case  "syncentitymsg": SendSyncEntityMsg(session, (Protocol.SyncEntityMsg)msg); break;

        case  "commandcomponent": SendCommandComponent(session, (CommandComponent)msg); break;

        case  "playerbuycharacter_c": SendPlayerBuyCharacter_c(session, (PlayerBuyCharacter_c)msg); break;

        case  "playerloginmsg_c": SendPlayerLoginMsg_c(session, (PlayerLoginMsg_c)msg); break;

        case  "playermatchmsg_c": SendPlayerMatchMsg_c(session, (PlayerMatchMsg_c)msg); break;

        case  "playerrename_c": SendPlayerRename_c(session, (PlayerRename_c)msg); break;

        case  "playerresurgence_c": SendPlayerResurgence_c(session, (PlayerResurgence_c)msg); break;

        case  "playerselectcharacter_c": SendPlayerSelectCharacter_c(session, (PlayerSelectCharacter_c)msg); break;

        case  "playersettlement_c": SendPlayerSettlement_c(session, (PlayerSettlement_c)msg); break;

        default:
            Debug.LogError("SendCommand Exception : 不支持的消息类型!" + key);
            break;
        }
    }
Esempio n. 12
0
 public static void SendCommand(IProtocolMessageInterface cmd)
 {
 }