Exemplo n.º 1
0
    public void OnSetReadyMessage(int deviceId, SetReadyMessage setReadyMessage)
    {
        var playerIndex = IndexOfPlayerWithDeviceId(deviceId);

        if (playerIndex < 0)
        {
            return;
        }

        if (_currentGameState == GameState.OnLobby)
        {
            var globalPlayer = _globalPlayers[playerIndex];
            globalPlayer.LobbyPlayerData.IsReady = setReadyMessage.IsReady;

            var lobbyController = LobbyController.FindInScene();
            lobbyController.OnLobbyPlayerDataChanged(globalPlayer.LobbyPlayerData);
            AirConsoleBridge.Instance.BroadcastCharacterSetChanged(_globalPlayers);
        }
        else if (_currentGameState == GameState.OnGame)
        {
            IPlayerToGameStateBridge playerOnGame;
            if (_deviceIdToGameCharacterMap.TryGetValue(deviceId, out playerOnGame))
            {
                playerOnGame.OnSetReadyMessage(setReadyMessage);
            }
        }
    }
Exemplo n.º 2
0
    public void OnDeviceDisconnected(int deviceId)
    {
        if (_currentGameState == GameState.OnLobby)
        {
            var indexOfPlayerWithDeviceId = IndexOfPlayerWithDeviceId(deviceId);
            if (indexOfPlayerWithDeviceId >= 0)
            {
                var globalPlayer    = _globalPlayers[indexOfPlayerWithDeviceId];
                var lobbyController = LobbyController.FindInScene();

                lobbyController.OnLobbyPlayerDisconnected(globalPlayer.LobbyPlayerData.Id);

                // Tell the Lobby that this guy has disconnected
                _globalPlayers.RemoveAt(indexOfPlayerWithDeviceId);
            }
        }
        else if (_currentGameState == GameState.OnGame)
        {
            IPlayerToGameStateBridge gameCharacter;
            if (_deviceIdToGameCharacterMap.TryGetValue(deviceId, out gameCharacter))
            {
                gameCharacter.DeviceId = 0; // No device Id
            }
        }
    }
Exemplo n.º 3
0
    public void OnSetAvatarIndexMessage(int deviceId, SetAvatarIndexMessage setAvatarIndexMessage)
    {
        var playerIndex = IndexOfPlayerWithDeviceId(deviceId);

        if (playerIndex < 0)
        {
            return;
        }

        var globalPlayer = _globalPlayers[playerIndex];

        if (globalPlayer.AvatarIndex != setAvatarIndexMessage.AvatarIndex)
        {
            if (_currentGameState == GameState.OnLobby && IsAvatarAvailable(setAvatarIndexMessage.AvatarIndex))
            {
                globalPlayer.AvatarIndex = setAvatarIndexMessage.AvatarIndex;
                var lobbyController = LobbyController.FindInScene();

                lobbyController.OnLobbyPlayerDataChanged(globalPlayer.LobbyPlayerData);
            }

            AirConsoleBridge.Instance.SendOrUpdateAvatarForPlayer(globalPlayer);
            AirConsoleBridge.Instance.BroadcastCharacterSetChanged(_globalPlayers);
        }
    }
Exemplo n.º 4
0
    private void RegisterPlayerInLobby(GlobalPlayer globalPlayer)
    {
        var lobbyController = LobbyController.FindInScene();

        lobbyController.OnLobbyPlayerConnected(globalPlayer.LobbyPlayerData);
        AirConsoleBridge.Instance.SendOrUpdateAvatarForPlayer(globalPlayer);
        AirConsoleBridge.Instance.BroadcastCharacterSetChanged(_globalPlayers);
    }
Exemplo n.º 5
0
    public void LinkExistingPlayers()
    {
        var lobbyController = LobbyController.FindInScene();

        if (lobbyController == null)
        {
            Debug.LogError("NO LOBBYCONTROLLER FOUND!");
            return;
        }

        foreach (var globalPlayer in _globalPlayers)
        {
            RegisterPlayerInLobby(globalPlayer);
        }
    }