private void CreateMedals(MedalsCount medals)
        {
            _commendationsInstances = new List <GameObject>();

            UpdateCupCommendation(medals.CupLevel);
            CreateMedalsByType(GoldMedalPrefab, medals.GoldCount);
            CreateMedalsByType(SilverMedalPrefab, medals.SilverCount);
            CreateMedalsByType(BronzeMedalPrefab, medals.BronzeCount);
        }
        private void UpdateCommendations()
        {
            MedalsCount medalsCount = GetMedalsCountForLevels(_completedLevelsCount);

            foreach (GameObject commendation in _commendationsInstances)
            {
                Destroy(commendation);
            }
            CreateMedals(medalsCount);
        }
        private static MedalsCount GetMedalsCountForLevels(int levelsCount)
        {
            int remainingLevelsCount = levelsCount;

            MedalsCount medalsCount = new MedalsCount();

            int cupsDelimiter = (int)Math.Pow(LevelsCountForMedal, 3);

            medalsCount.CupLevel  = (int)Math.Floor((decimal)remainingLevelsCount / cupsDelimiter);
            remainingLevelsCount -= medalsCount.CupLevel * cupsDelimiter;

            int goldMedalsDelimiter = (int)Math.Pow(LevelsCountForMedal, 2);

            medalsCount.GoldCount = (int)Math.Floor((decimal)remainingLevelsCount / goldMedalsDelimiter);
            remainingLevelsCount -= medalsCount.GoldCount * goldMedalsDelimiter;

            medalsCount.SilverCount = (int)Math.Floor((decimal)remainingLevelsCount / LevelsCountForMedal);
            remainingLevelsCount   -= medalsCount.SilverCount * LevelsCountForMedal;

            medalsCount.BronzeCount = remainingLevelsCount;

            return(medalsCount);
        }