Esempio n. 1
0
 protected Item(string id, byte type, Game game)
 {
     this.id = id;
     this.game = game;
     this.type = type;
     this.visibleInterestAreas = new List<byte>();
     this.subscribedInterestAreas = new List<byte>();
 }
Esempio n. 2
0
 public Item(Game game, string id, ItemType type, bool isMine = false)
 {
     this.game = game;
     this.id = id;
     this.type = type;
     this.isMine = isMine;
     this.subscribedInterestAreas = new List<byte>();
 }
Esempio n. 3
0
 public static void CreateWorld(Game game, string worldName, BoundingBox boundingBox, Vector tileDimensions)
 {
     var data = new Dictionary<byte, object>
         {
             { (byte)ParameterCode.WorldName, worldName },
             { (byte)ParameterCode.BoundingBox, boundingBox },
             { (byte)ParameterCode.TileDimensions, tileDimensions }
         };
     game.SendOperation(OperationCode.CreateWorld, data, true, Settings.OperationChannel);
 }
Esempio n. 4
0
        public static void AttachInterestArea(Game game, string itemId)
        {
            var data = new Dictionary<byte, object>();

            if (!string.IsNullOrEmpty(itemId))
            {
                data.Add((byte)ParameterCode.ItemId, itemId);
            }

            game.SendOperation(OperationCode.AttachInterestArea, data, true, Settings.ItemChannel);
        }
Esempio n. 5
0
 public MyItem(Game game, string id, ItemType type, string text)
     : base(game, id, type, true)
 {
     var r = new Random(Guid.NewGuid().GetHashCode());
     const int b0 = 127;
     var c1 = (uint)r.Next(b0, 256);
     var c2 = (uint)r.Next(b0, 256);
     var c3 = (uint)r.Next(b0, 256);
     base.SetColor((int)(((c1 << 16) + (c2 << 8) + c3) | 0xFF000000));
     base.SetText(text);
 }
Esempio n. 6
0
        /// <summary>
        /// The add interest area.
        /// </summary>
        /// <param name="game">
        /// The mmo game.
        /// </param>
        /// <param name="cameraId">
        /// The camera id.
        /// </param>
        /// <param name="position">
        /// The position.
        /// </param>
        /// <param name="viewDistanceEnter">
        /// The view distance enter.
        /// </param>
        /// <param name="viewDistanceExit">
        /// The view distance exit.
        /// </param>
        public static void AddInterestArea(Game game, byte cameraId, float[] position, float[] viewDistanceEnter, float[] viewDistanceExit)
        {
            var data = new Dictionary<byte, object>
                {
                    { (byte)ParameterCode.InterestAreaId, cameraId }, 
                    { (byte)ParameterCode.ViewDistanceEnter, viewDistanceEnter }, 
                    { (byte)ParameterCode.ViewDistanceExit, viewDistanceExit }, 
                    { (byte)ParameterCode.Position, position }
                };

            game.SendOperation(OperationCode.AddInterestArea, data, true, Settings.ItemChannel);
        }
Esempio n. 7
0
        public static void EnterWorld(
            Game game, string worldName, string username, Hashtable properties, Vector position, Vector rotation, Vector viewDistanceEnter, Vector viewDistanceExit)
        {
            var data = new Dictionary<byte, object>
                {
                    { (byte)ParameterCode.WorldName, worldName },
                    { (byte)ParameterCode.Username, username },
                    { (byte)ParameterCode.Position, position },
                    { (byte)ParameterCode.ViewDistanceEnter, viewDistanceEnter },
                    { (byte)ParameterCode.ViewDistanceExit, viewDistanceExit }
                };
            if (properties != null)
            {
                data.Add((byte)ParameterCode.Properties, properties);
            }

            if (!rotation.IsZero)
            {
                data.Add((byte)ParameterCode.Rotation, rotation);
            }

            game.SendOperation(OperationCode.EnterWorld, data, true, Settings.OperationChannel);
        }
