/// <summary> /// 来自本地客户端的输入命令 /// </summary> /// <param name="cmd">命令</param> /// <param name="param">参数</param> public void InputCmd(Cmd cmd, string param) { //封装关键帧数据 KeyData keyData = new KeyData(cmd, param, GlobalClient.NetWorkManager.ClientID); //100毫秒向服务器发一次 GlobalClient.NetWorkManager.AddKeyPack(keyData); }
public void OnMessage(MessageBuffer msg) { int cproto = msg.ReadInt(); Debug.Log(cproto); switch (cproto) { case cProto.CONNECT: // SceneManager.instance.InitViewMap(); int roleId = msg.ReadInt(); // SceneManager.instance.viewMap.CreateMe(roleId); SceneManager.instance.viewMap.LogicMap.m_curRoleId = roleId; Debug.Log("玩家,id = " + roleId); break; case cProto.READY: break; case cProto.SYNC_POS: int cRoleId = msg.ReadInt(); string pos = msg.ReadString(); SceneManager.instance.viewMap.SyncPos(cRoleId, pos); Debug.Log(string.Format("玩家 {0} ,pos = {1}", cRoleId, pos)); break; case cProto.SYNC_KEY: int servFrameCount = msg.ReadInt(); if (servFrameCount >= SceneManager.instance.viewMap.LogicMap.m_curFrameCount) { string keyStr = msg.ReadString(); string[] keyData = keyStr.Split(';'); for (int i = 0; i < keyData.Length; ++i) { if (keyData[i] == "") { continue; } KeyData data = new KeyData(keyData[i]); SceneManager.instance.viewMap.LogicMap.DoCmd(data); } SceneManager.instance.viewMap.LogicMap.m_curFrameCount += 1; } break; case cProto.START: string players = msg.ReadString(); SceneManager.instance.viewMap.CreateAllPlayer(players); Debug.LogError(" start ========================= "); TimerHeap.AddTimer(0, 50, SycMePos); TimerHeap.AddTimer(0, 100, SycKey); break; } }
public void DoCmd(KeyData keyData) { Debug.LogError("执行关键帧 " + keyData.ToString()); DoCmd(keyData.cmd, keyData.data, keyData.roleId); }
public void InputCmd(Cmd cmd, string param) { KeyData keyData = new KeyData(cmd, param, curRoleId); _netManager.AddKeyPack(keyData); }
public void DoCmd(KeyData keyData) { Debug.LogError("执行关键帧 "+keyData.ToString()); DoCmd(keyData.cmd, keyData.data, keyData.roleId); }
public void AddKeyPack(KeyData data) { m_keyPack.Add(data.ToString()); }
public void OnMessage(MessageBuffer msg) { int cproto = msg.ReadInt(); Debug.Log(cproto); switch (cproto) { case cProto.CONNECT: // SceneManager.instance.InitViewMap(); int roleId = msg.ReadInt(); // SceneManager.instance.viewMap.CreateMe(roleId); SceneManager.instance.viewMap.LogicMap.curRoleId = roleId; Debug.Log("玩家,id = " + roleId); break; case cProto.READY: break; case cProto.SYNC_POS: int cRoleId = msg.ReadInt(); string pos = msg.ReadString(); SceneManager.instance.viewMap.SyncPos(cRoleId, pos); Debug.Log(string.Format("玩家 {0} ,pos = {1}", cRoleId ,pos)); break; case cProto.SYNC_KEY: int servFrameCount = msg.ReadInt(); if (servFrameCount >= SceneManager.instance.viewMap.LogicMap.curFrameCount) { string keyStr = msg.ReadString(); string[] keyData = keyStr.Split(';'); for (int i = 0; i < keyData.Length; ++i ) { if(keyData[i] == "") { continue; } KeyData data = new KeyData(keyData[i]); SceneManager.instance.viewMap.LogicMap.DoCmd(data); } SceneManager.instance.viewMap.LogicMap.curFrameCount += 1; } break; case cProto.START: string players = msg.ReadString(); SceneManager.instance.viewMap.CreateAllPlayer(players); TimerHeap.AddTimer(0, 50, SycMePos); TimerHeap.AddTimer(0, 100, SycKey); break; } }
public void AddKeyPack(KeyData data) { keyPack.Add(data.ToString()); }