Beispiel #1
0
        /// @param holders
        ///     The list of holders to look through
        /// @param currencyID
        ///     The currency to look for
        ///
        /// @return The top panel for this currency
        ///
        private TopPanelHolder GetHolder(List <TopPanelHolder> holders, string currencyID)
        {
            TopPanelHolder holder = null;

            foreach (var topHolder in holders)
            {
                if (topHolder.CurrencyID == currencyID)
                {
                    holder = topHolder;
                    break;
                }
            }
            return(holder);
        }
Beispiel #2
0
        /// @param reward
        ///     The reward to spawn
        /// @param position
        ///     The position to spawn at
        /// @param callback
        ///     The function to call when the ceremony is done
        ///
        private void SpawnRewardInternal(CurrencyItem reward, Vector3 position, Action callback)
        {
            // Spawn a bunch of particles
            int particleAmount = Math.Min(reward.m_value, k_maxParticles);

            if (reward.m_value > k_megaThreshold)
            {
                particleAmount = k_megaParticles;
            }

            TopPanelHolder holder = GetHolder(reward.m_currencyID);

            SpawnRewardInternal(particleAmount, reward, position, holder, callback);
        }
Beispiel #3
0
        /// @param currencyID
        ///     The currency to look for
        ///
        /// @return The top panel for this currency
        ///
        private TopPanelHolder GetHolder(string currencyID)
        {
            // Get from the static holders
            TopPanelHolder holder = GetHolder(m_holders, currencyID);

            if (holder == null)
            {
                // Get from the temporary holders
                holder = GetHolder(m_extraHolders, currencyID);
            }

            if (holder == null)
            {
                // Create extra holder
                var holderObject = ResourceUtils.LoadAndInstantiateGameObject(k_topHolderPath, m_hiddenPanelsHolder, currencyID);
                holder = holderObject.GetComponent <TopPanelHolder>();
                holder.SetCurrency(currencyID);
                holder.m_hidden = true;
                m_extraHolders.Add(holder);
            }
            return(holder);
        }
Beispiel #4
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);
        }