private void ClearInputModule()
        {
            InputModule inputModule = UIEventSystem.inputModuleMain;

            if (inputModule == null)
            {
                return;
            }

            inputModule.Clear();
        }
Example #2
0
        public override void OnEnter()
        {
            InputModule inputModule = UIEventSystem.inputModuleMain;

            if (inputModule != null)
            {
                inputModule.Clear();
            }

            Finish();
        }
Example #3
0
    private void SetupInputModule()
    {
        InputModule inputModule = UIEventSystem.inputModuleMain;

        if (inputModule == null)
        {
            return;
        }

        inputModule.Clear();

        tnLocalPartyModule localPartyModule = GameModulesManager.GetModuleMain <tnLocalPartyModule>();

        if (localPartyModule != null)
        {
            for (int playerIndex = 0; playerIndex < localPartyModule.playersCount; ++playerIndex)
            {
                int playerId = localPartyModule.GetPlayerId(playerIndex);

                if (Hash.IsNullOrEmpty(playerId))
                {
                    continue;
                }

                tnPlayerData playerData = tnGameData.GetPlayerDataMain(playerId);

                if (playerData == null)
                {
                    continue;
                }

                string playerInputName     = playerData.playerInputName;
                string wifiPlayerInputName = playerData.wifiPlayerInputName;

                PlayerInput     playerInput    = InputSystem.GetPlayerByNameMain(playerInputName);
                WiFiPlayerInput wifiPlyerInput = WiFiInputSystem.GetPlayerByNameMain(wifiPlayerInputName);

                if (playerInput != null)
                {
                    inputModule.AddPlayer(playerInput);
                }
                else
                {
                    if (wifiPlyerInput != null)
                    {
                        inputModule.AddWifiPlayer(wifiPlyerInput);
                    }
                }
            }
        }
    }
Example #4
0
    private void SetAllPlayersOnInputModule()
    {
        InputModule inputModule = UIEventSystem.inputModuleMain;

        if (inputModule == null)
        {
            return;
        }

        inputModule.Clear();

        List <int> playersIds = tnGameData.GetPlayersKeysMain();

        if (playersIds != null)
        {
            for (int index = 0; index < playersIds.Count; ++index)
            {
                int playerId = playersIds[index];

                if (Hash.IsNullOrEmpty(playerId))
                {
                    continue;
                }

                tnPlayerData playerData = tnGameData.GetPlayerDataMain(playerId);

                if (playerData == null)
                {
                    continue;
                }

                string playerInputName     = playerData.playerInputName;
                string wifiPlayerInputName = playerData.wifiPlayerInputName;

                PlayerInput     playerInput     = InputSystem.GetPlayerByNameMain(playerInputName);
                WiFiPlayerInput wifiPlayerInput = WiFiInputSystem.GetPlayerByNameMain(wifiPlayerInputName);

                if (playerInput != null)
                {
                    inputModule.AddPlayer(playerInput);
                }
                else
                {
                    if (wifiPlayerInput != null)
                    {
                        inputModule.AddWifiPlayer(wifiPlayerInput);
                    }
                }
            }
        }
    }
Example #5
0
    private void SetLocalPartyOnInputModule()
    {
        InputModule inputModule = UIEventSystem.inputModuleMain;

        if (inputModule != null)
        {
            inputModule.Clear();

            tnLocalPartyModule localPartyModule = GameModulesManager.GetModuleMain <tnLocalPartyModule>();
            if (localPartyModule != null)
            {
                for (int index = 0; index < localPartyModule.playersCount; ++index)
                {
                    int playerId = localPartyModule.GetPlayerId(index);

                    if (Hash.IsNullOrEmpty(playerId))
                    {
                        continue;
                    }

                    tnPlayerData playerData = tnGameData.GetPlayerDataMain(playerId);

                    if (playerData == null)
                    {
                        continue;
                    }

                    string playerInputName     = playerData.playerInputName;
                    string wifiPlayerInputName = playerData.wifiPlayerInputName;

                    if (!StringUtils.IsNullOrEmpty(playerInputName))
                    {
                        inputModule.AddPlayer(playerInputName);
                    }
                    else
                    {
                        if (!StringUtils.IsNullOrEmpty(wifiPlayerInputName))
                        {
                            inputModule.AddWifiPlayer(wifiPlayerInputName);
                        }
                    }
                }
            }
        }
    }
