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);
    }
示例#2
0
    public tnGameModeData GetData(int i_Id)
    {
        tnGameModeData data = null;

        m_Data.TryGetValue(i_Id, out data);
        return(data);
    }
示例#3
0
    // LOGIC

    public void Initialize(string i_DatabasePath)
    {
        tnGameModesDatabase database = Resources.Load <tnGameModesDatabase>(i_DatabasePath);

        if (database != null)
        {
            for (int index = 0; index < database.count; ++index)
            {
                tnGameModeDataEntry entry = database.GetGameModeDataEntry(index);
                if (entry != null)
                {
                    tnGameModeDataDescriptor descriptor = entry.descriptor;
                    if (descriptor != null)
                    {
                        int            hash = StringUtils.GetHashCode(entry.id);
                        tnGameModeData data = new tnGameModeData(descriptor);
                        m_Data.Add(hash, data);
                        m_Keys.Add(hash);
                    }
                }
            }
        }
        else
        {
            LogManager.LogWarning(this, "Database not loaded.");
        }
    }
示例#4
0
    // INTERNALS

    private void Setup()
    {
        ClearAll();

        // Setup game mode selector.

        SetupGameModeSelector();

        // Setup match duration selector.

        SetupMatchDurationSelector();

        // Setup golden goal selector.

        SetupGoldenGoalSelector();

        // Setup referee selector.

        SetupRefereeSelector();

        // Setup ball selector.

        SetupBallSelector();

        // Select first game mode.

        SelectGameModeIndex(0);

        // Reset selectors to default value.

        int gameModeId = selectedGameModeId;

        tnGameModeData gameModeData = tnGameData.GetGameModeDataMain(gameModeId);

        if (gameModeData != null)
        {
            tnGameModeConfig gameModeConfig = tnGameData.GetConfigDataMain(gameModeData.optionsConfigId);
            if (gameModeConfig != null)
            {
                SelectMatchDuration(gameModeConfig.matchDurationOption);
                SelectReferee(gameModeConfig.refereeOption);
                SelectGoldenGoal(gameModeConfig.goldenGoalOption);
            }
        }

        // Select first ball.

        SelectBallIndex(0);

        // Setup stadium selector.

        SetupStadiumSelector(gameModeId);

        // Setup max players.

        SetupMaxPlayerSelector(selectedStadiumId);
    }
    void OnEnable()
    {
        // Refresh Game mode selector.

        SetupGameModeSelector();

        // Reset selectors to default values (specified into each tnGameModeConfig).

        SelectGameModeIndex(0);

        if (m_GameModeSelector != null)
        {
            SelectorItem currentGameMode = m_GameModeSelector.currentItem;
            if (currentGameMode != null)
            {
                int            gameModeId   = currentGameMode.id;
                tnGameModeData gameModeData = tnGameData.GetGameModeDataMain(gameModeId);
                if (gameModeData != null)
                {
                    tnGameModeConfig gameModeConfig = tnGameData.GetConfigDataMain(gameModeData.optionsConfigId);
                    if (gameModeConfig != null)
                    {
                        SelectMatchDuration(gameModeConfig.matchDurationOption);
                        SelectReferee(gameModeConfig.refereeOption);
                        SelectGoldenGoal(gameModeConfig.goldenGoalOption);
                    }
                }

                SetupStadiumSelector(gameModeId);
            }
        }

        SelectBallIndex(0);
        SelectFirstUnlockedStadium();

        SetupAILevelSelector();
        SelectAILevel(tnGameData.aiLevelCountMain / 2);

        int aiCount = GetAICount();

        if (m_AILevelSelector != null)
        {
            m_AILevelSelector.interactable = (aiCount > 0);
        }

        // Adjust navigation.

        AdjustAISelectorNavigation(aiCount);

        // Register on events.

        if (m_GameModeSelector != null)
        {
            m_GameModeSelector.onChangeSelection.AddListener(OnGameModeSelectedChanged);
        }
    }
        private void SetupMatchSettingsModule()
        {
            tnMatchSettingsModule module = GameModulesManager.GetModuleMain <tnMatchSettingsModule>();

            if (module == null)
            {
                return;
            }

            module.Clear();

            // Game mode.

            {
                module.SetGameModeId(gameMode.Value);
            }

            // Stadium.

            {
                int stadiumKey = -1;
                GetRandomStadiumKey(gameMode.Value, out stadiumKey);

                module.SetStadiumId(stadiumKey);
            }

            // Ball.

            {
                int ballKey = -1;
                GetRandomBallKey(out ballKey);

                module.SetBallId(ballKey);
            }

            // Ai level.

            {
                module.SetAILevelIndex(tnGameData.aiLevelCountMain - 1);
            }

            // Options.

            {
                tnGameModeData gameModeData = tnGameData.GetGameModeDataMain(gameMode.Value);
                if (gameModeData != null)
                {
                    tnGameModeConfig gameModeConfig = tnGameData.GetConfigDataMain(gameModeData.optionsConfigId);
                    if (gameModeConfig != null)
                    {
                        module.SetMatchDurationOption(gameModeConfig.matchDurationOption);
                        module.SetRefereeOption(gameModeConfig.refereeOption);
                    }
                }
            }
        }
