예제 #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;
 }