void Update() { hitCounter = hitCounter - 1 > 0 ? hitCounter - 1 : 0; switch (state) { case MatchManager.PlayerState.Serve: if (kb.spaceKey.isPressed) { animator.SetTrigger("Serve"); state = MatchManager.PlayerState.WaitAnimation; from = MatchManager.PlayerState.Serve; GetShotType(); gameObject.GetComponent <KeyboardPlayerMover>().serving = false; } else { gameObject.GetComponent <KeyboardPlayerMover>().serving = true; } break; case MatchManager.PlayerState.Play: if (kb.spaceKey.isPressed) { from = MatchManager.PlayerState.Play; GetShotType(); HitBall(); } break; case MatchManager.PlayerState.WaitAnimation: if (waitCounter < waitTime) { waitCounter += Time.deltaTime; } else { if (from == MatchManager.PlayerState.Play) { HitBall(); } else if (from == MatchManager.PlayerState.Serve) { Serve(); } state = MatchManager.PlayerState.Play; waitCounter = 0; } break; } }
public void SetState(MatchManager.PlayerState newState) { state = newState; }