示例#7
0
    private void CreateCharacters()
    {
        // Cache character prefab path.

        tnMatchSettingsModule matchSettingsModule = GameModulesManager.GetModuleMain <tnMatchSettingsModule>();

        if (matchSettingsModule != null)
        {
            int gameModeId = matchSettingsModule.gameModeId;
            m_GameModeId = gameModeId;
            tnGameModeData gameModeData = tnGameData.GetGameModeDataMain(gameModeId);

            if (gameModeData != null)
            {
                m_CharacterPrefab = gameModeData.LoadAndGetCharacterPrefabPath();
            }
        }

        // Create teams.

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

        if (teamsModule == null)
        {
            return;
        }

        for (int teamIndex = 0; teamIndex < teamsModule.teamsCount; ++teamIndex)
        {
            List <GameObject> team = new List <GameObject>();
            m_Teams.Add(team);
        }

        for (int teamIndex = 0; teamIndex < teamsModule.teamsCount; ++teamIndex)
        {
            List <tnAIInputFiller> aiList = new List <tnAIInputFiller>();
            m_LocalAI.Add(aiList);
        }

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

            if (teamDescription == null)
            {
                continue;
            }

            ProceesTeam(teamIndex, teamDescription);
        }

        // Disable Input

        DisableInput();
    }
        private void GetRandomStadiumKey(string i_GameModeId, out int o_StadiumKey)
        {
            List <int> allowedStadiumKeys = new List <int>();

            int minTeamSize;
            int maxTeamSize;

            GetTeamSize(out minTeamSize, out maxTeamSize);

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

            tnGameModeData gameModeData = tnGameData.GetGameModeDataMain(i_GameModeId);

            for (int stadiumIndex = 0; stadiumIndex < stadiyumKeys.Count; ++stadiumIndex)
            {
                int currentStadiumKey = stadiyumKeys[stadiumIndex];

                tnStadiumData stadiumData = tnGameData.GetStadiumDataMain(currentStadiumKey);

                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 allowedTeamSize = stadiumData.teamSize;

                bool locked = excludedByTag || !allowedTeamSize.IsValueValid(maxTeamSize) || !allowedTeamSize.IsValueValid(minTeamSize);
                if (!locked)
                {
                    allowedStadiumKeys.Add(currentStadiumKey);
                }
            }

            int stadiumKey = Hash.s_NULL;

            if (allowedStadiumKeys.Count > 0)
            {
                int randomIndex = Random.Range(0, allowedStadiumKeys.Count);
                stadiumKey = allowedStadiumKeys[randomIndex];
            }

            o_StadiumKey = stadiumKey;
        }
        private void SetupTeamsModule()
        {
            tnTeamsModule teamsModule = GameModulesManager.GetModuleMain <tnTeamsModule>();

            if (teamsModule == null)
            {
                return;
            }

            teamsModule.Clear();

            tnGameModeData gameModeData = tnGameData.GetGameModeDataMain(gameMode.Value);

            if (gameModeData == null)
            {
                return;
            }

            int numTeams = Random.Range(gameModeData.teamsRange.min, gameModeData.teamsRange.max);

            int minTeamSize = gameModeData.playersPerTeamRange.min;
            int maxTeamSize = gameModeData.playersPerTeamRange.max;

            if (forceTeamSize != null && forceTeamSize.Value)
            {
                if (forcedMinTeamSize != null && forcedMinTeamSize.Value > 0)
                {
                    minTeamSize = forcedMinTeamSize.Value;
                }

                if (forcedMaxTeamSize != null && forcedMaxTeamSize.Value > 0)
                {
                    maxTeamSize = forcedMaxTeamSize.Value;
                }
            }

            int[] teamIds = SelectTeams(numTeams);

            if (teamIds != null)
            {
                int teamSize = Random.Range(minTeamSize, maxTeamSize);

                Color[] teamColors = Utils.ComputeTeamColors(teamIds);

                for (int teamIndex = 0; teamIndex < teamIds.Length; ++teamIndex)
                {
                    int   teamId    = teamIds[teamIndex];
                    Color teamColor = teamColors[teamIndex];

                    tnTeamDescription teamDescription = CreateTeam(teamId, teamSize, teamColor);
                    teamsModule.AddTeamDescription(teamDescription);
                }
            }
        }
