public void SwingBat(bool isStrike) { //Check if this should be a strike or a hit if (isStrike) { if (GameControl.strikes != 2) { string aud = "strike" + UnityEngine.Random.Range(1, 4); TextPopUps.instance.ShowPopUp("strike"); AudioControl.instance.PlayAudio(aud); } else { player.ChangeAtBats(1); } float rand = UnityEngine.Random.Range(0f, 1f); if (rand >= 0.35f) { anim.SetTrigger("isSwingingBat"); } GameControl.instance.HandleStrike(false); } //Revisit this if we decide to implement foul balls //else if (ball.curPitch.type == Pitcher.Pitches.foul) //{ // anim.SetTrigger("isSwingingBat"); // int pitchIndex = UnityEngine.Random.Range(0, ball.curPitch.hitLoc.Count); // Vector2 hitTarget = ball.curPitch.hitLoc[pitchIndex].center.transform.position; // hitTarget.x += UnityEngine.Random.Range(ball.curPitch.hitLoc[pitchIndex].minOffset.x, ball.curPitch.hitLoc[pitchIndex].maxOffset.x); // hitTarget.y += UnityEngine.Random.Range(ball.curPitch.hitLoc[pitchIndex].minOffset.y, ball.curPitch.hitLoc[pitchIndex].maxOffset.y); // ball.TemporarilyDisableCollision(0.3f); // ball.curSpeed = ball.curPitch.hitSpeed; // ball.maxHeight = ball.curPitch.maxHeight; // ball.endPoint = hitTarget; // ball.startPoint = ball.transform.position; // GameControl.ballInPlay = true; // GameControl.instance.HandleStrike(true); //} else { atBat = false; anim.SetTrigger("isSwingingBat"); int pitchIndex = UnityEngine.Random.Range(0, ball.curPitch.hitLoc.Count); Vector2 hitTarget = ball.curPitch.hitLoc[pitchIndex].center.transform.position; hitTarget.x += UnityEngine.Random.Range(ball.curPitch.hitLoc[pitchIndex].minOffset.x, ball.curPitch.hitLoc[pitchIndex].maxOffset.x); hitTarget.y += UnityEngine.Random.Range(ball.curPitch.hitLoc[pitchIndex].minOffset.y, ball.curPitch.hitLoc[pitchIndex].maxOffset.y); ball.TemporarilyDisableCollision(0.3f); ball.curSpeed = ball.curPitch.hitSpeed; ball.maxHeight = ball.curPitch.maxHeight; ball.targetFielder = null; ball.startPoint = ball.transform.position; ball.endPoint = hitTarget; ball.hasntHitGround = true; string aud = "hit" + UnityEngine.Random.Range(1, 3); if (ball.curPitch.type == Pitcher.Pitches.homerun) { ball.HandleHomeRun(); } Field.mostRecentBatter = this; Invoke("FieldersCanReact", 0.2f); AudioControl.instance.PlayAudio(aud); GameControl.instance.ResetCount(); GameControl.instance.SetCameraToFollowBall(true); GameControl.ballInPlay = true; GameControl.waitingForNextBatter = true; isAdvancing = true; col.enabled = false; player.ChangeAtBats(1); } if (ball.curPitch.type == Pitcher.Pitches.homerun) { GameControl.isHomeRun = true; } }