void InitializeScoreTrackers() { GameObject this_gost = Instantiate(score_tracker_prefab, new Vector3(-5.25f, -0.5f, 0), Quaternion.identity) as GameObject; GameObject other_gost = Instantiate(score_tracker_prefab, new Vector3(-5.25f, 0.5f, 0), Quaternion.identity) as GameObject; this_team_score_tracker = this_gost.GetComponent <ScoreTracker>(); opposing_team_score_tracker = other_gost.GetComponent <ScoreTracker>(); this_team_score_tracker.SetOwner(ScoreTracker.Owner.this_team); opposing_team_score_tracker.SetOwner(ScoreTracker.Owner.opposing_team); if (PhotonNetwork.connected) { this_team_score_tracker.InitializeScore(); opposing_team_score_tracker.InitializeScore(); if (PhotonNetwork.isMasterClient) { UnInvertObject(this_gost); UnInvertObject(other_gost); } } if (PhotonNetwork.connected && PhotonNetwork.playerList.Length == 1) { this_team_score_tracker.IsPracticeArena = true; opposing_team_score_tracker.IsPracticeArena = true; } }
/// <summary> /// For client, it may not be feasible to immediately bind ScoreTracker /// upon entering arena. This late binding resolves non-deterministic load order /// </summary> void LateBindScoreTrackers() { Debug.Log("Lazy initialization of ScoreTracker"); ScoreTracker[] sts = GameObject.FindObjectsOfType <ScoreTracker>(); foreach (ScoreTracker st in sts) { switch (st.ScoreOwner) { case ScoreTracker.Owner.this_team: this_team_st = st; this_team_st.InitializeScore(); break; case ScoreTracker.Owner.opposing_team: other_team_st = st; other_team_st.InitializeScore(); break; } } }