private tnTeamDescription CreateTeam(int i_TeamKey, int i_TeamSize, Color i_TeamColor) { tnTeamData teamData = tnGameData.GetTeamDataMain(i_TeamKey); if (teamData == null || i_TeamSize <= 0) { return(null); } tnTeamDescription teamDescription = new tnTeamDescription(); teamDescription.SetTeamId(i_TeamKey); teamDescription.SetTeamColor(i_TeamColor); List <int> teamLineup = teamData.GetDefaultLineUp(i_TeamSize); for (int characterIndex = 0; characterIndex < teamLineup.Count; ++characterIndex) { int characterKey = teamLineup[characterIndex]; tnCharacterDescription characterDescription = new tnCharacterDescription(); characterDescription.SetCharacterId(characterKey); characterDescription.SetPlayerId(StringUtils.s_NULL); characterDescription.SetSpawnOrder(characterIndex); teamDescription.AddCharacterDescription(characterDescription); } return(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); } } } }