public class GameController : MonoBehaviour
{
private State state = State.JumpBall; // A basketball game always starts with a jump ball.
+ internal Animator BallAnimation;
public Player player;
public Player enemy;
ball.controller = this;
PlayerHoop.controller = this;
EnemyHoop.controller = this;
+ BallAnimation = ball.GetComponentInChildren<Animator>();
}
public struct Player
if (Vector2.Distance(controller.ball.transform.position, handPosition) >= 1f) return false;
controller.state = dribble;
+ controller.BallAnimation.enabled = false;
controller.dribbleSound.Play();
Move(handPosition);
return true;
public bool Shoot(Transform playerTransform)
{
if (controller.state != dribble) return false; // We must be dribbling the ball to shoot it.
+ controller.BallAnimation.enabled = true;
controller.dribbleSound.Stop();
controller.state = shoot;
controller.ball.Shoot(hoop.transform.position);
internal void BallDropped()
{
+ BallAnimation.enabled = true;
dribbleSound.Stop();
state = State.Idle;
}