Example #1
0
        static public byte[] Serialize(BasePlayerAction state)
        {
            byte[] bytes = new byte[OneObjectSize];

            bytes[0] = (byte)state.actionType;
            Array.Copy(BitConverter.GetBytes(state.newAngle), 0, bytes, 1, 2);

            return(bytes);
        }
Example #2
0
        static public BasePlayerAction Deserialize(byte[] bytes)
        {
            if (bytes.Length != OneObjectSize)
            {
                throw new ApplicationException("Wrong byte[] size in static public BasePlayerAction Deserialize(byte[] bytes);");
            }

            var state = new BasePlayerAction((PlayerActionType)bytes[0]);

            state.newAngle = BitConverter.ToInt16(bytes, 1);

            return(state);
        }