private bool CoordinatesBelongToArea(Vector2 collision, CourtArea area) { return(collision.y > area.HorizontalStart && collision.y < area.HorizontalLimit && collision.x > area.DepthStart && collision.x < area.DepthLimit); }
public CourtSectionMapper(ScoreManager scoreManager) { _backLeftServingSquare = GenerateCourtArea(AreaType.ServingSquare, Depth.Back, Horizontal.Left); _frontRightServingSquare = GenerateCourtArea(AreaType.ServingSquare, Depth.Front, Horizontal.Right); _backRightServingSquare = GenerateCourtArea(AreaType.ServingSquare, Depth.Back, Horizontal.Right); _frontLeftServingSquare = GenerateCourtArea(AreaType.ServingSquare, Depth.Front, Horizontal.Left); _frontFullArea = GenerateCourtArea(AreaType.Full, Depth.Front, null); _backFullArea = GenerateCourtArea(AreaType.Full, Depth.Back, null); var frontServingSquareDepth = Mathf.Abs(_frontLeftServingSquare.DepthLimit - _frontLeftServingSquare.DepthStart); _frontVolleyAreaStart = _frontLeftServingSquare.DepthLimit - frontServingSquareDepth * 0.6f; var backServingSquareDepth = Mathf.Abs(_backLeftServingSquare.DepthLimit - _backLeftServingSquare.DepthStart); _backVolleyAreaLimit = _backLeftServingSquare.DepthStart + backServingSquareDepth * 0.6f; _scoreManager = scoreManager; }
private static CourtArea GenerateCourtArea(AreaType type, Depth depth, [CanBeNull] Horizontal?horizontal) { /* * References (left, right, front, back) are considered from the camera perspective */ CourtArea area = new CourtArea(); if (depth == Depth.Front) { if (type == AreaType.Full) { //COORDINATES FOR FRONT FULL COURT area.DepthLimit = 0; area.DepthStart = -39.155f; area.HorizontalLimit = 14f; area.HorizontalStart = -13.82f; } else if (type == AreaType.ServingSquare) { if (horizontal == Horizontal.Left) { //COORDINATES FOR FRONT LEFT SERVING SQUARE area.DepthLimit = 0; area.DepthStart = -21.38f; area.HorizontalLimit = 14f; area.HorizontalStart = -0.21f; } else if (horizontal == Horizontal.Right) { //COORDINATES FOR FRONT RIGHT SERVING SQUARE area.DepthLimit = 0; area.DepthStart = -21.38f; area.HorizontalLimit = 0.145f; area.HorizontalStart = -13.82f; } } } else if (depth == Depth.Back) { if (type == AreaType.Full) { //COORDINATES FOR BACK FULL COURT area.DepthLimit = 39.015f; area.DepthStart = 0.044f; area.HorizontalLimit = 14f; area.HorizontalStart = -13.82f; } else if (type == AreaType.ServingSquare) { if (horizontal == Horizontal.Left) { //COORDINATES FOR BACK LEFT SERVING SQUARE area.DepthLimit = 21.176f; area.DepthStart = 0.044f; area.HorizontalLimit = 14f; area.HorizontalStart = -0.21f; } else if (horizontal == Horizontal.Right) { //COORDINATES FOR BACK RIGHT SERVING SQUARE area.DepthLimit = 21.176f; area.DepthStart = 0.044f; area.HorizontalLimit = 0.145f; area.HorizontalStart = -13.82f; } } } return(area); }