예제 #1
0
 void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("HitterBox"))
     {
         gameObject.GetComponent <MeshRenderer>().material = Pitcher.GetCurrentBallMaterial();
     }
 }
예제 #2
0
    void CheckSwing()
    {
        if (GM.BallIsInHitBox())
        {
            if (!Input.GetKeyDown(KeyCode.Space))
            {
                return;
            }

            if (Pitcher.GetCurrentBallMaterial() != BadBallMaterial)
            {
                GM.GetBaseball().SetPositionToMoveTo(GoodHitTarget);
                GM.GetBaseball().Speed *= 2;
            }
            else
            {
                Transform RandFielder = GM.GetRandomFielderPosition();
                GM.GetBaseball().SetPositionToMoveTo(RandFielder);
            }

            HasSwung = true;
            HitBall  = true;
            print("SWUNG");
            MovingToBase = true;
            IsRunner     = true;

            BaseToMoveTo = FirstBase;
            CurrentBase  = FirstBase;
        }
        else if (GM.BallDidExitHitBox())
        {
            if (!HasSwung)
            {
                if (Pitcher.GetCurrentBallMaterial() != BadBallMaterial)
                {
                    HitBall = false;
                    GM.AddStrike();
                }

                Destroy(GM.GetBaseball().gameObject, 0.65f);
            }
        }

        GM.SetBallExitedHitBox(false);
    }