public void SwipeManager(SwipeStates swipeState, Vector2 inputPos) { if (swipeState == SwipeStates.Start) { StartSwipe(inputPos); } if (swipeState == SwipeStates.Continue) { ContinueSwipe(inputPos); } if (swipeState == SwipeStates.End) { EndSwipe(inputPos); } if (swipeToProcess) { // print ("+" + Mathf.RoundToInt( getSwipeOffset() / anglePart).ToString()); rotationIndex += (int)(Mathf.RoundToInt(getSwipeOffset() / anglePart)); swipeToProcess = false; } }
public void OnDragEventHandler (Vector2 screenPosition, float distance) { if (player.playerState == PlayerStates.Dead){ return; } MoveTrailRenderer (gameController.guiCamera.ScreenToWorldPoint (screenPosition) + new Vector3 (0, 0, 1)); if (swipeState == SwipeStates.None) { oldFingerPosition = screenPosition; swipeState = SwipeStates.DragActive; } if (swipeState == SwipeStates.Aftertouch){ if (Vector2.Distance(screenPosition, lastAftertouchPosition) >= aftertouchRecognitionRadius){ Vector3 dirVector = (gameController.ToCourtSpace(screenPosition).GetValueOrDefault() - gameController.ToCourtSpace(lastAftertouchPosition).GetValueOrDefault()).normalized; dirVector.y = 0; lastAftertouchPosition = screenPosition; afterTouchDirection = dirVector; } } DeltaCalculations (screenPosition); if (swipeState == SwipeStates.DragActive) { if (deltaAverage >= deltaSwipeThreshold) { swipeState = SwipeStates.SwipeActive; } } if (swipeState == SwipeStates.SwipeActive) { var swipeStartCourtSpace = gameController.ToCourtSpace (dragStartPosition).GetValueOrDefault (); var swipeEndCourtSpace = gameController.ToCourtSpace (screenPosition).GetValueOrDefault (); var direction = (swipeEndCourtSpace - swipeStartCourtSpace).normalized; var passedSwipeThresholdRadius = Vector2.Distance (screenPosition, dragStartPosition) > swipeRecognitionRadius; var isForwardSwipe = Vector3.Dot (direction, -(new Vector3 (0, 0, player.transform.position.z)).normalized) < vectorFowardThreshold; var isHorizontalSwipe = Mathf.Abs (Vector3.Dot (direction, Vector3.right)) > vectorHorizontalThreshold; print (Vector3.Dot (direction, -(new Vector3 (0, 0, player.transform.position.z)).normalized)); if (passedSwipeThresholdRadius) { if (isForwardSwipe) { swipeState = SwipeStates.Aftertouch; ResetDragInformation (screenPosition); print ("SHOT"); /* float ballCharge = matchController.manager.HitBallId(); ZombieModeBall ball = SpawnManager.SpawnPrefab (Spawn.ZombieModeBall, player.transform.position + new Vector3 (0, 3, 0), PoolName.Default).GetComponent<ZombieModeBall> (); */ Ball ball = SpawnManager.SpawnPrefab (Spawn.Ball, player.transform.position + new Vector3 (0, 3, 0), PoolName.Default).GetComponent<Ball> (); ball.transform.position = player.transform.position + new Vector3(0, 3, 1); player.animator.Play("Attack", 0, 0); gameController.audioManager.sfxBallHit.Play(); Vector3 assistedDir = player.assistance.AssistedShotVector(ball, direction); currentAftertouchBall = ball; currentAftertouchBall.aftertouchActive = true; //matchController.manager.ResetCharge(0); ball.Hit (new Vector3 (assistedDir.x * hitStrength, hitStrengthY, assistedDir.z * hitStrength)); //ball.SetBall(ballCharge); } else if (isHorizontalSwipe) { player.Slide (direction); ResetDragInformation (screenPosition); swipeState = SwipeStates.SwipePerformed; /* matchController.player.SideStep (direction); ResetDragInformation (screenPosition); swipeState = SwipeStates.SwipePerformed; */ } } } }
public void OnReleaseEventHandler (Vector2 pos) { swipeState = SwipeStates.None; ResetDragInformation (pos); ResetAftertouch(); }