示例#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);
        }
    }
    // INTERNALS

    private void ShowInfo()
    {
        tnMatchSettingsModule matchSettingsModule = GameModulesManager.GetModuleMain <tnMatchSettingsModule>();

        if (matchSettingsModule == null || viewInstance == null)
        {
            return;
        }

        // stadium

        int           stadiumId   = matchSettingsModule.stadiumId;
        tnStadiumData stadiumData = tnGameData.GetStadiumDataMain(stadiumId);

        if (stadiumData != null)
        {
            viewInstance.SetStadiumImage(stadiumData.icon);
            viewInstance.SetStadiumName(stadiumData.name);
            viewInstance.SetStadiumMinPlayers(stadiumData.onlineTeamSize.min * 2);
        }

        // game mode

        int            gameMode     = matchSettingsModule.gameModeId;
        tnGameModeData gameModeData = tnGameData.GetGameModeDataMain(gameMode);

        if (gameModeData != null)
        {
            viewInstance.SetGameMode(gameModeData.name);
        }

        // golden goal, referee, match duration

        string goldengol;

        tnGameData.TryGetGoldenGoalValueMain(matchSettingsModule.goldenGoalOption, out goldengol);

        string referee;

        tnGameData.TryGetGoldenGoalValueMain(matchSettingsModule.refereeOption, out referee);

        float matchDuration;

        tnGameData.TryGetMatchDurationValueMain(matchSettingsModule.matchDurationOption, out matchDuration);

        viewInstance.SetOtherSettings(goldengol == "ON", referee == "ON", matchDuration);
    }
    public static tnMatchController CreateMatchController(int i_Id)
    {
        tnMatchController controllerInstance = null;

        tnGameModeData gameModeData = tnGameData.GetGameModeDataMain(i_Id);

        if (gameModeData != null)
        {
            tnMatchController controllerPrefab = gameModeData.matchController;
            if (controllerPrefab != null)
            {
                controllerInstance = GameObject.Instantiate <tnMatchController>(controllerPrefab);
            }
        }

        return(controllerInstance);
    }
        public override void OnEnter()
        {
            tnMatchSettingsModule module = GameModulesManager.GetModuleMain <tnMatchSettingsModule>();

            if (module != null)
            {
                int            gameModeId   = module.gameModeId;
                tnGameModeData gameModeData = tnGameData.GetGameModeDataMain(gameModeId);

                if (gameModeData != null)
                {
                    int          camerasSetId = gameModeData.camerasSetId;
                    tnCamerasSet camerasSet   = tnGameData.GetCameraSetMain(camerasSetId);

                    if (camerasSet != null)
                    {
                        int           stadiumId   = module.stadiumId;
                        tnStadiumData stadiumData = tnGameData.GetStadiumDataMain(stadiumId);

                        if (stadiumData != null)
                        {
                            GameObject cameraPrefab = camerasSet.GetCamera(stadiumData.cameraId);

                            if (cameraPrefab != null)
                            {
                                if (storeResult != null && !storeResult.IsNone)
                                {
                                    storeResult.Value = cameraPrefab.gameObject;
                                }
                            }
                        }
                    }
                }
            }

            Finish();
        }
    // EVENTS

    private void OnGameModeSelectedChanged(SelectorItem i_SelectorItem)
    {
        if (i_SelectorItem == null)
        {
            return;
        }

        int            gameModeId   = i_SelectorItem.id;
        tnGameModeData gameModeData = tnGameData.GetGameModeDataMain(gameModeId);

        if (gameModeData != null)
        {
            tnGameModeConfig gameModeConfig = tnGameData.GetConfigDataMain(gameModeData.optionsConfigId);
            if (gameModeConfig != null)
            {
                // SelectMatchDuration(gameModeConfig.matchDurationOption);
                // SelectReferee(gameModeConfig.refereeOption);
                // SelectGoldenGoal(gameModeConfig.goldenGoalOption);
            }
        }

        SetupStadiumSelector(gameModeId);
        SelectFirstUnlockedStadium();
    }
