示例#1
0
        /// <summary>
        /// The attach item.
        /// </summary>
        /// <param name="item">
        /// The mmo item.
        /// </param>
        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.Type);
            item.SetInterestAreaAttached(true);
        }
示例#2
0
 public InterestArea(byte cameraId, Game game, MyItem avatar)
     : this(cameraId, game, avatar.Position)
 {
     this.AttachedItem = avatar;
     avatar.Moved += this.OnItemMoved;
 }
示例#3
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[] { 0f, 0f },
                    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;
        }