public override void OnStartAuthority() { ScoreHandler scoreHandler = FindObjectOfType <ScoreHandler>(); MatchTimer matchTimer = FindObjectOfType <MatchTimer>(); updateManaBarCoroutine = StartCoroutine(UpdateManaBar()); manaBarMaskWidth = manaBarRawImage.rectTransform.rect.width; if (scoreHandler != null) { scoreHandler.ScoreChanged += OnScoreChanged; } else { Debug.LogError("OnStartAuthority, scoreHandler not found"); } if (matchTimer != null) { OnTimeChanged(matchTimer.Minutes, matchTimer.Seconds); matchTimer.TimeChanged += OnTimeChanged; matchTimer.MatchEnd += OnMatchEnd; } else { Debug.LogError("OnStartAuthority, matchTimer not found"); } GameObject pauseMenuUI = Instantiate(pauseMenuPrefab); pauseMenu = pauseMenuUI.GetComponent <PauseMenu>(); pauseMenu.PauseMenuOpened += OnPauseMenuOpened; pauseMenu.PauseMenuClosed += OnPauseMenuClosed; }
private void OnDestroy() { if (hasAuthority) { pauseMenu.PauseMenuOpened -= OnPauseMenuOpened; pauseMenu.PauseMenuClosed -= OnPauseMenuClosed; } ScoreHandler scoreHandler = FindObjectOfType <ScoreHandler>(); MatchTimer matchTimer = FindObjectOfType <MatchTimer>(); if (scoreHandler != null) { scoreHandler.ScoreChanged -= OnScoreChanged; } else { Debug.LogError("OnDestroy, scoreHandler not found"); } if (matchTimer != null) { matchTimer.TimeChanged -= OnTimeChanged; matchTimer.MatchEnd -= OnMatchEnd; } else { Debug.LogError("OnDestroy, matchTimer not found"); } if (updateManaBarCoroutine != null) { StopCoroutine(updateManaBarCoroutine); } }
private void OnDestroy() { foreach (Goal goal in goals) { goal.Score -= OnScore; } MatchTimer matchTimer = FindObjectOfType <MatchTimer>(); if (matchTimer != null) { matchTimer.MatchEnd -= OnMatchEnd; } }
public override void OnStartServer() { ball = GameObject.FindGameObjectWithTag(Tags.BallTag); ballStartPosition = ball.transform.position; ballStartRotation = ball.transform.rotation; ballRigidbody = ball.GetComponent <Rigidbody>(); ballInitialMass = ballRigidbody.mass; goals = FindObjectsOfType <Goal>(); foreach (Goal goal in goals) { goal.Score += OnScore; } MatchTimer matchTimer = FindObjectOfType <MatchTimer>(); if (matchTimer != null) { matchTimer.MatchEnd += OnMatchEnd; } }