public static bool IsLocalPlayer(int i_OnlinePlayerIndex)
    {
        if (i_OnlinePlayerIndex < 0)
        {
            return(false);
        }

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

        if (localPartyModule == null)
        {
            return(false);
        }

        for (int index = 0; index < localPartyModule.playersCount; ++index)
        {
            int onlinePlayerIndex = localPartyModule.GetOnlinePlayerIndexByIndex(index);
            if (onlinePlayerIndex == i_OnlinePlayerIndex)
            {
                return(true);
            }
        }

        return(false);
    }
コード例 #2
0
    private void CreateMatchController()
    {
        tnMatchSettingsModule matchSettingsModule = GameModulesManager.GetModuleMain <tnMatchSettingsModule>();

        if (matchSettingsModule == null)
        {
            return;
        }

        int gameModeId = matchSettingsModule.gameModeId;
        tnMatchController matchControllerInstance = tnGameModeFactory.CreateMatchController(gameModeId);

        if (matchControllerInstance != null)
        {
            matchControllerInstance.gameObject.name = "MultiplayerMatchController";
            matchControllerInstance.SetSeed(m_SharedSeed);

            matchControllerInstance.SetCamera(m_GameCameraGO);
        }

        m_MatchController = matchControllerInstance;

        if (m_TrueSyncManager != null)
        {
            m_TrueSyncManager.RegisterTrueSyncObject(m_MatchController.gameObject);
        }
    }
    public static bool OnlineToLocalPlayerIndex(int i_OnlinePlayerIndex, out int o_LocalPlayerIndex)
    {
        o_LocalPlayerIndex = -1;

        if (i_OnlinePlayerIndex < 0)
        {
            return(false);
        }

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

        if (localPartyModule == null)
        {
            return(false);
        }

        for (int index = 0; index < localPartyModule.playersCount; ++index)
        {
            int currentOnlinePlayerIndex = localPartyModule.GetOnlinePlayerIndexByIndex(index);
            if (currentOnlinePlayerIndex == i_OnlinePlayerIndex)
            {
                o_LocalPlayerIndex = index;
                return(true);
            }
        }

        return(false);
    }
    // UTILS

    private int GetAICount()
    {
        int aiCount = 0;

        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;
                    }

                    bool ai = (characterDescription.playerId == Hash.s_NULL);
                    aiCount += (ai) ? 1 : 0;
                }
            }
        }

        return(aiCount);
    }
    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);
    }
コード例 #6
0
    // BUSINESS LOGIC

    public void UpdateModule()
    {
        tnTeamsModule teamsModule = GameModulesManager.GetModuleMain <tnTeamsModule>();

        if (teamsModule == null)
        {
            return;
        }

        // Evaluate teams colors.

        Color[] teamColors = null;

        {
            int[] teamIds = new int[s_MaxPlayers];

            for (int teamIndex = 0; teamIndex < s_MaxPlayers; ++teamIndex)
            {
                teamIds[teamIndex] = GetTeamId(teamIndex);
            }

            teamColors = Utils.ComputeTeamColors(teamIds);
        }

        // Fill team descriptors.

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

            if (teamDescription == null)
            {
                continue;
            }

            // Set team id.

            int teamId = GetTeamId(teamIndex);

            teamDescription.SetTeamId(teamId);

            // Set team color.

            Color teamColor;

            if (teamColors != null)
            {
                teamColor = teamColors[teamIndex];
            }
            else
            {
                teamColor = Color.white;
            }

            teamDescription.SetTeamColor(teamColor);

            LogManager.Log(this, LogContexts.FSM, "Team " + teamIndex + " : " + teamId + " " + "[" + teamColor + "]");
        }
    }
        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);
                    }
                }
            }
        }