示例#15
0
    private void CreateCamera()
    {
        GameObject spawnPointGo = GameObject.Find(s_Camera_SpawnPoint_Name);

        Vector3 spawnPointPosition = (spawnPointGo != null) ? spawnPointGo.transform.position : Vector3.zero;

        spawnPointPosition.z = -15f;

        tnMatchSettingsModule matchSettingsModule = GameModulesManager.GetModuleMain <tnMatchSettingsModule>();

        if (matchSettingsModule == null)
        {
            return;
        }

        int            gameModeId   = matchSettingsModule.gameModeId;
        tnGameModeData gameModeData = tnGameData.GetGameModeDataMain(gameModeId);

        if (gameModeData == null)
        {
            return;
        }

        int          cameraSetId = gameModeData.camerasSetId;
        tnCamerasSet cameraSet   = tnGameData.GetCameraSetMain(cameraSetId);

        if (cameraSet == null)
        {
            return;
        }

        int           stadiumId   = matchSettingsModule.stadiumId;
        tnStadiumData stadiumData = tnGameData.GetStadiumDataMain(stadiumId);

        if (stadiumData == null)
        {
            return;
        }

        GameObject cameraPrefab = cameraSet.GetCamera(stadiumData.cameraId);

        if (cameraPrefab == null)
        {
            return;
        }

        m_GameCameraGO      = Instantiate <GameObject>(cameraPrefab);
        m_GameCameraGO.name = "GameCamera";
        m_GameCameraGO.tag  = "GameCamera";

        tnGameCamera gameCamera = m_GameCameraGO.GetComponent <tnGameCamera>();

        if (gameCamera != null)
        {
            gameCamera.SetPosition(spawnPointPosition);
        }
        else
        {
            m_GameCameraGO.transform.position = spawnPointPosition;
        }

        m_GameCameraGO.transform.rotation = Quaternion.identity;
    }
    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);
    }
    private void UpdateView()
    {
        if (viewInstance == null)
        {
            return;
        }

        ClearView();

        int showedRooms = 0;

        for (int index = minShowedIndex; index >= 0 && index <= maxShowedIndex; ++index)
        {
            RoomInfo roomInfo = m_Rooms[index];

            if (roomInfo == null)
            {
                continue;
            }

            int stadiumId;
            PhotonUtils.TryGetRoomCustomProperty <int>(roomInfo, PhotonPropertyKey.s_RoomCustomPropertyKey_Stadium, out stadiumId);

            int gameModeId;
            PhotonUtils.TryGetRoomCustomProperty <int>(roomInfo, PhotonPropertyKey.s_RoomCustomPropertyKey_GameMode, out gameModeId);

            int matchDurationOptionId;
            PhotonUtils.TryGetRoomCustomProperty <int>(roomInfo, PhotonPropertyKey.s_RoomCustomPropertyKey_MatchDuration, out matchDurationOptionId);

            int goldenGoalOptionId;
            PhotonUtils.TryGetRoomCustomProperty <int>(roomInfo, PhotonPropertyKey.s_RoomCustomPropertyKey_GoldenGoal, out goldenGoalOptionId);

            int refereeOptionId;
            PhotonUtils.TryGetRoomCustomProperty <int>(roomInfo, PhotonPropertyKey.s_RoomCustomPropertyKey_Referee, out refereeOptionId);

            string host;
            PhotonUtils.TryGetRoomCustomProperty <string>(roomInfo, PhotonPropertyKey.s_RoomCustomPropertyKey_HostName, out host);

            int playersCount;
            PhotonUtils.TryGetRoomCustomProperty <int>(roomInfo, PhotonPropertyKey.s_RoomCustomPropertyKey_PlayerCount, out playersCount);

            int ping;
            PhotonUtils.TryGetRoomCustomProperty <int>(roomInfo, PhotonPropertyKey.s_RoomCustomPropertyKey_AvgPing, out ping);

            int maxPlayer = roomInfo.MaxPlayers;

            Sprite stadiumThumbnail = null;
            string stadiumName      = "";
            string gameModeName     = "";
            string rules            = "";

            tnStadiumData stadiumData = tnGameData.GetStadiumDataMain(stadiumId);
            if (stadiumData != null)
            {
                stadiumThumbnail = stadiumData.icon;
                stadiumName      = stadiumData.name;
            }

            tnGameModeData gameModeData = tnGameData.GetGameModeDataMain(gameModeId);
            if (gameModeData != null)
            {
                gameModeName = gameModeData.name;
            }

            float matchDuration;
            tnGameData.TryGetMatchDurationValueMain(matchDurationOptionId, out matchDuration);
            string matchDurationRule = TimeUtils.TimeToString(matchDuration, true, true);

            string goldenGoal;
            tnGameData.TryGetGoldenGoalValueMain(goldenGoalOptionId, out goldenGoal);
            string goldenGoalRule = (goldenGoal == "ON") ? "GOLDEN GOAL" : "NO GOLDEN GOAL";

            string referee;
            tnGameData.TryGetRefereeValueMain(refereeOptionId, out referee);
            string refereeRule = (referee == "ON") ? "REFEREE" : "";

            rules = goldenGoalRule + ", " + refereeRule + ((refereeRule == "") ? "" : ", ") + matchDurationRule;

            SetRoomData(showedRooms, stadiumThumbnail, stadiumName, gameModeName, rules, host, playersCount, maxPlayer, ping);
            ++showedRooms;
        }

        int   roomsCount            = m_Rooms.Count;
        float showedRoomsPercentage = (roomsCount > 0) ? (((float)showedRooms) / ((float)roomsCount)) : 1f;

        int   slotCount          = Mathf.Max(0, m_SlotsCount);
        int   possibleStates     = (roomsCount > slotCount) ? (roomsCount - slotCount) : 1;
        int   currentStates      = Mathf.Max(0, minShowedIndex);
        float positionPercentage = ((float)currentStates) / ((float)possibleStates);

        viewInstance.SetScrollbarHandleState(showedRoomsPercentage, positionPercentage);
        viewInstance.SetConfirmTriggerCanSend(roomsCount > 0);
        viewInstance.SetRefreshCommandActive(roomsCount > 0);
    }
示例#18
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();
    }