Example #1
0
        public void AttachItem(MyItem item)
        {
            if (this.AttachedItem != null)
            {
                this.AttachedItem.Moved -= this.OnItemMoved;
                this.AttachedItem = null;
            }

            this.AttachedItem = item;
            item.Moved += this.OnItemMoved;

            Operations.AttachInterestArea(this.game, item.Id);
            item.SetInterestAreaAttached(true);
        }
Example #2
0
        public Game(IGameListener listener, Settings settings, string avatarName)
        {
            this.listener = listener;
            this.settings = settings;

            this.avatar = new MyItem(this, Guid.NewGuid().ToString(), ItemType.Avatar, avatarName);

            this.AddItem(this.Avatar);
            this.AddCamera(new InterestArea(0, this, this.avatar));
            this.WorldData = new WorldData
                {
                    BoundingBox = new BoundingBox
                    {
                        Min = new Vector(),
                        Max = new Vector(settings.GridSize.X, settings.GridSize.Y)
                    },
                    Name = this.settings.WorldName,
                    TileDimensions = this.settings.TileDimensions
                };
        }
 public InterestArea(byte cameraId, Game game, MyItem avatar)
     : this(cameraId, game, avatar.Position)
 {
     this.AttachedItem = avatar;
     avatar.Moved += this.OnItemMoved;
 }
Example #4
0
        /// <summary>
        ///   Initializes a new instance of the <see cref = "Game" /> class.
        /// </summary>
        /// <param name = "listener">
        ///   The listener.
        /// </param>
        /// <param name = "settings">
        ///   The settings.
        /// </param>
        /// <param name = "avatarName">
        ///   The avatar Name.
        /// </param>
        public Game(IGameListener listener, Settings settings, string avatarName)
        {
            this.listener = listener;
            this.settings = settings;

            this.avatar = new MyItem(Guid.NewGuid().ToString(), (byte)ItemType.Avatar, this, avatarName);
            this.avatar.AddVisibleInterestArea(0);

            this.AddItem(this.Avatar);
            this.AddCamera(new InterestArea(0, this, this.avatar));
            this.WorldData = new WorldData
                {
                    TopLeftCorner = new[] { 1f, 1f }, 
                    BottomRightCorner = new float[] { this.settings.GridSize[0], this.settings.GridSize[1] }, 
                    Name = this.settings.WorldName, 
                    TileDimensions = new float[] { this.settings.TileDimensions[0], this.settings.TileDimensions[1] }
                };

            this.stateStrategy = Disconnected.Instance;
        }
Example #5
0
 public InterestArea(byte cameraId, Game game, MyItem avatar)
     : this(cameraId, game, avatar.Position)
 {
     this.AttachedItem = avatar;
     avatar.Moved     += this.OnItemMoved;
 }