public tnGameModeConfig GetData(int i_Id) { tnGameModeConfig data = null; m_Data.TryGetValue(i_Id, out data); return(data); }
// 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); } } } }
// LOGIC public void Initialize(string i_DatabasePath) { tnGameModeConfigsDatabase database = Resources.Load <tnGameModeConfigsDatabase>(i_DatabasePath); if (database != null) { foreach (string key in database.keys) { tnGameModeConfigDescriptor descriptor = database.GetConfig(key); if (descriptor != null) { int hash = StringUtils.GetHashCode(key); tnGameModeConfig data = new tnGameModeConfig(descriptor); m_Data.Add(hash, data); } } } else { LogManager.LogWarning(this, "Database not loaded."); } }
// 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(); }