Exemplo n.º 1
0
    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));
        }
    }
Exemplo n.º 2
0
 public void OnStateFluxPlayerListing(PlayerListingMessage message)
 {
     ClearPlayerListView();
     if (_playersPanelContent == null)
     {
         return;
     }
     foreach (Player p in message.Players)
     {
         _players.Add(p);
         GameObject row         = GameObject.Instantiate(playerRowPrefab, _playersPanelContent.transform);
         var        textMeshPro = row.GetComponentInChildren <TextMeshProUGUI>();
         textMeshPro.text = p.Name;
         if (p.Color != null)
         {
             textMeshPro.color = StateFluxTypeConvert.Convert(p.Color);
         }
     }
 }