Exemple #1
0
        /// <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);
        }
Exemple #2
0
        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;
            }
        }
Exemple #3
0
 public void DoCmd(KeyData keyData)
 {
     Debug.LogError("执行关键帧 " + keyData.ToString());
     DoCmd(keyData.cmd, keyData.data, keyData.roleId);
 }
Exemple #4
0
        public void InputCmd(Cmd cmd, string param)
        {
            KeyData keyData = new KeyData(cmd, param, curRoleId);

            _netManager.AddKeyPack(keyData);
        }
Exemple #5
0
 public void InputCmd(Cmd cmd, string param)
 {
     KeyData keyData = new KeyData(cmd, param, curRoleId);
     _netManager.AddKeyPack(keyData);
 }
Exemple #6
0
 public void DoCmd(KeyData keyData)
 {
     Debug.LogError("执行关键帧 "+keyData.ToString());
     DoCmd(keyData.cmd, keyData.data, keyData.roleId);
 }
Exemple #7
0
 public void AddKeyPack(KeyData data)
 {
     m_keyPack.Add(data.ToString());
 }
Exemple #8
0
 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;
     }
 }
Exemple #9
0
 public void AddKeyPack(KeyData data)
 {
     keyPack.Add(data.ToString());
 }