コード例 #1
0
        /// <summary>
        /// This method encodes an object of this class into a byte list
        /// </summary>
        /// <param name="bytes"></param>
        public override void Encode(ByteList bytes)
        {
            bytes.Add(ClassId);                             // Write out the class type

            Int16 lengthPos = bytes.CurrentWritePosition;   // Get the current write position, so we

            // can write the length here later

            bytes.Add((Int16)0);                            // Write out a place holder for the length

            bytes.AddObjects(Width, Height);                // Write out Width and Height
            Int16 SidewalkCount = (SidewalkSquares == null) ? (Int16)0 : Convert.ToInt16(SidewalkSquares.Count);

            bytes.Add(SidewalkCount);
            if (SidewalkSquares != null)
            {
                foreach (FieldLocation loc in SidewalkSquares)
                {
                    bytes.Add(loc);
                }
            }

            Int16 length = Convert.ToInt16(bytes.CurrentWritePosition - lengthPos - 2);

            bytes.WriteInt16To(lengthPos, length);          // Write out the length of this object
        }
コード例 #2
0
        /// <summary>
        /// This method encodes an object of this class into a byte list
        /// </summary>
        /// <param name="bytes"></param>
        public override void Encode(ByteList bytes)
        {
            bytes.Add(ClassId);                             // Write out the class type

            Int16 lengthPos = bytes.CurrentWritePosition;   // Get the current write position, so we

            // can write the length here later

            bytes.Add((Int16)0);                            // Write out a place holder for the length

            bytes.AddObjects(
                PlayingFieldWidth,
                PlayingFieldHeight,

                BrilliantStudentRegistrationMin,
                BrilliantStudentRegistrationMax,
                BrilliantStudentInitialStrength,
                BrilliantStudentBaseSpeed,
                BrilliantStudentSidewalkSpeedMultiplier,
                BrilliantStudentDeathToZombieDelay,

                ExcuseGeneratorRegistrationMin,
                ExcuseGeneratorRegistrationMax,
                ExcuseGeneratorInitialStrength,
                NumberOfTicksRequiredToBuildAnExcuse,

                WhiningSpinnerRegistrationMin,
                WhiningSpinnerRegistrationMax,
                WhiningSpinnerInitialStrength,
                NumberOfTicksRequiredToBuildTwine,

                ZombieInitialStrengthMin,
                ZombieInitialStrengthMax,
                ZombieInitialSpeedMax,
                ZombieInitialSpeedMin,
                ZombieSidewalkSpeedMultiplier,
                ZombieCreationRate,
                ZombieCreationAcceleration,
                ZombieEatingRate,
                ZombieStrengthIncreaseForEatingStudent,
                ZombieStrengthIncreaseForExcuseGenerator,
                ZombieStrengthIncreaseForWhiningSpinner,
                MinEatingDistance,
                MaxEatingDistance,

                RefereeRegistrationMin,
                RefereeRegistrationMax,

                BombExcuseDamage,
                BombTwinePerSquareOfDistance,
                BombDamageDiffusionFactor,

                TickInterval,
                TickLifetime,
                TicksToStrengthRatio);

            Int16 length = Convert.ToInt16(bytes.CurrentWritePosition - lengthPos - 2);

            bytes.WriteInt16To(lengthPos, length);          // Write out the length of this object
        }
コード例 #3
0
ファイル: Tick.cs プロジェクト: alfy32/USU_CS5200_SP14_BSvsZP
        /// <summary>
        /// This method encodes an object of this class into a byte list
        /// </summary>
        /// <param name="bytes"></param>
        public override void Encode(ByteList bytes)
        {
            bytes.Add(ClassId);                             // Write out the class type

            Int16 lengthPos = bytes.CurrentWritePosition;   // Get the current write position, so we

            // can write the length here later

            bytes.Add((Int16)0);                                  // Write out a place holder for the length

            bytes.AddObjects(ForAgentId, LogicalClock, HashCode); // Write out Address and Port

            Int16 length = Convert.ToInt16(bytes.CurrentWritePosition - lengthPos - 2);

            bytes.WriteInt16To(lengthPos, length);          // Write out the length of this object
        }
コード例 #4
0
        /// <summary>
        /// This method encodes an object of this class into a byte list
        /// </summary>
        /// <param name="bytes"></param>
        public override void Encode(ByteList bytes)
        {
            bytes.Add(ClassId);                             // Write out the class type

            Int16 lengthPos = bytes.CurrentWritePosition;   // Get the current write position, so we

            // can write the length here later

            bytes.Add((Int16)0);                            // Write out a place holder for the length

            bytes.AddObjects(Id, CommunicationEndPoint);

            Int16 length = Convert.ToInt16(bytes.CurrentWritePosition - lengthPos - 2);

            bytes.WriteInt16To(lengthPos, length);          // Write out the length of this object
        }