Example #6
0
    private void SetLocalCaptainOnInputModule()
    {
        InputModule inputModule = UIEventSystem.inputModuleMain;

        if (inputModule != null)
        {
            inputModule.Clear();

            tnLocalPartyModule localPartyModule = GameModulesManager.GetModuleMain <tnLocalPartyModule>();
            if (localPartyModule != null)
            {
                int captainId = localPartyModule.captainId;
                if (Hash.IsValid(captainId))
                {
                    tnPlayerData playerData = tnGameData.GetPlayerDataMain(captainId);
                    if (playerData != null)
                    {
                        string playerInputName     = playerData.playerInputName;
                        string wifiPlayerInputName = playerData.wifiPlayerInputName;

                        if (!StringUtils.IsNullOrEmpty(playerInputName))
                        {
                            inputModule.AddPlayer(playerInputName);
                        }
                        else
                        {
                            if (!StringUtils.IsNullOrEmpty(wifiPlayerInputName))
                            {
                                inputModule.AddWifiPlayer(wifiPlayerInputName);
                            }
                        }
                    }
                }
            }
        }
    }
Example #7
0
 protected virtual void OnPause(GamePauseState state)
 {
     InputModule.Clear();
 }
    private void SetupInputModule()
    {
        InputModule inputModule = UIEventSystem.inputModuleMain;

        if (inputModule == null)
        {
            return;
        }

        inputModule.Clear();

        tnTeamsModule teamsModule = GameModulesManager.GetModuleMain <tnTeamsModule>();

        if (teamsModule != null)
        {
            for (int teamIndex = 0; teamIndex < teamsModule.teamsCount; ++teamIndex)
            {
                tnTeamDescription teamDescription = teamsModule.GetTeamDescription(teamIndex);

                if (teamDescription == null)
                {
                    continue;
                }

                for (int characterIndex = 0; characterIndex < teamDescription.charactersCount; ++characterIndex)
                {
                    tnCharacterDescription characterDescription = teamDescription.GetCharacterDescription(characterIndex);

                    if (characterDescription == null)
                    {
                        continue;
                    }

                    int playerId = characterDescription.playerId;

                    if (Hash.IsNullOrEmpty(playerId))
                    {
                        continue;
                    }

                    tnPlayerData playerData = tnGameData.GetPlayerDataMain(playerId);

                    if (playerData == null)
                    {
                        continue;
                    }

                    string playerInputName     = playerData.playerInputName;
                    string wifiPlayerInputName = playerData.wifiPlayerInputName;

                    PlayerInput     playerInput    = InputSystem.GetPlayerByNameMain(playerInputName);
                    WiFiPlayerInput wifiPlyerInput = WiFiInputSystem.GetPlayerByNameMain(wifiPlayerInputName);

                    if (playerInput != null)
                    {
                        inputModule.AddPlayer(playerInput);
                    }
                    else
                    {
                        if (wifiPlyerInput != null)
                        {
                            inputModule.AddWifiPlayer(wifiPlyerInput);
                        }
                    }
                }
            }
        }
    }
        public override void OnEnter()
        {
            InputModule inputModule = UIEventSystem.inputModuleMain;

            if (inputModule != null)
            {
                // Clear input module.

                inputModule.Clear();

                // Handle players.

                if (useAllPlayers != null && useAllPlayers.Value)
                {
                    for (int playerIndex = 0; playerIndex < InputSystem.numPlayersMain; ++playerIndex)
                    {
                        PlayerInput playerInput = InputSystem.GetPlayerByIndexMain(playerIndex);
                        inputModule.AddPlayer(playerInput);
                    }
                }
                else
                {
                    if (players != null)
                    {
                        for (int playerIndex = 0; playerIndex < players.Length; ++playerIndex)
                        {
                            FsmString str = players[playerIndex];
                            if (!str.IsNone && str.Value != "")
                            {
                                inputModule.AddPlayer(str.Value);
                            }
                        }
                    }
                }

                // Handle wifi players.

                if (useAllWifiPlayers != null && useAllWifiPlayers.Value)
                {
                    for (int playerIndex = 0; playerIndex < WiFiInputSystem.playersCountMain; ++playerIndex)
                    {
                        WiFiPlayerInput playerInput = WiFiInputSystem.GetPlayerByIndexMain(playerIndex);
                        inputModule.AddWifiPlayer(playerInput);
                    }
                }
                else
                {
                    if (wifiPlayers != null)
                    {
                        for (int playerIndex = 0; playerIndex < wifiPlayers.Length; ++playerIndex)
                        {
                            FsmString str = wifiPlayers[playerIndex];
                            if (!str.IsNone && str.Value != "")
                            {
                                inputModule.AddWifiPlayer(str.Value);
                            }
                        }
                    }
                }
            }

            Finish();
        }
