void Start() { gameObjectTracker = new GameObjectTracker(); lastGuestInput = new GuestInput(); miceTracker = new MiceTracker(); Cursor.visible = false; stateFluxClient = GameObject.Find("StateFlux").GetComponent <StateFluxClient>(); if (stateFluxClient == null) { DebugLog("Failed to connect with StateFluxClient"); return; } stateFluxClient.AddListener(this); // lobby makes sure we are logged in before starting a game playerId = stateFluxClient.clientId; // when the game instance starts, LobbyManager receives a game instance start notification and saves these // we copy them here for convenience hostPlayer = LobbyManager.Instance.hostPlayer; players = LobbyManager.Instance.players; thisPlayer = players[playerId]; thatPlayer = players.Values.Where(p => p.Id != playerId).FirstOrDefault(); CreateMousePointerGameObjects(); if (stateFluxClient.isHosting) { var g = GameObject.Find("State_IsGuest"); g.SetActive(false); var textMesh = g.GetComponentInChildren <TextMesh>(); if (textMesh != null) { textMesh.color = StateFluxTypeConvert.Convert(thisPlayer.Color); } StartCoroutine(gameObjectTracker.SendStateAsHost()); } else { var g = GameObject.Find("State_IsHost"); g.SetActive(false); var textMesh = g.GetComponentInChildren <TextMesh>(); if (textMesh != null) { textMesh.color = StateFluxTypeConvert.Convert(thisPlayer.Color); } StartCoroutine(nameof(SendInputAsGuest)); } }
public IEnumerator Initialize() { yield return(new WaitForEndOfFrame()); _players = new List <Player>(); _games = new List <GameInstance>(); _said = new List <ChatSaidMessage>(); _lastUsernameSaveFile = Application.persistentDataPath + (Application.isEditor ? "/lastUsername-editor.txt" : "/lastUsername.txt"); FindGameObjects(); SceneManager.activeSceneChanged += ChangedActiveScene; StateFluxClient client = StateFluxClient.Instance; client.AddListener(this); StateFluxClient.Instance.Initialize(); StartCoroutine(StateFluxClient.Instance.hasSavedSession ? ActivateLobbyPanel() : ActivateLoginPanel()); Initialized = true; }