コード例 #8
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();
    }
        public override void OnEnter()
        {
            tnMatchSettingsModule matchSettingsModule = GameModulesManager.GetModuleMain<tnMatchSettingsModule>();

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

            Finish();
        }
        public override void OnEnter()
        {
            tnTeamsModule teamsModule = GameModulesManager.GetModuleMain <tnTeamsModule>();

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

            Finish();
        }
        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);
                }
            }
        }
    protected override void OnUpdate(float i_DeltaTime)
    {
        base.OnUpdate(i_DeltaTime);

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

        if (localPartyModule != null)
        {
            int playerId = localPartyModule.captainId;

            bool up   = tnInputUtils.GetPositiveButtonDown(playerId, "VerticalUp", "Vertical");
            bool down = tnInputUtils.GetNegativeButtonDown(playerId, "VerticalDown", "Vertical");

            bool refresh    = tnInputUtils.GetButtonDown(playerId, "Action1");
            bool createRoom = tnInputUtils.GetButtonDown(playerId, "Action2", "Action2");

            if (m_Rooms.Count > 0)
            {
                if (refresh)
                {
                    Refresh();
                    ForceSelection(0);

                    SfxPlayer.PlayMain(m_RefreshSfx);
                }
                else
                {
                    if ((up || down) && !(up && down))
                    {
                        if (up)
                        {
                            MoveUp();
                        }
                        else
                        {
                            MoveDown();
                        }
                    }
                }
            }

            if (createRoom)
            {
                SfxPlayer.PlayMain(m_CreateRoomSfx);

                if (m_CreateRoomRequestedEvent != null)
                {
                    m_CreateRoomRequestedEvent();
                }
            }
        }
    }
コード例 #13
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);
                    }
                }
            }
        }
    }
    // INTERNALS

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

        if (matchSettingsModule == null)
        {
            return;
        }

        GameObject scorePanelSpawnPointGo = GameObject.Find(s_ScorePanelSpawnPoint);

        if (scorePanelSpawnPointGo == null)
        {
            return;
        }

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

        if (stadiumData == null)
        {
            return;
        }

        int gameModeId = matchSettingsModule.gameModeId;

        GameObject scorePanelPrefab = stadiumData.LoadAndGetScorePanelPrefab(gameModeId);

        if (scorePanelPrefab == null)
        {
            return;
        }

        Vector3    spawnPosition = scorePanelSpawnPointGo.transform.position;
        Quaternion spawnRotation = scorePanelSpawnPointGo.transform.rotation;

        GameObject scorePanelInstance = Instantiate <GameObject>(scorePanelPrefab);

        scorePanelInstance.name = "ScorePanel";

        scorePanelInstance.transform.position = spawnPosition;
        scorePanelInstance.transform.rotation = spawnRotation;

        tnUIStandardScorePanel scorePanel = scorePanelInstance.GetComponentInChildren <tnUIStandardScorePanel>();

        if (scorePanel != null)
        {
            scorePanel.Bind(this);
        }
    }
    // tnMatchController's interface

    protected override void OnPreInit()
    {
        base.OnPreInit();

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

        if (teamsModule == null || teamsModule.teamsCount == 0)
            return;

        if (m_AIFactoryComponent != null)
        {
            m_AIFactoryComponent.Setup(teamsModule.teamsCount);
        }
    }
    // LOGIC

    public void UpdateModule()
    {
        tnTeamsModule teamsModule = GameModulesManager.GetModuleMain <tnTeamsModule>();

        if (teamsModule == null)
        {
            return;
        }

        teamsModule.Clear();

        SetupTeamA(teamsModule);
        SetupTeamB(teamsModule);
    }
