Beispiel #1
0
        public static byte[] PackMessage(int msgType, MessageBase msg)
        {
            NetworkWriter writer = NetworkWriterPool.GetWriter();

            try
            {
                // write message type
                writer.WriteInt16((short)msgType);

                // serialize message into writer
                msg.Serialize(writer);

                // return byte[]
                return(writer.ToArray());
            }
            finally
            {
                NetworkWriterPool.Recycle(writer);
            }
        }
Beispiel #2
0
 public void Serialize(NetworkWriter writer)
 {
     writer.WriteInt16(command);
     writer.WriteInt32(connectionId);
     playerData.Serialize(writer);
 }
        public static void WriteCharacter(this NetworkWriter writer, Character character)
        {
            writer.WriteVector2(character.grid_Position);
            writer.WriteVector2(character.future_Position);
            writer.WriteInt16(character.gold_Cost);
            writer.WriteInt16(character.level);
            writer.WriteInt16(character.mana);
            writer.WriteInt16(character.max_Mana);
            writer.WriteInt16(character.base_Mana);
            writer.WriteInt16(character.attack_Damage);
            writer.WriteInt16(character.spell_Power);
            writer.WriteDouble(character.attack_Speed);
            writer.WriteInt16(character.maxHealth);
            writer.WriteInt16(character.armor);
            writer.WriteInt16(character.magic_Resistance);
            writer.WriteInt16(character.range);
            writer.WriteInt16(character.ID);

            writer.WriteDouble(character.attack_Timer);
        }