/// <summary> /// /// </summary> /// <param name="OtherBoxBounds"></param> /// <returns></returns> protected override bool IsOverlappingBox2DBounds(Box2DBounds OtherBoxBounds) { bool ShouldPushOutVertically, ShouldPushOutHorizontally; ShouldPushOutBox2dBounds(OtherBoxBounds, out ShouldPushOutVertically, out ShouldPushOutHorizontally); return(ShouldPushOutVertically && ShouldPushOutHorizontally); }
protected override void ShouldPushOutBox2dBounds(Box2DBounds OtherBoxBounds, out bool ShouldPushOutVertically, out bool ShouldPushOutHorizontally, bool UseBufferForOverlap = false) { Vector2 CenterA = this.GetCenterPoint(); Vector2 CenterB = OtherBoxBounds.GetCenterPoint(); Vector2 SizeA = this.GetMaxBounds() - this.GetMinBounds(); Vector2 SizeB = (OtherBoxBounds.GetMaxBounds() - OtherBoxBounds.GetMinBounds()) - OtherBoxBounds.BufferBounds; ShouldPushOutVertically = (Mathf.Abs(CenterA.x - CenterB.x) * 2) < (SizeA.x + SizeB.x); ShouldPushOutHorizontally = Mathf.Abs(CenterA.y - CenterB.y) * 2 < (SizeA.y + SizeB.y); }
protected abstract void ShouldPushOutBox2dBounds(Box2DBounds OtherBounds, out bool ShouldPushOutVertically, out bool ShouldPushOutHorizontally, bool UseBufferForOverlap = false);
protected override Vector2 GetOffsetForNearestVerticalPointOnBoundsForBox2DBounds(Box2DBounds BoxBounds) { if (this.MinBounds.y > BoxBounds.MinBounds.y) { return(new Vector2(0, this.MinBounds.y - BoxBounds.MaxBounds.y)); } else if (this.MaxBounds.y < BoxBounds.MaxBounds.y) { return(new Vector2(0, this.MaxBounds.y - BoxBounds.MinBounds.y)); } else if (this.CenterPoint.y < BoxBounds.CenterPoint.y) { return(new Vector2(0, BoxBounds.MinBounds.y - this.MaxBounds.y)); } else { return(new Vector2(0, BoxBounds.MaxBounds.y - this.MinBounds.y)); } }
protected override Vector2 GetOffsetForNearestHorizontalPointOnBoundsForBox2DBounds(Box2DBounds BoxBounds) { if (this.MinBounds.x > BoxBounds.MinBounds.x) { return(new Vector2(this.MinBounds.x - BoxBounds.MaxBounds.x, 0)); } else if (this.MaxBounds.x < BoxBounds.MaxBounds.x) { return(new Vector2(this.MaxBounds.x - BoxBounds.MinBounds.x, 0)); } else if (this.CenterPoint.x < BoxBounds.CenterPoint.x) { return(new Vector2(BoxBounds.MinBounds.x - this.MaxBounds.x, 0)); } else { return(new Vector2(BoxBounds.MaxBounds.x - this.MinBounds.x, 0)); } }
/// <summary> /// /// </summary> /// <param name="BoxBounds"></param> /// <returns></returns> protected abstract Vector2 GetOffsetForNearestVerticalPointOnBoundsForBox2DBounds(Box2DBounds BoxBounds);
/// <summary> /// Method to check whether or now we are overlapping a Box@DBounds object /// </summary> /// <param name="BoxBounds"></param> /// <returns></returns> protected abstract bool IsOverlappingBox2DBounds(Box2DBounds BoxBounds);