/// <summary> /// Call when two players have joined the game /// </summary> private void Start() { Debug.Log("[Ball Controller] Initialising..."); isGoal = false; var p1Goal = Goals.FindPlayerOneGoal().GetComponent <TriggerObservable>(); var p2Goal = Goals.FindPlayerTwoGoal().GetComponent <TriggerObservable>(); p1Goal.TriggerEnter += OnGoal; p2Goal.TriggerEnter += OnGoal; GameServer.OnGameReady += CreateBall; }
// --- Messages --- /// <summary> /// Attaches handlers to the goals /// </summary> private void Start() { playerOneScore = 0; playerTwoScore = 0; var p1Goal = Goals.FindPlayerOneGoal().GetComponent <TriggerObservable>(); p1Goal.TriggerEnter += Goals.OnBallGoal(_ => playerOneScore += 1); p1Goal.TriggerEnter += Goals.OnBallGoal(OnGoal); var p2Goal = Goals.FindPlayerTwoGoal().GetComponent <TriggerObservable>(); p2Goal.TriggerEnter += Goals.OnBallGoal(_ => playerOneScore += 1); p2Goal.TriggerEnter += Goals.OnBallGoal(OnGoal); }