コード例 #5
0
        /// <summary>
        /// This method encodes an object of this class into a byte list
        /// </summary>
        /// <param name="bytes"></param>
        public override void Encode(ByteList bytes)
        {
            bytes.Add(ClassId);                             // Write out the class type

            Int16 lengthPos = bytes.CurrentWritePosition;   // Get the current write position, so we

            // can write the length here later

            bytes.Add((Int16)0);                            // Write out a place holder for the length

            base.Encode(bytes);

            if (ANumber == null)
            {
                ANumber = string.Empty;
            }
            if (FirstName == null)
            {
                FirstName = string.Empty;
            }
            if (LastName == null)
            {
                LastName = string.Empty;
            }

            bytes.AddObjects((byte)AgentType,
                             (byte)AgentStatus,
                             ANumber,
                             FirstName,
                             LastName,
                             Strength,
                             Speed,
                             Points,
                             Location);

            Int16 length = Convert.ToInt16(bytes.CurrentWritePosition - lengthPos - 2);

            bytes.WriteInt16To(lengthPos, length);          // Write out the length of this object
        }
コード例 #6
0
        public override void Encode(ByteList bytes)
        {
            bytes.Add(ClassId);                              // Write out this class id first

            Int16 lengthPos = bytes.CurrentWritePosition;    // Get the current write position, so we
                                                                    // can write the length here later
            bytes.Add((Int16)0);                             // Write out a place holder for the length

            base.Encode(bytes);                              // Encode the part of the object defined
                                                             // by the base class

            bytes.AddObjects(ThrowingBrilliantStudentId, Bomb, TowardsSquare, EnablingTick);

            Int16 length = Convert.ToInt16(bytes.CurrentWritePosition - lengthPos - 2);
            bytes.WriteInt16To(lengthPos, length);           // Write out the length of this object
        }
コード例 #7
0
        /// <summary>
        /// This method encodes
        /// </summary>
        /// <param name="bytes"></param>
        public virtual void Encode(ByteList bytes)
        {
            bytes.Add(ClassId);                            // Write out the class type

            Int16 lengthPos = bytes.CurrentWritePosition;    // Get the current write position, so we
                                                                    // can write the length here later

            bytes.Add((Int16) 0);                            // Write out a place holder for the length

            bytes.AddObjects(MessageNr, ConversationId);

            Int16 length = Convert.ToInt16(bytes.CurrentWritePosition - lengthPos - 2);
            bytes.WriteInt16To(lengthPos, length);           // Write out the length of this object
        }
コード例 #8
0
        /// <summary>
        /// This method encodes an object of this class into a byte list
        /// </summary>
        /// <param name="bytes"></param>
        public override void Encode(ByteList bytes)
        {
            bytes.Add(ClassId);                             // Write out the class type

            Int16 lengthPos = bytes.CurrentWritePosition;   // Get the current write position, so we
                                                            // can write the length here later

            bytes.Add((Int16) 0);                           // Write out a place holder for the length

            bytes.AddObjects(
                            PlayingFieldWidth,
                            PlayingFieldHeight,

                            BrilliantStudentRegistrationMin,
                            BrilliantStudentRegistrationMax,
                            BrilliantStudentInitialStrength,
                            BrilliantStudentBaseSpeed,
                            BrilliantStudentSidewalkSpeedMultiplier,
                            BrilliantStudentDeathToZombieDelay,

                            ExcuseGeneratorRegistrationMin,
                            ExcuseGeneratorRegistrationMax,
                            ExcuseGeneratorInitialStrength,
                            NumberOfTicksRequiredToBuildAnExcuse,

                            WhiningSpinnerRegistrationMin,
                            WhiningSpinnerRegistrationMax,
                            WhiningSpinnerInitialStrength,
                            NumberOfTicksRequiredToBuildTwine,

                            ZombieInitialStrengthMin,
                            ZombieInitialStrengthMax,
                            ZombieInitialSpeedMax,
                            ZombieInitialSpeedMin,
                            ZombieSidewalkSpeedMultiplier,
                            ZombieCreationRate,
                            ZombieCreationAcceleration,
                            ZombieEatingRate,
                            ZombieStrengthIncreaseForEatingStudent,
                            ZombieStrengthIncreaseForExcuseGenerator,
                            ZombieStrengthIncreaseForWhiningSpinner,
                            MinEatingDistance,
                            MaxEatingDistance,

                            RefereeRegistrationMin,
                            RefereeRegistrationMax,

                            BombExcuseDamage,
                            BombTwinePerSquareOfDistance,
                            BombDamageDiffusionFactor,

                            TickInterval,
                            TickLifetime,
                            TicksToStrengthRatio);

            Int16 length = Convert.ToInt16(bytes.CurrentWritePosition - lengthPos - 2);
            bytes.WriteInt16To(lengthPos, length);          // Write out the length of this object
        }