Esempio n. 8
0
        /// <summary>
        /// The move camera.
        /// </summary>
        /// <param name="game">
        /// The mmo game.
        /// </param>
        /// <param name="cameraId">
        /// The camera id.
        /// </param>
        /// <param name="position">
        /// The position.
        /// </param>
        public static void MoveInterestArea(Game game, byte cameraId, float[] position)
        {
            var data = new Dictionary<byte, object> { { (byte)ParameterCode.InterestAreaId, cameraId }, { (byte)ParameterCode.Position, position } };

            game.SendOperation(OperationCode.MoveInterestArea, data, true, Settings.ItemChannel);
        }
Esempio n. 9
0
        /// <summary>
        /// The move operation.
        /// </summary>
        /// <param name="game">
        /// The mmo game.
        /// </param>
        /// <param name="itemId">
        /// The item id.
        /// </param>
        /// <param name="itemType">
        /// The item type.
        /// </param>
        /// <param name="position">
        /// The position.
        /// </param>
        /// <param name="rotation">
        /// The rotation.
        /// </param>
        /// <param name="sendReliable">
        /// The send Reliable.
        /// </param>
        public static void Move(Game game, string itemId, byte? itemType, float[] position, float[] rotation, bool sendReliable)
        {
            var data = new Dictionary<byte, object> { { (byte)ParameterCode.Position, position } };
            if (itemId != null)
            {
                data.Add((byte)ParameterCode.ItemId, itemId);
            }

            if (itemType.HasValue)
            {
                data.Add((byte)ParameterCode.ItemType, itemType.Value);
            }

            if (rotation != null)
            {
                data.Add((byte)ParameterCode.Rotation, rotation);
            }

            game.SendOperation(OperationCode.Move, data, sendReliable, Settings.ItemChannel);
        }
Esempio n. 10
0
 public InterestArea(byte cameraId, Game game, MyItem avatar)
     : this(cameraId, game, avatar.Position)
 {
     this.AttachedItem = avatar;
     avatar.Moved += this.OnItemMoved;
 }
Esempio n. 11
0
        /// <summary>
        /// The subscribe item.
        /// </summary>
        /// <param name="game">
        /// The mmo game.
        /// </param>
        /// <param name="itemId">
        /// The item id.
        /// </param>
        /// <param name="itemType">
        /// The item type.
        /// </param>
        /// <param name="propertiesRevision">
        /// The properties revision.
        /// </param>
        public static void SubscribeItem(Game game, string itemId, byte itemType, int? propertiesRevision)
        {
            var data = new Dictionary<byte, object> { { (byte)ParameterCode.ItemId, itemId }, { (byte)ParameterCode.ItemType, itemType } };
            if (propertiesRevision.HasValue)
            {
                data.Add((byte)ParameterCode.PropertiesRevision, propertiesRevision);
            }

            game.SendOperation(OperationCode.SubscribeItem, data, true, Settings.ItemChannel);
        }
Esempio n. 12
0
 /// <summary>
 /// The set view distance.
 /// </summary>
 /// <param name="game">
 /// The mmo game.
 /// </param>
 /// <param name="viewDistanceEnter">
 /// The view Distance Enter.
 /// </param>
 /// <param name="viewDistanceExit">
 /// The view Distance Exit.
 /// </param>
 public static void SetViewDistance(Game game, float[] viewDistanceEnter, float[] viewDistanceExit)
 {
     var data = new Dictionary<byte, object>
         {
             { (byte)ParameterCode.ViewDistanceEnter, viewDistanceEnter }, { (byte)ParameterCode.ViewDistanceExit, viewDistanceExit } 
         };
     game.SendOperation(OperationCode.SetViewDistance, data, true, Settings.ItemChannel);
 }
Esempio n. 13
0
 public static void DestroyItem(Game game, string itemId)
 {
     var data = new Dictionary<byte, object> { { (byte)ParameterCode.ItemId, itemId } };
     game.SendOperation(OperationCode.DestroyItem, data, true, Settings.ItemChannel);
 }
Esempio n. 14
0
        public static void Move(Game game, string itemId, Vector position, Vector rotation, bool sendReliable)
        {
            var data = new Dictionary<byte, object> { { (byte)ParameterCode.Position, position } };
            if (itemId != null)
            {
                data.Add((byte)ParameterCode.ItemId, itemId);
            }

            if (!rotation.IsZero)
            {
                data.Add((byte)ParameterCode.Rotation, rotation);
            }

            game.SendOperation(OperationCode.Move, data, sendReliable, Settings.ItemChannel);
        }
