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); } }
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); } }
public void OnMobileMoved(Mobile sender, MoveArgs args) { UpdateScreenPosition(sender); }
public PlayerAnimation(Mobile mobile) : base(mobile) { }
private void npc_Move(Mobile sender, MoveArgs args) { collisionDetection.Perform(marian, (Npc)sender); }
public GloopAnimation(Mobile mobile) : base(mobile) { }
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); }
public void UpdatePosition(Mobile mobile) { Vector2 center = CalculateOffset(mobile, mobile.Position, 1); Vector2 position = Offset(center, -1); Position = position; }
public Vector2 GetPosition(Mobile mobile) { Vector2 center = Offset(Position, 1); Vector2 position = CalculateOffset(mobile, center, -1); return position; }
public InterpolationCalculator(Mobile mobile) { this.mobile = mobile; }