override public void UseAbilityOnHold(Vector2 currentTouchPosition) { if (isResettingCameraZoom && isResettingCameraPosition) { return; } this.currentTouchPosition = currentTouchPosition; angle = MyCalculator.CalculateAngle(initialTouchPosition, currentTouchPosition, transform.position); currentForcePercentage = MyCalculator.CalcuateForcePercentage(initialTouchPosition, currentTouchPosition, maxDrawLength); if (abilityCharges > 0f) { if (projectileArc != null) { projectileArc.UpdateProjectileArc(rb, transform.position, angle, currentForcePercentage * maxForce); } } CameraZoom(); }
void ManageTouches() { #if UNITY_STANDALONE_WIN if (Input.GetMouseButtonDown(0)) { // Checks if the shoot area has been touched hasTouchedShootArea = IsOnShootTouchArea(GetCurrentMousePos()); // Checks if the ability area has been touched hasTouchedAbilityArea = IsOnAbilityTouchArea(GetCurrentMousePos()); if (hasTouchedAbilityArea) { if (ballista.lastBall != null) { ballista.lastBall.UseAbilityOnTouch(); } } isMouseDown = true; initialTouchPos = GetCurrentMousePos(); EnableLine(true); } #endif #if UNITY_ANDROID || UNITY_IOS if (Input.touchCount > 0) { Touch touch = Input.GetTouch(0); if (touch.phase == TouchPhase.Began) { // Checks if the shoot area has been touched hasTouchedShootArea = IsOnShootTouchArea(GetCurrentTouchPos()); // Checks if the ability area has been touched hasTouchedAbilityArea = IsOnAbilityTouchArea(GetCurrentTouchPos()); if (hasTouchedAbilityArea) { if (ballista.lastBall != null) { ballista.lastBall.UseAbilityOnTouch(GetCurrentTouchPos()); } } isMouseDown = true; initialTouchPos = GetCurrentTouchPos(); EnableLine(true); } } #endif if (isMouseDown) { #if UNITY_ANDROID || UNITY_IOS currentTouchPos = GetCurrentTouchPos(); #endif #if UNITY_STANDALONE_WIN currentTouchPos = GetCurrentMousePos(); #endif /** * Abilities */ if (hasTouchedAbilityArea) { if (ballista.lastBall != null) { ballista.lastBall.UseAbilityOnHold(GetCurrentTouchPos()); } } /** * Shooting */ if (hasTouchedShootArea) { EnableLengthPercentageText(true); currentForcePercentage = MyCalculator.CalcuateForcePercentage(initialTouchPos, currentTouchPos, maxDrawLength); ballista.Aim(MyCalculator.CalculateAngle(initialTouchPos, currentTouchPos, ballista.flightGroove.transform.position)); // CalculateLength(); PrepareProjectileArc(); } DrawLine(); } #if UNITY_STANDALONE_WIN if (Input.GetMouseButtonUp(0)) { isMouseDown = false; /// <summary> /// Abilities /// </summary> if (hasTouchedAbilityArea) { if (ballista.lastBall != null) { ballista.lastBall.UseAbilityOnRelease(); } } /// <summary> /// Shooting /// </summary> if (hasTouchedShootArea) { ballista.Shoot(currentDrawLength / maxDrawLength); EnableLengthPercentageText(false); } } #endif #if UNITY_ANDROID || UNITY_IOS if (Input.touchCount > 0) { if (Input.GetTouch(0).phase == TouchPhase.Ended) { isMouseDown = false; /** * Abilities */ if (hasTouchedAbilityArea) { if (ballista.lastBall != null) { ballista.lastBall.UseAbilityOnRelease(); } } /** * Shooting */ if (hasTouchedShootArea) { ballista.Shoot(currentForcePercentage); EnableLengthPercentageText(false); } EnableLine(false); } } #endif }