Beispiel #1
0
        /// <summary>
        /// Tests whether this object is equal to the argument.
        /// </summary>
        /// <param name="obj">The object to test for equality.</param>
        /// <returns>True if this object is equal to the argument, false otherwise.</returns>
        public override bool Equals(object obj)
        {
            if (obj == null || obj.GetType() != this.GetType())
            {
                return(false);
            }

            LevelUpdate that = obj as LevelUpdate;

            return(this.NextLevelIndex == that.NextLevelIndex &&
                   this.Size == that.Size);
        }
Beispiel #2
0
        /// <summary>
        /// Writes the given <see cref="LevelUpdate"/> to a byte array.
        /// </summary>
        /// <param name="update">The <see cref="LevelUpdate"/>, not null.</param>
        /// <returns>A byte array containing the data from the <see cref="LevelUpdate"/>.</returns>
        public static byte[] WriteLevelUpdate(LevelUpdate update)
        {
            if (update == null)
            {
                throw new ArgumentNullException("update");
            }

            byte[] message = new byte[13];

            message[0] = (byte)UpdateType.UpdateLevel;
            WriteInt32(update.NextLevelIndex, message, 1);
            WriteSingle(update.Size.x, message, 5);
            WriteSingle(update.Size.y, message, 9);
            return(message);
        }
Beispiel #3
0
 /// <summary>
 /// Called whenever one local player manages to complete the level.
 /// </summary>
 /// <param name="update">The LevelUpdate describing the change.</param>
 public void OnLevelCompleted(LevelUpdate update)
 {
     this.socket.Send(MessageProcessor.WriteLevelUpdate(update));
 }