public static CollisionType CheckCollisionType(this Hitbox a, Hitbox b) { if (a.Type == HitboxType.Attack) { if (b.Type == HitboxType.Attack) { return(CollisionType.Clash); } if (b.Type == HitboxType.Body) { return(CollisionType.Hit); } } return(CollisionType.None); }
public static void DebugDraw(this Hitbox hitbox) { Vector2 _00 = hitbox.Position + hitbox.Size * new float2(-0.5f, 0f); Vector2 _01 = hitbox.Position + hitbox.Size * new float2(-0.5f, 1f); Vector2 _10 = hitbox.Position + hitbox.Size * new float2(0.5f, 0f); Vector2 _11 = hitbox.Position + hitbox.Size * new float2(0.5f, 1f); Color color; switch (hitbox.Type) { case HitboxType.Body: color = _bodyColor; break; case HitboxType.Attack: color = _attackColor; break; default: throw new ArgumentOutOfRangeException(); } Debug.DrawLine(_00, _01, color, 0, false); Debug.DrawLine(_11, _01, color, 0, false); Debug.DrawLine(_11, _10, color, 0, false); Debug.DrawLine(_00, _10, color, 0, false); }
public static bool Intersects(this Hitbox a, Hitbox b) { return(math.all(a.Position < b.Position + b.Size) && math.all(a.Position + a.Size > b.Position)); }