private BallHeightEnum GetBallHeightState(Vector3 ballStartPosition, Vector3 ballEndposition, Vector3 ballCurrentPosition) { BallHeightEnum resultingState = BallHeightEnum.NONE; float ballTotalTravellingDistance = Vector3.Distance(ballStartPosition, ballEndposition); float ballCurrentTraveledDistance = Vector3.Distance(ballStartPosition, ballCurrentPosition); float distanceThreshold = ballTotalTravellingDistance / 4; if (ballCurrentTraveledDistance >= 0 && ballCurrentTraveledDistance < distanceThreshold) { resultingState = BallHeightEnum.LOW; } else if (ballCurrentTraveledDistance >= distanceThreshold && ballCurrentTraveledDistance < distanceThreshold * 2) { resultingState = BallHeightEnum.HIGH; } else if (ballCurrentTraveledDistance >= distanceThreshold * 2 && ballCurrentTraveledDistance < distanceThreshold * 3) { resultingState = BallHeightEnum.LOW; } else if (ballCurrentTraveledDistance >= distanceThreshold * 3 && ballCurrentTraveledDistance <= distanceThreshold * 4) { resultingState = BallHeightEnum.GROUNDED; } return(resultingState); }
public static float CalculatePassSuccessRate(GameObject ballReceiverGameObject, GameObject ballPasserGameObject, BallHeightEnum ballHeight) { PlayerStatus receiverStatus = PlayerUtils.FetchPlayerStatusScript(ballReceiverGameObject); PlayerStatus passerStatus = PlayerUtils.FetchPlayerStatusScript(ballPasserGameObject); float passerCharacteristic = passerStatus.PassEfficiency; float result; switch (ballHeight) { case BallHeightEnum.GROUNDED: result = 100f; break; case BallHeightEnum.LOW: result = receiverStatus.CatchEfficiency + passerCharacteristic; break; case BallHeightEnum.HIGH: result = 0f; break; default: result = 100f; break; } return(AdjustResult(result)); }