/// End of the Unlock state /// private void ExitStateUnlock() { // Save the level state m_levelService.OpenLevel(LevelModel.m_index); // Effects m_audioService.PlaySFX(AudioIdentifiers.k_sfxMapUnlock); ParticleUtils.SpawnParticles(ParticleIdentifiers.k_starburst, MapNodeView.transform.position); }
/// @param newScore /// The score to set /// @param callback /// The function to call when the score finished updated /// private IEnumerator StaggerStarProgress(int newScore, Action callback = null) { int lastThreshold = 0; for (int index = 0; index < m_scores.Count; ++index) { if (m_starsProgress[index].GetProgress() < 1.0f) { // Set the progress of that star bool effectDone = false; bool shouldContinue = false; float progress = (float)(newScore - lastThreshold) / (m_scores[index] - lastThreshold); m_starsProgress[index].TweenToProgress(progress, 1.0f, 0.0f, () => { effectDone = true; if (progress >= 1.0f) { // The star is filled! shouldContinue = true; m_audioService.PlaySFX(AudioIdentifiers.k_sfxStarburst); ParticleUtils.SpawnParticles(ParticleIdentifiers.k_starburstUI, transform, m_starsProgress[index].transform.position); } }); while (effectDone == false) { yield return(null); } lastThreshold = m_scores[index]; if (shouldContinue == false) { // Don't progress further stars break; } } } callback.SafeInvoke(); }
/// @param callback /// The function to call when the tiles are popped /// private IEnumerator StaggerTilesPop(Action callback) { // Pop the tiles int tilePopped = 0; int tilesChained = 0; int tileScore = k_tileScore; foreach (var tile in m_selectedTiles) { string audioSFX = AudioIdentifiers.k_sfxPopPositive; string particleID = ParticleIdentifiers.k_tilePop; string textFormat = GameTextIdentifiers.k_rewardFormat; Color textColour = Color.white; // Special tiles if (tile.m_tileColour == TileColour.Grey) { audioSFX = AudioIdentifiers.k_sfxPopNegative; particleID = ParticleIdentifiers.k_tilePopNegative; textFormat = GameTextIdentifiers.k_penaltyFormat; textColour = Color.red; tileScore = -k_tileScore; } // Audio SFX m_audioService.PlaySFX(audioSFX); // Particle effect and score m_currentScore += tileScore; var textParticle = ParticleUtils.SpawnTextParticles(string.Format(textFormat, tileScore), m_view.TilesHolder, tile.m_boardPosition); textParticle.SetColour(textColour); ParticleUtils.SpawnParticles(particleID, tile.m_boardPosition); // Log the score event m_objectiveService.LogEvent(ObjectiveType.Score, tileScore); tile.Pop(() => { // Tile popped, remove it m_tiles.Remove(tile); tile.gameObject.SetActive(false); ++tilePopped; // Log the popped tile event m_objectiveService.LogEvent(ObjectiveType.Colour, tile.m_tileColour); }); yield return(new WaitForSeconds(0.1f)); // Add bonus score if any ++tilesChained; if (tileScore > 0 && tilesChained % k_minActiveTiles == 0) { tileScore += k_bonusScore; } } while (tilePopped < m_selectedTiles.Count) { yield return(null); } // Log the chain event m_objectiveService.LogEventWithValue(ObjectiveType.Chain, tilesChained); callback.SafeInvoke(); }