private void InitBallSelector()
    {
        if (m_BallSelector == null)
        {
            return;
        }

        SelectorData selectorData = new SelectorData();

        List <int> ballKeys = tnGameData.GetBallsKeysMain();

        if (ballKeys != null)
        {
            for (int ballIndex = 0; ballIndex < ballKeys.Count; ++ballIndex)
            {
                int        ballId   = ballKeys[ballIndex];
                tnBallData ballData = tnGameData.GetBallDataMain(ballId);

                SelectorItem selectorItem = new SelectorItem(ballId, ballData.name, "", ballData.icon);
                selectorData.AddItem(selectorItem);
            }
        }

        m_BallSelector.SetData(selectorData);
    }
    private void SetupGameModeSelector()
    {
        if (m_GameModeSelector == null)
        {
            return;
        }

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

        if (teamsModule == null)
        {
            return;
        }

        int maxTeamSize = 0;

        for (int teamIndex = 0; teamIndex < teamsModule.teamsCount; ++teamIndex)
        {
            tnTeamDescription teamDescription = teamsModule.GetTeamDescription(teamIndex);
            if (teamDescription != null)
            {
                maxTeamSize = Mathf.Max(teamDescription.charactersCount, maxTeamSize);
            }
        }

        SelectorData selectorData = new SelectorData();

        List <int> gameModesKeys = tnGameData.GetGameModesKeysMain();

        if (gameModesKeys != null)
        {
            for (int gameModeIndex = 0; gameModeIndex < gameModesKeys.Count; ++gameModeIndex)
            {
                int            gameModeId   = gameModesKeys[gameModeIndex];
                tnGameModeData gameModeData = tnGameData.GetGameModeDataMain(gameModeId);

                if (gameModeData == null)
                {
                    continue;
                }

                if (!gameModeData.hidden)
                {
                    IntRange teamsRange    = gameModeData.teamsRange;
                    IntRange teamSizeRange = gameModeData.playersPerTeamRange;

                    if (teamsRange.IsValueValid(teamsModule.teamsCount))
                    {
                        if (teamSizeRange.IsValueValid(maxTeamSize))
                        {
                            SelectorItem selectorItem = new SelectorItem(gameModeId, gameModeData.name, "", null);
                            selectorData.AddItem(selectorItem);
                        }
                    }
                }
            }
        }

        m_GameModeSelector.SetData(selectorData);
    }
    private void InitRefereeSelector()
    {
        if (m_RefereeSelector == null)
        {
            return;
        }

        SelectorData selectorData = new SelectorData();

        List <int> refereeOptionKeys = tnGameData.GetRefereeOptionKeysMain();

        if (refereeOptionKeys != null)
        {
            for (int refereeOptionIndex = 0; refereeOptionIndex < refereeOptionKeys.Count; ++refereeOptionIndex)
            {
                int refereeOptionId = refereeOptionKeys[refereeOptionIndex];

                string refereeOption;
                if (tnGameData.TryGetRefereeValueMain(refereeOptionId, out refereeOption))
                {
                    SelectorItem selectorItem = new SelectorItem(refereeOptionId, refereeOption, "", null);
                    selectorData.AddItem(selectorItem);
                }
            }
        }

        m_RefereeSelector.SetData(selectorData);
    }
    private void InitGoldenGoalSelector()
    {
        if (m_GoldenGoalSelector == null)
        {
            return;
        }

        SelectorData selectorData = new SelectorData();

        List <int> goldenGoalOptionKeys = tnGameData.GetGoldenGoalOptionKeysMain();

        if (goldenGoalOptionKeys != null)
        {
            for (int goldenGoalOptionIndex = 0; goldenGoalOptionIndex < goldenGoalOptionKeys.Count; ++goldenGoalOptionIndex)
            {
                int goldenGoalOptionId = goldenGoalOptionKeys[goldenGoalOptionIndex];

                string goldenGoalOption;
                if (tnGameData.TryGetGoldenGoalValueMain(goldenGoalOptionId, out goldenGoalOption))
                {
                    SelectorItem selectorItem = new SelectorItem(goldenGoalOptionId, goldenGoalOption, "", null);
                    selectorData.AddItem(selectorItem);
                }
            }
        }

        m_GoldenGoalSelector.SetData(selectorData);
    }
Ejemplo n.º 5
0
    // Max players

    private void SetupMaxPlayerSelector(int i_StadiumId)
    {
        SelectorData selectorData = new SelectorData();

        tnStadiumData stadiumData = tnGameData.GetStadiumDataMain(i_StadiumId);

        if (stadiumData != null)
        {
            int minPlayers = 2 * stadiumData.onlineTeamSize.min;
            int maxPlayers = 2 * stadiumData.onlineTeamSize.max;

            int localPartySize;
            PhotonUtils.TryGetPlayerCustomProperty <int>(PhotonNetwork.player, PhotonPropertyKey.s_PlayerCustomPropertyKey_LocalPartySize, out localPartySize);

            for (int numPlayers = minPlayers; numPlayers <= maxPlayers; numPlayers += 2)
            {
                if (numPlayers <= localPartySize)
                {
                    continue;
                }

                SelectorItem selectorItem = new SelectorItem(numPlayers, numPlayers.ToString(), "", null);
                selectorData.AddItem(selectorItem);
            }
        }

        if (viewInstance != null)
        {
            viewInstance.SetMaxPlayersSelectorData(selectorData);
        }

        RefreshMaxPlayers();
    }
    private void InitMatchDurationSelector()
    {
        if (m_MatchDurationSelector == null)
        {
            return;
        }

        SelectorData selectorData = new SelectorData();

        List <int> matchDurationKeys = tnGameData.GetMatchDurationOptionKeysMain();

        if (matchDurationKeys != null)
        {
            foreach (int key in matchDurationKeys)
            {
                float value;
                if (tnGameData.TryGetMatchDurationValueMain(key, out value))
                {
                    string time = TimeUtils.TimeToString(value, true, true);

                    SelectorItem selectorItem = new SelectorItem(key, time, "", null);
                    selectorData.AddItem(selectorItem);
                }
            }
        }

        m_MatchDurationSelector.SetData(selectorData);
    }
Ejemplo n.º 7
0
    // Ball

    private void SetupBallSelector()
    {
        SelectorData selectorData = new SelectorData();

        List <int> ballKeys = tnGameData.GetBallsKeysMain();

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

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

                tnBallData ballData = tnGameData.GetBallDataMain(key);

                if (ballData == null)
                {
                    continue;
                }

                SelectorItem selectorItem = new SelectorItem(key, ballData.name, "", ballData.icon);
                selectorData.AddItem(selectorItem);
            }
        }

        if (viewInstance != null)
        {
            viewInstance.SetBallSelectorData(selectorData);
        }
    }
Ejemplo n.º 8
0
    // Referee

    private void SetupRefereeSelector()
    {
        SelectorData selectorData = new SelectorData();

        List <int> refereeOptionKeys = tnGameData.GetRefereeOptionKeysMain();

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

                string value;
                if (tnGameData.TryGetRefereeValueMain(key, out value))
                {
                    SelectorItem selectorItem = new SelectorItem(key, value, "", null);
                    selectorData.AddItem(selectorItem);
                }
            }
        }

        if (viewInstance != null)
        {
            viewInstance.SetRefereeSelectorData(selectorData);
        }
    }
Ejemplo n.º 9
0
    // Duration

    private void SetupMatchDurationSelector()
    {
        SelectorData selectorData = new SelectorData();

        List <int> matchDurationKeys = tnGameData.GetMatchDurationOptionKeysMain();

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

                float value;
                if (tnGameData.TryGetMatchDurationValueMain(key, out value))
                {
                    string time = TimeUtils.TimeToString(value, true, true);

                    SelectorItem selectorItem = new SelectorItem(key, time, "", null);
                    selectorData.AddItem(selectorItem);
                }
            }
        }

        if (viewInstance != null)
        {
            viewInstance.SetMatchDurationSelectorData(selectorData);
        }
    }
Ejemplo n.º 10
0
    // Game mode

    private void SetupGameModeSelector()
    {
        SelectorData selectorData = new SelectorData();

        List <int> gameModesKeys = tnGameData.GetGameModesKeysMain();

        if (gameModesKeys != null)
        {
            for (int gameModeIndex = 0; gameModeIndex < gameModesKeys.Count; ++gameModeIndex)
            {
                int gameModeId = gameModesKeys[gameModeIndex];

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

                tnGameModeData gameModeData = tnGameData.GetGameModeDataMain(gameModeId);

                if (gameModeData == null)
                {
                    continue;
                }

                if (!gameModeData.hidden)
                {
                    IntRange teamSizeRange = gameModeData.onlinePlayersPerTeamRange;

                    int localPartySize;
                    PhotonUtils.TryGetPlayerCustomProperty <int>(PhotonPropertyKey.s_PlayerCustomPropertyKey_LocalPartySize, out localPartySize);

                    bool teamSizeInvalid = (localPartySize >= teamSizeRange.max * 2);

                    if (!teamSizeInvalid)
                    {
                        SelectorItem selectorItem = new SelectorItem(gameModeId, gameModeData.name, "", null);
                        selectorData.AddItem(selectorItem);
                    }
                }
            }
        }

        if (viewInstance != null)
        {
            viewInstance.SetGameModeSelectorData(selectorData);
        }
    }
    private void InitResolutionSelector()
    {
        if (m_ResolutionSelector == null)
        {
            return;
        }

        SelectorData selectorData = new SelectorData();

        for (int resolutionIndex = 0; resolutionIndex < Screen.resolutions.Length; ++resolutionIndex)
        {
            Resolution   resolution   = Screen.resolutions[resolutionIndex];
            string       label        = resolution.ToString();
            SelectorItem selectorItem = new SelectorItem(resolutionIndex, label, "", null);
            selectorData.AddItem(selectorItem);
        }

        m_ResolutionSelector.SetData(selectorData);
    }
    private void InitResolutionSelector()
    {
        SelectorData selectorData = new SelectorData();

        Resolution[] resolutions = Screen.resolutions;

        if (resolutions != null)
        {
            for (int resolutionIndex = 0; resolutionIndex < resolutions.Length; ++resolutionIndex)
            {
                Resolution   resolution   = resolutions[resolutionIndex];
                string       label        = resolution.ToString();
                SelectorItem selectorItem = new SelectorItem(resolutionIndex, label, "", null);
                selectorData.AddItem(selectorItem);
            }
        }

        if (viewInstance != null)
        {
            viewInstance.SetResolutionSelectorData(selectorData);
        }
    }
    private void SetupAILevelSelector()
    {
        if (m_AILevelSelector == null)
        {
            return;
        }

        SelectorData selectorData = new SelectorData();

        for (int aiLevelIndex = 0; aiLevelIndex < tnGameData.aiLevelCountMain; ++aiLevelIndex)
        {
            tnAILevel aiLevel = tnGameData.GetAILevelMain(aiLevelIndex);

            if (aiLevel == null)
            {
                continue;
            }

            SelectorItem selectorItem = new SelectorItem(aiLevelIndex, aiLevel.label, "", null);
            selectorData.AddItem(selectorItem);
        }

        m_AILevelSelector.SetData(selectorData);
    }
    private void SetupStadiumSelector(int i_GameModeId)
    {
        if (m_StadiumSelector == null)
        {
            return;
        }

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

        if (teamModule == null)
        {
            return;
        }

        int maxTeamSize = 0;

        for (int teamIndex = 0; teamIndex < teamModule.teamsCount; ++teamIndex)
        {
            tnTeamDescription teamDescription = teamModule.GetTeamDescription(teamIndex);
            if (teamDescription != null)
            {
                maxTeamSize = Mathf.Max(teamDescription.charactersCount, maxTeamSize);
            }
        }

        SelectorData selectorData = new SelectorData();

        List <int> stadiumKeys = tnGameData.GetStadiumsKeysMain();

        if (stadiumKeys != null)
        {
            tnGameModeData gameModeData = tnGameData.GetGameModeDataMain(i_GameModeId);

            for (int stadiumIndex = 0; stadiumIndex < stadiumKeys.Count; ++stadiumIndex)
            {
                int           stadiumId   = stadiumKeys[stadiumIndex];
                tnStadiumData stadiumData = tnGameData.GetStadiumDataMain(stadiumId);

                if (stadiumData == null)
                {
                    continue;
                }

                bool excludedByTag = false;

                if (gameModeData != null)
                {
                    for (int excluderTagIndex = 0; excluderTagIndex < gameModeData.fieldsExcludersTagsCount; ++excluderTagIndex)
                    {
                        int excluderTag = gameModeData.GetFieldExcluderTag(excluderTagIndex);
                        if (excluderTag != Hash.s_EMPTY && excluderTag != Hash.s_NULL)
                        {
                            if (stadiumData.HasTag(excluderTag))
                            {
                                excludedByTag = true;
                            }
                        }
                    }
                }

                IntRange teamSizeRange = stadiumData.teamSize;

                bool   locked       = excludedByTag || !(teamSizeRange.IsValueValid(maxTeamSize));
                string lockedString = "";

                if (locked)
                {
                    if (excludedByTag)
                    {
                        lockedString = "Not available in this game mode.";
                    }
                    else
                    {
                        lockedString = "From " + teamSizeRange.min + " to " + teamSizeRange.max + " players";
                    }
                }

                SelectorItem selectorItem = new SelectorItem(stadiumId, stadiumData.name, stadiumData.description, stadiumData.icon, locked, lockedString);
                selectorData.AddItem(selectorItem);
            }
        }

        m_StadiumSelector.SetData(selectorData);
    }
Ejemplo n.º 15
0
    // Stadium

    private void SetupStadiumSelector(int i_GameModeId)
    {
        SelectorData selectorData = new SelectorData();

        List <int> stadiumKeys = tnGameData.GetStadiumsKeysMain();

        if (stadiumKeys == null)
        {
            return;
        }

        tnGameModeData gameModeData = tnGameData.GetGameModeDataMain(i_GameModeId);

        for (int stadiumIndex = 0; stadiumIndex < stadiumKeys.Count; ++stadiumIndex)
        {
            int           stadiumId   = stadiumKeys[stadiumIndex];
            tnStadiumData stadiumData = tnGameData.GetStadiumDataMain(stadiumId);

            if (stadiumData == null)
            {
                continue;
            }

            if (stadiumData.hiddenOnline)
            {
                continue;
            }

            bool excludedByTag = false;

            if (gameModeData != null)
            {
                for (int excluderTagIndex = 0; excluderTagIndex < gameModeData.fieldsExcludersTagsCount; ++excluderTagIndex)
                {
                    int excluderTag = gameModeData.GetFieldExcluderTag(excluderTagIndex);

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

                    excludedByTag |= stadiumData.HasTag(excluderTag);
                }
            }

            IntRange teamSizeRange = stadiumData.onlineTeamSize;

            int localPartySize;
            PhotonUtils.TryGetPlayerCustomProperty <int>(PhotonNetwork.player, PhotonPropertyKey.s_PlayerCustomPropertyKey_LocalPartySize, out localPartySize);

            bool teamSizeInvalid = (localPartySize >= teamSizeRange.max * 2);

            bool locked = excludedByTag || teamSizeInvalid;

            SelectorItem selectorItem = new SelectorItem(stadiumId, stadiumData.name, stadiumData.description, stadiumData.icon, locked, String.Empty);
            selectorData.AddItem(selectorItem);
        }

        if (viewInstance != null)
        {
            viewInstance.SetStadiumSelectorData(selectorData);
        }

        SelectFirstUnlockedStadium();
    }