Example #10
0
    protected override void OnUpdate(float i_DeltaTime)
    {
        base.OnUpdate(i_DeltaTime);

        if (viewInstance == null || !viewInstance.isOpen)
        {
            return;
        }

        // Clear change flags.

        for (int index = 0; index < m_ChangeFlags.Length; ++index)
        {
            m_ChangeFlags[index] = false;
        }

        int freeSlot = GetFreeSlotCount();

        // Listen for new join.

        if (m_ReceiveInput)
        {
            if (freeSlot > 0)
            {
                List <int> playersIds = tnGameData.GetPlayersKeysMain();

                if (playersIds != null)
                {
                    for (int index = 0; index < playersIds.Count; ++index)
                    {
                        int playerId = playersIds[index];

                        if (IsAlreadyJoined(playerId))
                        {
                            continue;
                        }

                        bool startPressed = tnInputUtils.GetButtonDown(playerId, "Start");

                        if (startPressed)
                        {
                            int targetIndex = GetFirstFreeSlotIndex();
                            if (targetIndex >= 0)
                            {
                                m_JoinedPlayerIds[targetIndex] = playerId;
                                m_ChangeFlags[targetIndex]     = true;

                                --freeSlot;
                            }
                        }
                    }
                }
            }

            // Check if someone leave the group.

            for (int index = 0; index < m_JoinedPlayerIds.Length; ++index)
            {
                int playerId = m_JoinedPlayerIds[index];

                if (Hash.IsNullOrEmpty(playerId))
                {
                    continue;
                }

                bool cancelPressed = tnInputUtils.GetButtonDown(playerId, "Cancel");

                if (cancelPressed)
                {
                    m_JoinedPlayerIds[index] = Hash.s_NULL;
                    m_ChangeFlags[index]     = true;

                    ++freeSlot;
                }
            }
        }

        // Cache if something has changed.

        bool somethingChanged = false;

        for (int index = 0; index < m_ChangeFlags.Length; ++index)
        {
            somethingChanged |= m_ChangeFlags[index];
        }

        // Set players on input module.

        if (somethingChanged)
        {
            if (IsAllFree())
            {
                SetAllPlayersOnInputModule();
            }
            else
            {
                InputModule inputModule = UIEventSystem.inputModuleMain;
                if (inputModule != null)
                {
                    inputModule.Clear();

                    for (int index = 0; index < m_JoinedPlayerIds.Length; ++index)
                    {
                        int playerId = m_JoinedPlayerIds[index];

                        if (Hash.IsNullOrEmpty(playerId))
                        {
                            continue;
                        }

                        PlayerInput     playerInput;
                        WiFiPlayerInput wifiPlayerInput;
                        tnInputUtils.GetPlayersInputs(playerId, out playerInput, out wifiPlayerInput);

                        if (playerInput != null)
                        {
                            inputModule.AddPlayer(playerInput);
                        }
                        else
                        {
                            if (wifiPlayerInput != null)
                            {
                                inputModule.AddWifiPlayer(wifiPlayerInput);
                            }
                        }
                    }
                }
            }
        }

        // Update view.

        if (somethingChanged)
        {
            // Update slots.

            int    joinedIndex      = 0;
            string photonPlayerName = PhotonNetwork.playerName;

            for (int index = 0; index < m_JoinedPlayerIds.Length; ++index)
            {
                bool changed  = m_ChangeFlags[index];
                int  playerId = m_JoinedPlayerIds[index];

                bool isFree = Hash.IsNullOrEmpty(playerId);

                if (!isFree)
                {
                    SetPlayerName(index, photonPlayerName, joinedIndex);
                    ++joinedIndex;
                }

                if (!changed)
                {
                    continue;
                }

                if (isFree)
                {
                    // Free slot.

                    FreePlayerSlot(index);
                }
                else
                {
                    // Set slot.

                    SetPlayerSlot(index, playerId);
                }
            }

            // Update triggers.

            if (IsAllFree())
            {
                viewInstance.SetProceedTriggerCanSend(false);

                viewInstance.SetCancelTriggerActive(false);
                viewInstance.SetCancelTriggerCanSend(false);

                viewInstance.SetBackTriggerActive(true);
                viewInstance.SetBackTriggerCanSend(true);
            }
            else
            {
                viewInstance.SetProceedTriggerCanSend(true);

                viewInstance.SetCancelTriggerActive(true);
                viewInstance.SetCancelTriggerCanSend(true);

                viewInstance.SetBackTriggerActive(false);
                viewInstance.SetBackTriggerCanSend(false);
            }
        }
    }