private void Internal_AddTeamB(tnTeamsModule i_TeamsModule, int i_CharacterCount) { if (i_TeamsModule == null) { return; } tnTeamDescription teamDescription = new tnTeamDescription(); string teamId = GetTeamB(); teamDescription.SetTeamId(teamId); Color teamColor = GetTeamBColor(); teamDescription.SetTeamColor(teamColor); if (i_CharacterCount >= 0) { tnTeamData teamData = tnGameData.GetTeamDataMain(teamId); if (teamData != null) { int characterCount = Mathf.Min(i_CharacterCount, teamData.charactersCount); for (int index = 0; index < characterCount; ++index) { tnCharacterDescription characterDescription = new tnCharacterDescription(); characterDescription.SetCharacterId(teamData.GetCharacterKey(index)); characterDescription.SetSpawnOrder(index); if (m_AllHumans) { characterDescription.SetPlayerId(GetPlayerIdByIndex(index + characterCount)); } teamDescription.AddCharacterDescription(characterDescription); } } } i_TeamsModule.AddTeamDescription(teamDescription); }
// INTERNAL private void Internal_SetupTeam(int i_TeamIndex, tnTeamDescription i_TeamDescription) { if (!IsValidIndex(i_TeamIndex)) { return; } if (i_TeamDescription == null) { return; } int teamId = i_TeamDescription.teamId; tnTeamData teamData = tnGameData.GetTeamDataMain(teamId); if (teamData == null) { return; } List <int> lineUp = teamData.GetDefaultLineUp(i_TeamDescription.charactersCount); if (lineUp == null) { return; } SetTeamInfo(i_TeamIndex, teamData); // Lineup. { tnUITeamAnchors teamAnchors = m_TeamAnchorsSets[i_TeamIndex]; tnUIAnchorsSet anchorsSet = null; if (teamAnchors != null) { anchorsSet = teamAnchors.GetAnchorsSetBySize(i_TeamDescription.charactersCount); } if (anchorsSet != null) { for (int index = 0; index < anchorsSet.anchorsCount && index < lineUp.Count; ++index) { RectTransform anchor = anchorsSet.GetAnchorByIndex(index); if (anchor != null) { int characterId = lineUp[index]; if (!teamData.Contains(characterId)) { continue; } tnCharacterData characterData = tnGameData.GetCharacterDataMain(characterId); if (characterData == null) { continue; } FacingDir facingDir = m_Facing[i_TeamIndex]; Color teamColor = i_TeamDescription.teamColor; Sprite flag = teamData.baseSprite; tnUICharacter character = SpawnCharacter(characterData, facingDir, teamColor, flag); tnUICharacterSlot slot = SpawnCharacterSlot(); slot.transform.position = anchor.position; slot.character = character; slot.characterId = characterId; bool isHuman = m_Humans[i_TeamIndex, index]; if (isHuman) { Color playerColor = m_PlayersColors[i_TeamIndex, index]; slot.SetPlayerColor(playerColor); } else { slot.ClearPlayerColor(); } SlotList slotList = m_LineUp[i_TeamIndex]; slotList.Add(slot); } } } m_TeamAnchors[i_TeamIndex] = anchorsSet; } // Bench. { tnUIBench bench = m_TeamAnchorsBench[i_TeamIndex]; int lastBenchIndexUsed = -1; for (int index = 0; index < bench.entriesCount && index < teamData.charactersCount; ++index) { tnUIBenchEntry benchEntry = bench.GetEntryByIndex(index); if (benchEntry != null && benchEntry.anchor != null) { int characterId = Hash.s_NULL; for (int characterIndex = lastBenchIndexUsed + 1; characterIndex < teamData.charactersCount; ++characterIndex) { int id = teamData.GetCharacterKey(characterIndex); if (!lineUp.Contains(id)) { characterId = id; lastBenchIndexUsed = characterIndex; break; } } tnCharacterData characterData = tnGameData.GetCharacterDataMain(characterId); if (characterData == null) { continue; } FacingDir facingDir = m_Facing[i_TeamIndex]; Color teamColor = i_TeamDescription.teamColor; Sprite flag = teamData.baseSprite; tnUICharacter character = SpawnCharacter(characterData, facingDir, teamColor, flag); tnUICharacterSlot slot = SpawnCharacterSlot(); slot.transform.position = benchEntry.anchor.position; slot.character = character; slot.characterId = characterId; slot.ClearPlayerColor(); SlotList slotList = m_Bench[i_TeamIndex]; slotList.Add(slot); } } } }