Exemple #1
0
 public void Serialize(ByteProtocol protocol)
 {
     protocol.push((int)weaponId);
     protocol.push((int)weaponType);
     protocol.push((int)defalutSkillId);
     fixedParams.Serialize(protocol);
 }
        protected void SendPingToClient(byte clientId)
        {
            ProtocolBase protocol = new ByteProtocol();

            protocol.push((byte)MessageType.Ping);
            protocol.push((byte)MessageType.end);
            this.SendToClient(clientId, protocol.GetByteStream());
        }
Exemple #3
0
 public override void Serialize(ByteProtocol protocol)
 {
     protocol.push(Weaponname);
     protocol.push(WeaponInfo);
     protocol.push(ObjToId(uiIcon));
     protocol.push(ObjToId(animation));
     protocol.push(ObjToId(ItemPrefab));
 }
Exemple #4
0
 public override void Serialize(ByteProtocol protocol)
 {
     protocol.push((Int32)skillId);
     //    UnityEngine.Debug.LogError("push skillId" +(Int32)skillId);
     protocol.push(coolDownTime);
     protocol.push(animTime);
     protocol.push((byte)key);
     base.Serialize(protocol);
 }
Exemple #5
0
        protected void SendIninInfo(byte clientId)
        {
            ProtocolBase protocol = new ByteProtocol();

            protocol.push((byte)MessageType.Init);
            protocol.push(clientId);
            protocol.push((byte)MessageType.end);
            SendToClient(clientId, protocol.GetByteStream());
            ServerLog.LogClient("客户端连接成功:" + ClientPool[clientId].socket.LocalEndPoint + "ClientID:" + clientId, 0, clientId);
        }
Exemple #6
0
        protected void SendStepAll(object sender, ElapsedEventArgs e)
        {
            if (framSize <= 0)
            {
                return;
            }
            if (ClientPool.ActiveCount <= 0)
            {
                if (FrameList.Count > 0)
                {
                    ServerLog.LogServer("所有客户端退出游戏 战斗结束!!!", 1);
                    FrameList.Clear();
                }
                return;
            }

            if (FrameList.Count == 0)
            {
                ServerLog.LogServer("玩家进入服务器 战斗开始!!!", 1);
            }
            ServerLog.LogServer("0[" + FrameList.Count + "]", 1);

            byte[][]     temp     = StepMessage;
            int          length   = temp.Length;
            ProtocolBase protocol = new ByteProtocol();

            protocol.push((byte)MessageType.Frame);
            protocol.push((byte)length);
            //ServerLog.LogServer("获取[" + FrameList.Count + "]", 1);
            for (int i = 0; i < length; i++)
            {
                protocol.push(temp[i]);
            }
            ServerLog.LogServer("生成帧信息[" + length * temp[0].Length + "]", 1);
            byte[] temp2 = protocol.GetByteStream();

            FrameList.Add(temp2);

            ClientPool.Foreach((con) => { SendToClient(con.clientId, temp2);
                                          if (!con.ActiveCheck())
                                          {
                                              ServerLog.LogClient("客户端断线 中止连接:" + ClientPool[con.clientId].socket.LocalEndPoint + "ClientID:" + con.clientId, 0, con.clientId);

                                              con.socket.Close();
                                              ClientPool.Recover(con.clientId);
                                          }
                               });

            ServerLog.LogServer("帧同步[" + FrameList.Count + "]", 2);
            //StepMessage = new byte[ClientPool.Count][];
            //for (int i = 0; i < StepMessage.Length; i++)
            //{
            //    StepMessage[i] = new byte[framSize];
            //}
        }
Exemple #7
0
    public virtual void Serialize(ByteProtocol protocol)
    {
        protocol.push((Int32)intType);



        protocol.push(childNodes.Count);

        foreach (var node in childNodes)
        {
            node.Serialize(protocol);
        }
    }
