Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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
        }
Ejemplo n.º 3
0
 public StayRelativeTo(IWithPosition objectToMove, IWithPositionAndDirection origin, Vector2 offset, IWorldObject root)
 {
     Parent = origin;
     Offset = offset;
     Object = objectToMove;
     root.Layer.Scene.AddObject(this);
     Root = root;
 }
Ejemplo n.º 4
0
 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;
     }
 }
Ejemplo n.º 5
0
 public abstract Direction GetDirectionAwayFrom(IWithPositionAndDirection obj);
Ejemplo n.º 6
0
 public override Direction GetDirectionAwayFrom(IWithPositionAndDirection obj)
 {
     return(obj.DirectionAwayFrom(this, Axis.X));
 }
Ejemplo n.º 7
0
 public DirectedAnimation(IRemoveable root, IWithPositionAndDirection parent, Sprite sprite, TextureFlipBehavior flipbehavior, params int[] frames)
     : base(root, parent, sprite, frames)
 {
     Parent       = parent;
     FlipBehavior = flipbehavior;
 }
Ejemplo n.º 8
0
 public override Direction GetDirectionAwayFrom(IWithPositionAndDirection obj)
 {
     return(obj.CardinalDirectionTowards(this, Axis.X));
 }
Ejemplo n.º 9
0
 public static void StayRelativeTo(this IWithPosition item, IWithPositionAndDirection parent, float xOff, float yOff, IWorldObject root)
 {
     new StayRelativeTo(item, parent, new Vector2(xOff, yOff), root);
 }