コード例 #9
0
        public override void Encode(ByteList bytes)
        {
            bytes.Add(ClassId);                              // Write out this class id first

            Int16 lengthPos = bytes.CurrentWritePosition;    // Get the current write position, so we
                                                                    // can write the length here later
            bytes.Add((Int16)0);                             // Write out a place holder for the length

            base.Encode(bytes);                              // Encode the part of the object defined
                                                                    // by the base class
            bytes.AddObjects(ComponentId, TickToValidate);

            Int16 length = Convert.ToInt16(bytes.CurrentWritePosition - lengthPos - 2);
            bytes.WriteInt16To(lengthPos, length);           // Write out the length of this object
        }
コード例 #10
0
        /// <summary>
        /// This method encodes an object of this class into a byte list
        /// </summary>
        /// <param name="bytes"></param>
        public override void Encode(ByteList bytes)
        {
            bytes.Add(ClassId);                             // Write out the class type

            Int16 lengthPos = bytes.CurrentWritePosition;   // Get the current write position, so we
                                                            // can write the length here later

            bytes.Add((Int16) 0);                           // Write out a place holder for the length

            bytes.AddObjects(X, Y, Immutable);              // Write out X, Y, and Immutable properties

            Int16 length = Convert.ToInt16(bytes.CurrentWritePosition - lengthPos - 2);
            bytes.WriteInt16To(lengthPos, length);          // Write out the length of this object
        }
コード例 #11
0
        /// <summary>
        /// This method encodes an object of this class into a byte list
        /// </summary>
        /// <param name="bytes"></param>
        public override void Encode(ByteList bytes)
        {
            bytes.Add(ClassId);                             // Write out the class type

            Int16 lengthPos = bytes.CurrentWritePosition;   // Get the current write position, so we
                                                            // can write the length here later

            bytes.Add((Int16) 0);                           // Write out a place holder for the length

            bytes.AddObjects(ForAgentId, LogicalClock, HashCode);       // Write out Address and Port

            Int16 length = Convert.ToInt16(bytes.CurrentWritePosition - lengthPos - 2);
            bytes.WriteInt16To(lengthPos, length);          // Write out the length of this object
        }
コード例 #12
0
        /// <summary>
        /// This method encodes an object of this class into a byte list
        /// </summary>
        /// <param name="bytes"></param>
        public override void Encode(ByteList bytes)
        {
            bytes.Add(ClassId);                             // Write out the class type

            Int16 lengthPos = bytes.CurrentWritePosition;   // Get the current write position, so we
                                                            // can write the length here later

            bytes.Add((Int16) 0);                           // Write out a place holder for the length

            base.Encode(bytes);

            if (ANumber == null)
                ANumber = string.Empty;
            if (FirstName == null)
                FirstName = string.Empty;
            if (LastName == null)
                LastName = string.Empty;

            bytes.AddObjects(   (byte) AgentType,
                                (byte) AgentStatus,
                                ANumber,
                                FirstName,
                                LastName,
                                Strength,
                                Speed,
                                Points,
                                Location);

            Int16 length = Convert.ToInt16(bytes.CurrentWritePosition - lengthPos - 2);
            bytes.WriteInt16To(lengthPos, length);          // Write out the length of this object
        }
コード例 #13
0
        public override void Encode(ByteList bytes)
        {
            bytes.Add(ClassId);                           // Write out this class id first

            Int16 lengthPos = bytes.CurrentWritePosition;   // Get the current write position, so we
                                                                // can write the length here later
            bytes.Add((Int16) 0);                           // Write out a place holder for the length

            base.Encode(bytes);                             // Encode stuff from base class

            if (Message == null) Message = string.Empty;
            bytes.AddObjects(IntResult, ObjResult, Message);

            Int16 length = Convert.ToInt16(bytes.CurrentWritePosition - lengthPos - 2);
            bytes.WriteInt16To(lengthPos, length);          // Write out the length of this object
        }
コード例 #14
0
        /// <summary>
        /// This method encodes an object of this class into a byte list
        /// </summary>
        /// <param name="bytes"></param>
        public override void Encode(ByteList bytes)
        {
            bytes.Add(ClassId);                             // Write out the class type

            Int16 lengthPos = bytes.CurrentWritePosition;   // Get the current write position, so we
                                                            // can write the length here later

            bytes.Add((Int16) 0);                           // Write out a place holder for the length

            bytes.AddObjects(Width, Height);                // Write out Width and Height
            Int16 SidewalkCount = (SidewalkSquares == null) ? (Int16) 0 : Convert.ToInt16(SidewalkSquares.Count);
            bytes.Add(SidewalkCount);
            if (SidewalkSquares!=null)
                foreach (FieldLocation loc in SidewalkSquares)
                    bytes.Add(loc);

            Int16 length = Convert.ToInt16(bytes.CurrentWritePosition - lengthPos - 2);
            bytes.WriteInt16To(lengthPos, length);          // Write out the length of this object
        }