public void CompleteBlock(BlockType type, int amount) { BlockBar barToUse = null; switch (type) { case BlockType.Art: barToUse = ArtBar; break; case BlockType.Gameplay: barToUse = GameplayBar; break; case BlockType.Music: barToUse = MusicBar; break; case BlockType.Story: barToUse = StoryBar; break; default: throw new Exception($"unexpected type {type}"); } int overflow = barToUse.IncreaseAmount(amount); if (barToUse.IsFilled) { var optionalBarToUse = firstNonFullOptionalBar(type); if (optionalBarToUse != null) { overflow = optionalBarToUse.IncreaseAmount(overflow); if (!optionalBarToUse.IsFilled) { return; } } barToUse.IncreaseNoLimit(overflow); } }
public void InitializeBars() { ArtBar = new BlockBar(ArtRequirements); GameplayBar = new BlockBar(GameplayRequirements); MusicBar = new BlockBar(MusicRequirements); StoryBar = new BlockBar(StoryRequirements); SelectedRequirements.Sort((sg1, sg2) => sg2.Score.CompareTo(sg1.Score)); genreBars = new List <GenreBarPair>(); foreach (var scoredGenre in SelectedRequirements) { var genreData = ThemeData.Instance.GetGenre(scoredGenre.Genre); var pair = new GenreBarPair { Bar1 = new BlockBar(genreData.IncreaseAmount1), Bar2 = genreData.IncreaseAmount2 > 0 ? new BlockBar(genreData.IncreaseAmount2) : null }; genreBars.Add(pair); } }