示例#1
0
        /// 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);
        }
示例#2
0
        /// @param amount
        ///     The amount of particles to spawn
        /// @param reward
        ///     The reward to spawn
        /// @param position
        ///     The position to spawn at
        /// @param holder
        ///     The holder to interact with
        /// @param callback
        ///     The function to call when the ceremony is done
        ///
        private void SpawnRewardInternal(int amount, CurrencyItem reward, Vector3 position, TopPanelHolder holder, Action callback)
        {
            // Show the holder if needed
            holder.Show();

            // Spawn a bunch of particles
            int particleFinished = 0;

            for (int i = 0; i < amount; ++i)
            {
                ++holder.m_activeParticles;
                var particleReward = ParticleUtils.SpawnRewardParticles(reward.m_currencyID, transform.parent, position, holder.transform.position);
                particleReward.OnReachedDestination += () =>
                {
                    // This is called when the particle hits the holder
                    m_currencySequence.Stop(true);
                    m_currencySequence = DOTween.Sequence();

                    // Show the flash
                    holder.m_flash.color = Color.white;

                    // Trigger the sequence
                    m_currencySequence.Append(holder.transform.DOPunchPosition(Vector3.up * Screen.height * 0.025f, 0.5f));
                    m_currencySequence.Insert(0.0f, holder.m_flash.DOColor(GameUtils.k_transparent, 0.5f));
                    m_currencySequence.OnComplete(() =>
                    {
                        --holder.m_activeParticles;

                        // Hide the holder if not needed anymore
                        holder.Hide();
                    });

                    PlayCollectSFX(reward.m_currencyID);
                    m_currencySequence.Play();
                };

                particleReward.OnRewarded += () =>
                {
                    // This is called even if the particle gets destroyed
                    ++particleFinished;
                    if (particleFinished == amount)
                    {
                        callback.SafeInvoke();
                    }
                };
            }

            // Text shown above
            ParticleUtils.SpawnTextParticles(string.Format(GameTextIdentifiers.k_rewardFormat, reward.m_value), transform.parent, position);
        }
示例#3
0
        /// @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();
        }
示例#4
0
        /// @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();
        }