Exemple #8
0
        /// <summary>
        /// 发送本地客户端帧信息
        /// </summary>
        protected void SendClientFrame(object sender, ElapsedEventArgs e)
        {
            if (client.ServerCon.clientId < 0)
            {
                return;
            }
            ProtocolBase protocol = new ByteProtocol();

            protocol.push((byte)MessageType.Frame);
            protocol.push((byte)client.ServerCon.clientId);

            foreach (var bt in sendKey.GetBytes())
            {
                protocol.push(bt);
            }



            protocol.push((byte)joySticks.Count);
            // Debug.LogError("len"+joySticks.Count);
            foreach (var joy in joySticks)
            {
                //  Debug.LogError("key"+joy.Key);
                protocol.push((byte)joy.Key);
                protocol.push(joy.Value.direction);
            }

            client.Send(protocol.GetByteStream());
        }
Exemple #9
0
 public override void Serialize(ByteProtocol protocol)
 {
     protocol.push(skillname);
     protocol.push(skillInfo);
     protocol.push(ObjToId(uiIcon));
     protocol.push(ObjToId(useOverAnim));
     protocol.push(useOverAnimSspeed.ToFixed());
     protocol.push(ObjToId(ItemPrefab));
 }
Exemple #10
0
 public virtual void Serialize(ByteProtocol protocol)
 {
     protocol.push((Int32)trigger);
     protocol.push((Int32)type);
     // UnityEngine.Debug.LogError("push type" +(Int32)type);
     protocol.push(nextNodes.Count);
     //  UnityEngine.Debug.LogError("nextNode Count" +nextNodes.Count);
     foreach (var node in nextNodes)
     {
         node.Serialize(protocol);
     }
     protocol.push(boolParams.Count);
     foreach (var b in boolParams)
     {
         protocol.push(b);
     }
     protocol.push(fixedParams.Count);
     foreach (var b in fixedParams)
     {
         protocol.push(b);
     }
 }
        protected void SendStepAll(object sender, ElapsedEventArgs e)
        {
            _durationTime += 100;
            if (_durationTime >= 20000)
            {
                //_battleEnd = true;
            }

            if (ClientPool.ActiveCount <= 0)
            {
                if (FrameList.Count > 0)
                {
                    ServerLog.LogServer("所有客户端退出游戏 战斗结束!!!", 1);
                    FrameList.Clear();
                }
                return;
            }

            if (FrameList.Count == 0)
            {
                ServerLog.LogServer("玩家进入服务器 战斗开始!!!", 1);
            }

            ServerLog.LogServer("0[" + FrameList.Count + "]", 1);

            byte[][]     temp     = StepMessage;
            int          length   = temp.Length;
            ProtocolBase protocol = new ByteProtocol();

            protocol.push((byte)MessageType.Frame);
            protocol.push((byte)length);
            //ServerLog.LogServer("获取[" + FrameList.Count + "]", 1);
            for (int i = 0; i < length; i++)
            {
                protocol.push(temp[i] != null);
                protocol.push(temp[i]);
            }

            if (FrameList.Count == 0)
            {
                protocol.push((byte)MessageType.RandomSeed);
                Random rand = new Random();
                protocol.push(rand.Next(10000));
            }

            if (_battleEnd == true)
            {
                protocol.push((byte)MessageType.BattleEnd);
            }

            protocol.push((byte)MessageType.end);
            ServerLog.LogServer("生成帧信息[" + length + "]", 1);
            byte[] temp2 = protocol.GetByteStream();

            FrameList.Add(temp2);

            ClientPool.Foreach((con) =>
            {
                SendToClient(con.clientId, temp2);
                if (!con.ActiveCheck())
                {
                    ServerLog.LogClient("客户端断线 中止连接:" + ClientPool[con.clientId].socket.LocalEndPoint + "ClientID:" + con.clientId, 0, con.clientId);
                    con.socket.Close();
                    ClientPool.Recover(con.clientId);
                }
            });

            if (_battleEnd == true)
            {
                ClientPool.Foreach((con) =>
                {
                    con.socket.Close();
                    ClientPool.Recover(con.clientId);
                });
            }

            ServerLog.LogServer("帧同步[" + FrameList.Count + "]", 2);
        }
Exemple #12
0
 public override void Serialize(ByteProtocol protocol)
 {
     protocol.push(name);
     base.Serialize(protocol);
 }