/// <summary> /// On the server, initiate the given type of break /// </summary> /// <param name="type">The type of break that is necessary to start</param> public void StartBreak(GameBreak type) { if (isServer) { onBreak = true; // Prevent the ball from moving ball.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeAll; // Set the type of break that is happening and perform any necessary actions for it gameBreakType = type; gameBreakType.StartOfBreakActions(); timer.SetLengthOfTimer(gameBreakType.GetBreakLength()); // Start the countdown timer.Resume(); } }
/// <summary> /// On the server, end the current break /// </summary> private void EndBreak() { if (isServer) { onBreak = false; // Stop the timer timer.Pause(); timer.SetLengthOfTimer(0); // Perform any necessary actions for the end of this break type gameBreakType.EndOfBreakActions(); gameBreakType = null; // Allow ball to move ball.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.None; ball.GetComponent<Rigidbody>().velocity = new Vector3(0, 0, 0); } }