コード例 #17
0
        public override void OnEnter()
        {
            tnMatchSettingsModule module = GameModulesManager.GetModuleMain <tnMatchSettingsModule>();

            if (module != null)
            {
                int gameModeId = module.gameModeId;

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

            Finish();
        }
コード例 #18
0
    private IEnumerator LoadMap()
    {
        tnMatchSettingsModule matchSettingsModule = GameModulesManager.GetModuleMain <tnMatchSettingsModule>();

        if (matchSettingsModule != null)
        {
            int           stadiumId   = matchSettingsModule.stadiumId;
            tnStadiumData stadiumData = tnGameData.GetStadiumDataMain(stadiumId);
            if (stadiumData != null)
            {
                string      sceneName = stadiumData.sceneName;
                IEnumerator loadScene = LoadSceneAdditiveAsync(sceneName);
                yield return(StartCoroutine(loadScene));
            }
        }
    }
コード例 #19
0
        public override void OnEnter()
        {
            tnTeamsModule teamsModule = GameModulesManager.GetModuleMain <tnTeamsModule>();

            if (teamsModule == null)
            {
                teamsModule = GameModulesManager.AddModuleMain <tnTeamsModule>();
                teamsModule.Clear();
            }

            tnTeamDescription team = new tnTeamDescription();

            team.SetTeamId(id.Value);
            team.SetTeamColor(color.Value);

            int charactersCount = characters.Length;

            for (int characterIndex = 0; characterIndex < charactersCount; ++characterIndex)
            {
                tnCharacterEntry entry = characters[characterIndex];
                if (entry != null)
                {
                    FsmString characterId       = entry.characterId;
                    FsmInt    onlinePlayerIndex = entry.onlinePlayerIndex;
                    FsmString playerId          = entry.playerId;
                    FsmInt    spawnOrder        = entry.spawnOrder;

                    if (characterId != null && !characterId.IsNone && onlinePlayerIndex != null && !onlinePlayerIndex.IsNone && playerId != null && !playerId.IsNone && spawnOrder != null && !spawnOrder.IsNone)
                    {
                        tnCharacterDescription character = new tnCharacterDescription();

                        character.SetCharacterId(characterId.Value);

                        character.SetOnlinePlayerIndex(onlinePlayerIndex.Value);

                        character.SetPlayerId(playerId.Value);
                        character.SetSpawnOrder(spawnOrder.Value);

                        team.AddCharacterDescription(character);
                    }
                }
            }

            teamsModule.AddTeamDescription(team);

            Finish();
        }
    // 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);
    }
コード例 #21
0
    private void Internal_FillTeamsModule()
    {
        tnTeamsModule teamsModule = GameModulesManager.GetModuleMain <tnTeamsModule>();

        if (teamsModule != null)
        {
            int minPlayers = GetMinPlayers();
            int maxPlayers = GetMaxPlayers();

            int total          = m_PlayersPerTeam * 2;
            int clampedTotal   = Mathf.Clamp(total, minPlayers, maxPlayers);
            int characterCount = clampedTotal / 2;

            Internal_AddTeamA(teamsModule, characterCount);
            Internal_AddTeamB(teamsModule, characterCount);
        }
    }
コード例 #22
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);
                        }
                    }
                }
            }
        }
    }
