Пример #1
0
        public void CharacterMove(Mobile sender, MoveArgs args)
        {
            UpdatePositionRelativeToOwner(sender);

            // update relative screen position for everything else.
            foreach (IGameContent content in contents)
            {
                UpdateScreenPosition(content);
            }
        }
        private void marian_Move(Mobile sender, MoveArgs args)
        {
            foreach (Npc npc in npcs)
            {
                collisionDetection.Perform(marian, npc);
            }

            foreach (Item item in items)
            {
                collisionDetection.Perform(marian, item);
            }
        }
Пример #3
0
        private void UpdatePositionRelativeToOwner(Mobile sender)
        {
            Vector2 relative = sender.Position - position;

            ILevel level = TileMatrix.Instance.Metadata;

            int left = level.ScreenLeft;
            int right = bounds.Width - level.ScreenRight;
            int top = level.ScreenTop;
            int bottom = bounds.Height - level.ScreenBottom;

            if (relative.X < left)
            {
                float x = position.X + relative.X - left;
                position.X = Math.Max(x, 0);
            }

            if (relative.X > right)
            {
                float x = position.X + relative.X - right;
                int w = TileMatrix.Instance.Width - bounds.Width;
                position.X = Math.Min(x, w);
            }

            if (relative.Y < top)
            {
                float y = position.Y + relative.Y - top;
                position.Y = Math.Max(y, 0);
            }

            if (relative.Y > bottom)
            {
                float y = position.Y + relative.Y - bottom;
                int h = TileMatrix.Instance.Height - bounds.Height;
                position.Y = Math.Min(y, h);
            }
        }
Пример #4
0
 public void OnMobileMoved(Mobile sender, MoveArgs args)
 {
     UpdateScreenPosition(sender);
 }
Пример #5
0
 public PlayerAnimation(Mobile mobile)
     : base(mobile)
 {
 }
 private void npc_Move(Mobile sender, MoveArgs args)
 {
     collisionDetection.Perform(marian, (Npc)sender);
 }
Пример #7
0
 public GloopAnimation(Mobile mobile)
     : base(mobile)
 {
 }
Пример #8
0
 private Vector2 CalculateOffset(Mobile mobile, Vector2 from, int multiplier)
 {
     float x = from.X + mobile.ContentWidth / 2.0f * multiplier;
     float y = from.Y + mobile.ContentHeight / 2.0f * multiplier;
     return new Vector2(x, y);
 }
Пример #9
0
 public void UpdatePosition(Mobile mobile)
 {
     Vector2 center = CalculateOffset(mobile, mobile.Position, 1);
     Vector2 position = Offset(center, -1);
     Position = position;
 }
Пример #10
0
 public Vector2 GetPosition(Mobile mobile)
 {
     Vector2 center = Offset(Position, 1);
     Vector2 position = CalculateOffset(mobile, center, -1);
     return position;
 }
Пример #11
0
 public InterpolationCalculator(Mobile mobile)
 {
     this.mobile = mobile;
 }