void CheckKeyboardInput() { moveDirection.x = Input.GetAxis("Horizontal"); moveDirection.y = Input.GetAxis("Vertical"); rippleScript.CheckRipple(spearScript.GetPointOnScreen(Input.mousePosition), moveDirection); cameraScript.MoveCamera(moveDirection * 10); }
void CheckTouchInput() { // Two finger swipe to pan camera if (Input.touchCount == 2 && singleTouch == false) { Touch touch1 = Input.touches[0]; Touch touch2 = Input.touches[1]; if (touch1.phase == TouchPhase.Moved && touch2.phase == TouchPhase.Moved) { if (!CheckTouchPinch(touch1, touch2) && !CheckTouchTurn(touch1, touch2)) { cameraScript.MoveCamera(touch1.deltaPosition); Vector2 midpoint = (spearScript.GetPointOnScreen(touch1.position) + spearScript.GetPointOnScreen(touch2.position)) * 0.5f; rippleScript.CheckRipple(midpoint, touch1.deltaPosition * 0.07f); } } } // One finger touch to spear fish else if (Input.touchCount == 1 || singleTouch == true) { Touch touch1 = Input.touches[0]; if (touch1.phase == TouchPhase.Began) { // Break function here in case it was going to be a two finger swipe frameTouchBuffer++; } else if (touch1.phase == TouchPhase.Ended && singleTouch == true) { // We can tell the spear script that we let go singleTouch = false; spearScript.EndSpearFish(spearScript.GetPointOnScreen(touch1.position)); } else if (frameTouchBuffer > bufferCap) { // Create the circle spearScript.StartSpearFish(spearScript.GetPointOnScreen(touch1.position)); singleTouch = true; frameTouchBuffer = 0; } else if (frameTouchBuffer > 0) { frameTouchBuffer++; } else if (singleTouch == true) { // Run the radius change bit spearScript.RadiusChange(spearScript.GetPointOnScreen(touch1.position)); } } }