Esempio n. 15
0
        public static void GetProperties(Game game, string itemId, int? knownRevision)
        {
            var data = new Dictionary<byte, object> { { (byte)ParameterCode.ItemId, itemId } };
            if (knownRevision.HasValue)
            {
                data.Add((byte)ParameterCode.PropertiesRevision, knownRevision.Value);
            }

            game.SendOperation(OperationCode.GetProperties, data, true, Settings.ItemChannel);
        }
Esempio n. 16
0
        /// <summary>
        /// The raise generic event.
        /// </summary>
        /// <param name="game">
        /// The mmo game.
        /// </param>
        /// <param name="itemId">
        /// The item id.
        /// </param>
        /// <param name="itemType">
        /// The item type.
        /// </param>
        /// <param name="customEventCode">
        /// The custom event code.
        /// </param>
        /// <param name="eventData">
        /// The event data.
        /// </param>
        /// <param name="eventReliability">
        /// The event reliability.
        /// </param>
        /// <param name="eventReceiver">
        /// The event receiver.
        /// </param>
        public static void RaiseGenericEvent(
            Game game, string itemId, byte? itemType, byte customEventCode, object eventData, byte eventReliability, EventReceiver eventReceiver)
        {
            var data = new Dictionary<byte, object>
                {
                    { (byte)ParameterCode.CustomEventCode, customEventCode }, 
                    { (byte)ParameterCode.EventReliability, eventReliability }, 
                    { (byte)ParameterCode.EventReceiver, (byte)eventReceiver }
                };

            if (eventData != null)
            {
                data.Add((byte)ParameterCode.EventData, eventData);
            }

            if (itemId != null)
            {
                data.Add((byte)ParameterCode.ItemId, itemId);
            }

            if (itemType.HasValue)
            {
                data.Add((byte)ParameterCode.ItemType, itemType.Value);
            }

            game.SendOperation(OperationCode.RaiseGenericEvent, data, true, Settings.ItemChannel);
        }
Esempio n. 17
0
        /// <summary>
        /// The remove interest area.
        /// </summary>
        /// <param name="game">
        /// The mmo game.
        /// </param>
        /// <param name="cameraId">
        /// The camera id.
        /// </param>
        public static void RemoveInterestArea(Game game, byte cameraId)
        {
            var data = new Dictionary<byte, object> { { (byte)ParameterCode.InterestAreaId, cameraId } };

            game.SendOperation(OperationCode.RemoveInterestArea, data, true, Settings.ItemChannel);
        }
Esempio n. 18
0
 public ForeignItem(string id, byte type, Game game)
     : base(id, type, game)
 {
 }
Esempio n. 19
0
        /// <summary>
        /// The set properties.
        /// </summary>
        /// <param name="game">
        /// The mmo game.
        /// </param>
        /// <param name="itemId">
        /// The item id.
        /// </param>
        /// <param name="itemType">
        /// The item type.
        /// </param>
        /// <param name="propertiesSet">
        /// The properties set.
        /// </param>
        /// <param name="propertiesUnset">
        /// The properties unset.
        /// </param>
        /// <param name="sendReliable">
        /// The send Reliable.
        /// </param>
        public static void SetProperties(Game game, string itemId, byte? itemType, Hashtable propertiesSet, ArrayList propertiesUnset, bool sendReliable)
        {
            var data = new Dictionary<byte, object>();
            if (propertiesSet != null)
            {
                data.Add((byte)ParameterCode.PropertiesSet, propertiesSet);
            }

            if (propertiesUnset != null)
            {
                data.Add((byte)ParameterCode.PropertiesUnset, propertiesUnset);
            }

            if (itemId != null)
            {
                data.Add((byte)ParameterCode.ItemId, itemId);
            }

            if (itemType.HasValue)
            {
                data.Add((byte)ParameterCode.ItemType, itemType.Value);
            }

            game.SendOperation(OperationCode.SetProperties, data, sendReliable, Settings.ItemChannel);
        }
