コード例 #1
0
        public override byte[] Serialize()
        {
            List <byte> s = new List <byte>();

            // serialize Id
            s.Add((byte)((Id == null) ? 0 : 1));
            if (Id != null)
            {
                s.AddRange(BitConverter.GetBytes((int)Id));
            }

            // serialize Position
            s.Add((byte)((Position == null) ? 0 : 1));
            if (Position != null)
            {
                s.AddRange(Position.Serialize());
            }

            // serialize PlantingRemainingTime
            s.Add((byte)((PlantingRemainingTime == null) ? 0 : 1));
            if (PlantingRemainingTime != null)
            {
                s.AddRange(BitConverter.GetBytes((int)PlantingRemainingTime));
            }

            // serialize FootstepSounds
            s.Add((byte)((FootstepSounds == null) ? 0 : 1));
            if (FootstepSounds != null)
            {
                List <byte> tmp33 = new List <byte>();
                tmp33.AddRange(BitConverter.GetBytes((uint)FootstepSounds.Count()));
                while (tmp33.Count > 0 && tmp33.Last() == 0)
                {
                    tmp33.RemoveAt(tmp33.Count - 1);
                }
                s.Add((byte)tmp33.Count);
                s.AddRange(tmp33);

                foreach (var tmp34 in FootstepSounds)
                {
                    s.Add((byte)((tmp34 == null) ? 0 : 1));
                    if (tmp34 != null)
                    {
                        s.Add((byte)((sbyte)tmp34));
                    }
                }
            }

            // serialize Status
            s.Add((byte)((Status == null) ? 0 : 1));
            if (Status != null)
            {
                s.Add((byte)((sbyte)Status));
            }

            return(s.ToArray());
        }
コード例 #2
0
        public override byte[] Serialize()
        {
            List <byte> s = new List <byte>();

            // serialize Id
            s.Add((byte)((Id == null) ? 0 : 1));
            if (Id != null)
            {
                s.AddRange(BitConverter.GetBytes((int)Id));
            }

            // serialize Position
            s.Add((byte)((Position == null) ? 0 : 1));
            if (Position != null)
            {
                s.AddRange(Position.Serialize());
            }

            // serialize DefusionRemainingTime
            s.Add((byte)((DefusionRemainingTime == null) ? 0 : 1));
            if (DefusionRemainingTime != null)
            {
                s.AddRange(BitConverter.GetBytes((int)DefusionRemainingTime));
            }

            // serialize FootstepSounds
            s.Add((byte)((FootstepSounds == null) ? 0 : 1));
            if (FootstepSounds != null)
            {
                List <byte> tmp48 = new List <byte>();
                tmp48.AddRange(BitConverter.GetBytes((uint)FootstepSounds.Count()));
                while (tmp48.Count > 0 && tmp48.Last() == 0)
                {
                    tmp48.RemoveAt(tmp48.Count - 1);
                }
                s.Add((byte)tmp48.Count);
                s.AddRange(tmp48);

                foreach (var tmp49 in FootstepSounds)
                {
                    s.Add((byte)((tmp49 == null) ? 0 : 1));
                    if (tmp49 != null)
                    {
                        s.Add((byte)((sbyte)tmp49));
                    }
                }
            }

            // serialize BombSounds
            s.Add((byte)((BombSounds == null) ? 0 : 1));
            if (BombSounds != null)
            {
                List <byte> tmp50 = new List <byte>();
                tmp50.AddRange(BitConverter.GetBytes((uint)BombSounds.Count()));
                while (tmp50.Count > 0 && tmp50.Last() == 0)
                {
                    tmp50.RemoveAt(tmp50.Count - 1);
                }
                s.Add((byte)tmp50.Count);
                s.AddRange(tmp50);

                foreach (var tmp51 in BombSounds)
                {
                    s.Add((byte)((tmp51 == null) ? 0 : 1));
                    if (tmp51 != null)
                    {
                        s.Add((byte)((sbyte)tmp51));
                    }
                }
            }

            // serialize Status
            s.Add((byte)((Status == null) ? 0 : 1));
            if (Status != null)
            {
                s.Add((byte)((sbyte)Status));
            }

            return(s.ToArray());
        }