private void SetOpponentShot() { if (currentShotIndex < shotDataList.Count - 1) { ShotDataObject currentShot = shotDataList[currentShotIndex]; if (currentShot.shot["point"] == "no" && currentShot.shot["error"] == "none") { ShotDataObject nextShot = shotDataList[currentShotIndex + 1]; TennisPlayerController opponentController = GetCurrentOpponentController(); opponentController.MakeShot(nextShot.startPosition, nextShot.shot["shotType"], currentShot.shotDuration); } } }
private void Serve() { waitForServe = true; TennisPlayerController servingPlayer = GetCurrentPlayerController(); ballController.SetBallVisible(false); servingPlayer.shotCallback += delegate() { ballController.SetBallVisible(true); waitForServe = false; SetOpponentShot(); }; Vector3 servingPoint = shotDataList[currentShotIndex].startPosition; float distanceToServingPoint = (servingPlayer.transform.position - servingPoint).magnitude; servingPlayer.MakeShot(servingPoint, "serve", distanceToServingPoint * .85f); }