Exemplo n.º 1
0
    public override void OnCollected()
    {
        int sandboxStarCollectCount = GameProgress.GetSandboxStarCollectCount(Singleton <GameManager> .Instance.CurrentSceneName, base.NameKey);

        if (sandboxStarCollectCount <= 1)
        {
            int num = Singleton <GameConfigurationManager> .Instance.GetValue <int>("star_box_snout_value", "amount");

            if (num > 0 && !Singleton <BuildCustomizationLoader> .Instance.IsOdyssey)
            {
                GameProgress.AddSandboxStar(Singleton <GameManager> .Instance.CurrentSceneName, base.NameKey, true);
                num = ((!Singleton <DoubleRewardManager> .Instance.HasDoubleReward) ? num : (num * 2));
                GameProgress.AddSnoutCoins(num);
                Singleton <PlayerProgress> .Instance.AddExperience(PlayerProgress.ExperienceType.StarBoxCollectedSandbox);

                AudioSource win_snd = new GameObject("sbox").AddComponent <AudioSource>();
                win_snd.GetComponent <AudioSource>().clip   = (AudioClip)Resources.Load("AudioAdd" + Path.DirectorySeparatorChar + "win_snd");
                win_snd.GetComponent <AudioSource>().loop   = false;
                win_snd.GetComponent <AudioSource>().volume = 1f;
                win_snd.GetComponent <AudioSource>().Play();
                base.ShowXPParticles();
                for (int i = 0; i < num; i++)
                {
                    SnoutCoinSingle.Spawn(base.transform.position - Vector3.forward, 1f * (float)i);
                }
            }
            else if (sandboxStarCollectCount < 1)
            {
                AudioSource win_snd = new GameObject("sbox").AddComponent <AudioSource>();
                win_snd.GetComponent <AudioSource>().clip   = (AudioClip)Resources.Load("AudioAdd" + Path.DirectorySeparatorChar + "win_snd");
                win_snd.GetComponent <AudioSource>().loop   = false;
                win_snd.GetComponent <AudioSource>().volume = 1f;
                win_snd.GetComponent <AudioSource>().Play();
                GameProgress.AddSandboxStar(Singleton <GameManager> .Instance.CurrentSceneName, base.NameKey, false);
            }
        }
        if (StarBox.onCollected != null)
        {
            StarBox.onCollected();
        }
        if (this.onCollect != null)
        {
            this.onCollect();
        }
    }