コード例 #23
0
    // INTERNALS

    private void SelectPlayer(int i_TeamIndex)
    {
        tnTeamsModule teamsModule = GameModulesManager.GetModuleMain <tnTeamsModule>();

        if (teamsModule == null)
        {
            return;
        }

        tnTeamDescription teamDescription = teamsModule.GetTeamDescription(i_TeamIndex);

        if (teamDescription != null)
        {
            int playerId = teamDescription.captainPlayerId;
            m_Ids[i_TeamIndex] = playerId;

            // Cache PlayerInput.

            tnPlayerData playerData = tnGameData.GetPlayerDataMain(playerId);
            if (playerData != null)
            {
                if (!StringUtils.IsNullOrEmpty(playerData.playerInputName))
                {
                    m_Players[i_TeamIndex] = InputSystem.GetPlayerByNameMain(playerData.playerInputName);

                    PushControllingMap(i_TeamIndex, i_TeamIndex);
                }
                else
                {
                    if (!StringUtils.IsNullOrEmpty(playerData.wifiPlayerInputName))
                    {
                        m_WifiPlayers[i_TeamIndex] = WiFiInputSystem.GetPlayerByNameMain(playerData.wifiPlayerInputName);

                        PushControllingMap(i_TeamIndex, i_TeamIndex);
                    }
                }
            }
        }

        // Update image and label.

        UpdateImageColor(i_TeamIndex);
        UpdateLabel(i_TeamIndex);
    }
    // BUSINESS LOGIC

    public void UpdateModule()
    {
        tnMatchSettingsModule matchSettingsModule = GameModulesManager.GetModuleMain <tnMatchSettingsModule>();

        if (matchSettingsModule == null)
        {
            return;
        }

        matchSettingsModule.Clear();

        SetGameModeId(matchSettingsModule);     // Set Game Mode.
        SetMatchDuration(matchSettingsModule);  // Set Match Duration.
        SetReferee(matchSettingsModule);        // Set Referee On/Off.
        SetGoldenGoal(matchSettingsModule);     // Set Golden Goal.
        SetAILevelIndex(matchSettingsModule);   // Set AI Level Index.
        SetBall(matchSettingsModule);           // Set Ball type.
        SetStadium(matchSettingsModule);        // Set Stadium.
    }
        public override void OnEnter()
        {
            tnMatchSettingsModule module = GameModulesManager.GetModuleMain <tnMatchSettingsModule>();

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

                if (stadiumData != null)
                {
                    if (storeResult != null && !storeResult.IsNone)
                    {
                        storeResult.Value = stadiumData.sceneName;
                    }
                }
            }

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

            if (module == null)
            {
                module = GameModulesManager.AddModuleMain <tnMatchSettingsModule>();
            }

            module.Clear();

            module.SetGameModeId(gameModeId.Value);
            module.SetStadiumId(stadiumId.Value);
            module.SetBallId(ballId.Value);
            module.SetMatchDurationOption(matchDurationOption.Value);
            module.SetRefereeOption(refereeOption.Value);
            module.SetGoldenGoalOption(goldenGoalOption.Value);

            Finish();
        }
        public override void OnEnter()
        {
            // Clear input module.

            ClearInputModule();

            // Process teams.

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

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

            Finish();
        }
    // INTERNALS

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

        if (matchSettingsModule == null)
        {
            return;
        }

        // Match duration

        int matchDurationOptionId = matchSettingsModule.matchDurationOption;

        float matchDuration = 180f; // Default value.

        float time;

        if (tnGameData.TryGetMatchDurationValueMain(matchDurationOptionId, out time))
        {
            matchDuration = time;
        }

        m_MatchDuration = matchDuration;

        // Golden goal

        int goldenGoalOptionId = matchSettingsModule.goldenGoalOption;

        bool goldenGoal = false; // Defualt value.

        string goldenGoalValue;

        if (tnGameData.TryGetGoldenGoalValueMain(goldenGoalOptionId, out goldenGoalValue))
        {
            goldenGoal = (goldenGoalValue == "ON");
        }

        m_GoldenGoalEnabled = goldenGoal;
    }
コード例 #29
0
    // UTILS

    private void ShowDialog(string i_Title, string i_DetailText, Action i_Callback = null)
    {
        if (m_DialogPanel != null)
        {
            // Set players that will be able to respond to dialog.

            tnLocalPartyModule localPartyModule = GameModulesManager.GetModuleMain <tnLocalPartyModule>();
            if (localPartyModule != null && !localPartyModule.isEmpty)
            {
                SetLocalCaptainOnInputModule();
            }
            else
            {
                SetAllPlayersOnInputModule();
            }

            // Open panel.

            SwitchPanels(UIGroup.Group5, m_DialogPanel);

            // Configure and run dialog.

            Action callback = () => { ClearGroup(UIGroup.Group5); if (i_Callback != null)
                                      {
                                          i_Callback();
                                      }
            };
            m_DialogPanel.SetTitle(i_Title);
            m_DialogPanel.SetDeatilText(i_DetailText);
            m_DialogPanel.ShowDialog(callback);
        }
        else
        {
            if (i_Callback != null)
            {
                i_Callback();
            }
        }
    }
    public static bool LocalToOnlinePlayerIndex(int i_LocalPlayerIndex, out int o_OnlinePlayerIndex)
    {
        o_OnlinePlayerIndex = -1;

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

        if (localPartyModule == null)
        {
            return(false);
        }

        if (i_LocalPlayerIndex < 0 || i_LocalPlayerIndex > localPartyModule.playersCount)
        {
            return(false);
        }

        int onlinePlayerIndex = localPartyModule.GetOnlinePlayerIndexByIndex(i_LocalPlayerIndex);

        o_OnlinePlayerIndex = onlinePlayerIndex;

        return(true);
    }