Esempio n. 20
0
 public MyItem(string id, byte type, Game game, string text)
     : base(id, type, game)
 {
     base.SetColor((int)((uint)new Random(Guid.NewGuid().GetHashCode()).Next(0, int.MaxValue) | 0xFF000000));
     base.SetText(text);
 }
Esempio n. 21
0
        /// <summary>
        /// The spawn item.
        /// </summary>
        /// <param name="game">
        /// The mmo game.
        /// </param>
        /// <param name="itemId">
        /// The item id.
        /// </param>
        /// <param name="itemType">
        /// The item type.
        /// </param>
        /// <param name="position">
        /// The position.
        /// </param>
        /// <param name="rotation">
        /// The rotation.
        /// </param>
        /// <param name="properties">
        /// The properties.
        /// </param>
        /// <param name="subscribe">
        /// The subscribe.
        /// </param>
        public static void SpawnItem(Game game, string itemId, byte itemType, float[] position, float[] rotation, Hashtable properties, bool subscribe)
        {
            var data = new Dictionary<byte, object>
                {
                    { (byte)ParameterCode.Position, position }, 
                    { (byte)ParameterCode.ItemId, itemId }, 
                    { (byte)ParameterCode.ItemType, itemType }, 
                    { (byte)ParameterCode.Subscribe, subscribe }
                };
            if (properties != null)
            {
                data.Add((byte)ParameterCode.Properties, properties);
            }

            if (rotation != null)
            {
                data.Add((byte)ParameterCode.Rotation, rotation);
            }

            game.SendOperation(OperationCode.SpawnItem, data, true, Settings.ItemChannel);
        }
Esempio n. 22
0
 /// <summary>
 /// The create world.
 /// </summary>
 /// <param name="game">
 /// The mmo game.
 /// </param>
 /// <param name="worldName">
 /// The world name.
 /// </param>
 /// <param name="topLeftCorner">
 /// The top left corner.
 /// </param>
 /// <param name="bottomRightCorner">
 /// The bottom right corner.
 /// </param>
 /// <param name="tileDimensions">
 /// The tile dimensions.
 /// </param>
 public static void CreateWorld(Game game, string worldName, float[] topLeftCorner, float[] bottomRightCorner, float[] tileDimensions)
 {
     var data = new Dictionary<byte, object>
         {
             { (byte)ParameterCode.WorldName, worldName }, 
             { (byte)ParameterCode.TopLeftCorner, topLeftCorner }, 
             { (byte)ParameterCode.BottomRightCorner, bottomRightCorner }, 
             { (byte)ParameterCode.TileDimensions, tileDimensions }
         };
     game.SendOperation(OperationCode.CreateWorld, data, true, Settings.OperationChannel);
 }
Esempio n. 23
0
        /// <summary>
        /// The unsubscribe item.
        /// </summary>
        /// <param name="game">
        /// The mmo game.
        /// </param>
        /// <param name="itemId">
        /// The item id.
        /// </param>
        /// <param name="itemType">
        /// The item type.
        /// </param>
        public static void UnsubscribeItem(Game game, string itemId, byte itemType)
        {
            var data = new Dictionary<byte, object> { { (byte)ParameterCode.ItemId, itemId }, { (byte)ParameterCode.ItemType, itemType } };

            game.SendOperation(OperationCode.UnsubscribeItem, data, true, Settings.ItemChannel);
        }
Esempio n. 24
0
 /// <summary>
 /// The detach camera.
 /// </summary>
 /// <param name="game">
 /// The mmo game.
 /// </param>
 public static void DetachInterestArea(Game game)
 {
     game.SendOperation(OperationCode.DetachInterestArea, new Dictionary<byte, object>(), true, Settings.ItemChannel);
 }
Esempio n. 25
0
 public InterestArea(byte cameraId, Game game, float[] position)
 {
     this.game = game;
     this.cameraId = cameraId;
     this.Position = position;
 }
Esempio n. 26
0
 /// <summary>
 /// The exit world.
 /// </summary>
 /// <param name="game">
 /// The mmo game.
 /// </param>
 public static void ExitWorld(Game game)
 {
     game.SendOperation(OperationCode.ExitWorld, new Dictionary<byte, object>(), true, Settings.OperationChannel);
 }