internal Timeline(int id, string name, Entity.ObjectInfo objectInfo, int keys) { this.Id = id; this.Name = name; this.ObjectInfo = objectInfo; this.Keys = new Key[keys]; }
/// <summary> /// Returns whether the given coordinates lie inside the box of the given bone or object. </summary> /// <param name="boneOrObject"> the bone or object </param> /// <param name="info"> the object info of the given bone or object </param> /// <param name="x"> the x coordinate </param> /// <param name="y"> the y coordinate </param> /// <returns> <code>true</code> if the given point lies in the box </returns> /// <exception cref="NullPointerException"> if info or boneOrObject is <code>null</code> </exception> public virtual bool Collides(Bone boneOrObject, Entity.ObjectInfo info, float x, float y) { float width = info.Size.X * boneOrObject.Scale.X; float height = info.Size.Y * boneOrObject.Scale.Y; float pivotX = width * boneOrObject.Pivot.X; float pivotY = height * boneOrObject.Pivot.Y; Point point = new Point(x - boneOrObject.Position.X, y - boneOrObject.Position.Y); point.Rotate(-boneOrObject.Angle); return(point.X >= -pivotX && point.X <= width - pivotX && point.Y >= -pivotY && point.Y <= height - pivotY); }
/// <summary> /// Calculates its four points for the given bone or object with the given info. </summary> /// <param name="boneOrObject"> the bone or object </param> /// <param name="info"> the info </param> /// <exception cref="NullPointerException"> if info or boneOrObject is <code>null</code> </exception> public virtual void CalcFor(Bone boneOrObject, Entity.ObjectInfo info) { float width = info.Size.X * boneOrObject.Scale.X; float height = info.Size.Y * boneOrObject.Scale.Y; float pivotX = width * boneOrObject.Pivot.X; float pivotY = height * boneOrObject.Pivot.Y; this.Points[0].Set(-pivotX, -pivotY); this.Points[1].Set(width - pivotX, -pivotY); this.Points[2].Set(-pivotX, height - pivotY); this.Points[3].Set(width - pivotX, height - pivotY); for (int i = 0; i < 4; i++) { this.Points[i].Rotate(boneOrObject.Angle); } for (int i = 0; i < 4; i++) { this.Points[i].Translate(boneOrObject.Position); } }