Advertisement
PsyOps

PlayerUpdatePacket.cs

Mar 15th, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.42 KB | None | 0 0
  1. //-----------------------------------------------------------------------
  2. //
  3. // NAME:        PlayerUpdatePacket.cs
  4. //
  5. // PROJECT:     Battle Core Protocol Library
  6. //
  7. // COMPILER:    Microsoft Visual Studio .NET 2005
  8. //
  9. // DESCRIPTION: Player Update Packet implementation.
  10. //
  11. // NOTES:       None.
  12. //
  13. // $History: PlayerUpdatePacket.cs $
  14. //
  15. //-----------------------------------------------------------------------
  16.  
  17. // Namespace usage
  18. using System;
  19. using System.Collections.Generic;
  20. using System.Text;
  21. using System.IO;
  22. using BattleCore.Events;
  23.  
  24. // Namespace declaration
  25. namespace BattleCore.Protocol
  26. {
  27.    /// <summary>
  28.    /// PlayerUpdatePacket Object.  This packet is received when the
  29.    /// player ship and frequency information is updated is set.
  30.    /// </summary>
  31.    internal class PlayerUpdatePacket : IPacket
  32.    {
  33.       private ShipChangeEvent m_shipEvent = new ShipChangeEvent();
  34.       private TeamChangeEvent m_teamEvent = new TeamChangeEvent();
  35.  
  36.       ///<summary>Reliable Packet Property</summary>
  37.       public Boolean Reliable { get { return false; } }
  38.  
  39.       /// <summary>
  40.       /// Ship Change Event Property
  41.       /// </summary>
  42.       public ShipChangeEvent ShipEvent
  43.       {
  44.          set { m_shipEvent = value; }
  45.          get { return m_shipEvent; }
  46.       }
  47.  
  48.       /// <summary>
  49.       /// Team Change Event Property
  50.       /// </summary>
  51.       public TeamChangeEvent TeamEvent
  52.       {
  53.          set { m_teamEvent = value; }
  54.          get { return m_teamEvent; }
  55.       }
  56.  
  57.       /// <summary>
  58.       /// Packet Data Property
  59.       /// </summary>
  60.       public Byte[] Packet
  61.       {
  62.          set
  63.          {
  64.             if (value[0] == 0x0D)
  65.             {
  66.                m_teamEvent.PlayerId = BitConverter.ToUInt16 (value, 1);
  67.                m_teamEvent.Frequency = BitConverter.ToUInt16 (value, 3);
  68.                m_shipEvent.ShipType = (ShipTypes)value[5];
  69.             }
  70.             else if (value[0] == 0x1D)
  71.             {
  72.                m_shipEvent.ShipType = (ShipTypes)value[1];
  73.                m_teamEvent.PlayerId = BitConverter.ToUInt16 (value, 2);
  74.                m_teamEvent.Frequency = BitConverter.ToUInt16 (value, 4);
  75.             }
  76.  
  77.             // Set the ship event player identifier
  78.             m_shipEvent.PlayerId = m_teamEvent.PlayerId;
  79.          }
  80.          get
  81.          {
  82.             // return a new Byte
  83.             return new Byte[1];
  84.          }
  85.       }
  86.    }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement