Ejemplo n.º 1
0
    void Start()
    {
        scaleAmount = transform.localScale.x;
        int score = lifeCost * PlayerStats.Current.Level / 10;

        deathHandler = new DeathHandler();
        deathHandler.AddAction(delegate { PlayerStats.Current.Score += score; });
        deathHandler.AddAction(delegate { PlayerStats.Current.IncreaseLevel(lifeCost / 10); });
        deathHandler.AddAction(delegate { if (scaleAmount == 10.0f)
                                          {
                                              PlayerStats.Current.Money += 1;
                                          }
                               });
        deathHandler.AddAction(delegate {
            Canvas canvasChild = GetComponentInChildren <Canvas>(true);

            if (canvasChild)
            {
                canvasChild.gameObject.SetActive(true);
                Text lifeCostChild = canvasChild.GetComponentInChildren <Text>();
                if (lifeCostChild)
                {
                    lifeCostChild.text = score.ToString();
                }
            }
        });
        deathHandler.AddAction(delegate
        {
            if (meteorSoundExplodeInAir && SettingsScript.EffectVolume > 0.01f)
            {
                meteorSoundExplodeInAir.volume = SettingsScript.EffectVolume * transform.localScale.x / 100;
                meteorSoundExplodeInAir.Play();
            }
        });
        deathHandler.AddAction(delegate { if (transform.localScale.x == 10 && coinSound && SettingsScript.EffectVolume > 0.01f)
                                          {
                                              coinSound.Play();
                                          }
                               });
        animController = gameObject.GetComponent <Animator>();
        movement       = gameObject.GetComponent <MovementScript>();
    }