public static void PositionRelativeTo(this IWithPositionAndDirection obj, IWithPositionAndDirection parent, int offsetX, int offsetY) { var offset = new Vector2(offsetX, offsetY); obj.Position.Center = parent.Position.Center.Translate(offset.FlipIfLeft(parent.Direction)); obj.Direction = parent.Direction; }
public Hitbox(ICondition condition, IWorldObject owner) { Condition = condition; Owner = owner; Position = new Rectangle(0, 0, 16, 32); //todo this.StayRelativeTo(owner, 16, 0, owner); //todo }
public StayRelativeTo(IWithPosition objectToMove, IWithPositionAndDirection origin, Vector2 offset, IWorldObject root) { Parent = origin; Offset = offset; Object = objectToMove; root.Layer.Scene.AddObject(this); Root = root; }
public static void Face(this IWithPositionAndDirection obj, IWithPosition other) { if (obj.Position.Center.X < other.Position.Center.X) { obj.Direction = Direction.Right; } else if (obj.Position.Center.X > other.Position.Center.X) { obj.Direction = Direction.Left; } }
public abstract Direction GetDirectionAwayFrom(IWithPositionAndDirection obj);
public override Direction GetDirectionAwayFrom(IWithPositionAndDirection obj) { return(obj.DirectionAwayFrom(this, Axis.X)); }
public DirectedAnimation(IRemoveable root, IWithPositionAndDirection parent, Sprite sprite, TextureFlipBehavior flipbehavior, params int[] frames) : base(root, parent, sprite, frames) { Parent = parent; FlipBehavior = flipbehavior; }
public override Direction GetDirectionAwayFrom(IWithPositionAndDirection obj) { return(obj.CardinalDirectionTowards(this, Axis.X)); }
public static void StayRelativeTo(this IWithPosition item, IWithPositionAndDirection parent, float xOff, float yOff, IWorldObject root) { new StayRelativeTo(item, parent, new Vector2(xOff, yOff), root); }