private void FillAttractTimeData(int i_SlotIndex, tnBaseMatchController i_MatchController) { if (i_MatchController == null) { return; } int charcatersCount = i_MatchController.charactersCount; // Compute total shots count. FP totalAttractTime = FP.Zero; for (int characterIndex = 0; characterIndex < charcatersCount; ++characterIndex) { tnBaseMatchCharacterResults characterResults = (tnBaseMatchCharacterResults)i_MatchController.GetCharacterResultsByIndex(characterIndex); if (characterResults != null) { totalAttractTime += characterResults.attractTime; } } // Get best character for this stat. int selectedCharacterIndex = -1; int selectedCharacterId = Hash.s_NULL; int selectedPlayerId = Hash.s_NULL; FP maxAttractTime = FP.MinValue; for (int characterIndex = 0; characterIndex < charcatersCount; ++characterIndex) { tnBaseMatchCharacterResults characterResults = (tnBaseMatchCharacterResults)i_MatchController.GetCharacterResultsByIndex(characterIndex); if (characterResults != null) { FP characterAttractTime = characterResults.attractTime; if (characterAttractTime > maxAttractTime) { selectedCharacterIndex = characterIndex; selectedCharacterId = characterResults.id; selectedPlayerId = characterResults.playerId; maxAttractTime = characterAttractTime; } } } if (selectedCharacterIndex < 0) { return; } // Fill data. string playerName = ""; Sprite playerPortrait = null; Color playerColor = Color.white; { tnCharacterData characterData = tnGameData.GetCharacterDataMain(selectedCharacterId); if (characterData != null) { playerName = characterData.displayName; playerPortrait = characterData.uiIconFacingRight; } tnPlayerData playerData = tnGameData.GetPlayerDataMain(selectedPlayerId); if (playerData != null) { playerColor = playerData.color; } } string statValue = maxAttractTime.ToString(2); statValue += " s"; FP partecipationPercentage = FP.Zero; if (totalAttractTime > FP.Zero) { partecipationPercentage = maxAttractTime / totalAttractTime; partecipationPercentage *= 100f; partecipationPercentage = MathFP.Clamp(partecipationPercentage, FP.Zero, 100f); } string partecipationValue = partecipationPercentage.ToString(2); partecipationValue += "%"; FillData(i_SlotIndex, playerName, playerPortrait, playerColor, s_StatName_AttractTime, statValue, s_PartecipationLabel, partecipationValue); }