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); } } }
// LOGIC public void UpdateModule() { tnTeamsModule teamsModule = GameModulesManager.GetModuleMain <tnTeamsModule>(); if (teamsModule == null) { return; } teamsModule.Clear(); SetupTeamA(teamsModule); SetupTeamB(teamsModule); }
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(); }