Exemplo n.º 1
0
    private void SpawnDustIfPossible()
    {
        var start   = DateTime.Now;
        var oldDate = DateTime.Parse(plantStats[8]);

        if (happinessState == "sh")
        {
            timeNeededToSpawnDust = 10f;
        }
        if (happinessState == "h")
        {
            timeNeededToSpawnDust = 30f;
        }
        if (happinessState == "s")
        {
            timeNeededToSpawnDust = 60f;
        }
        if ((start - oldDate).TotalMinutes >= timeNeededToSpawnDust)
        {
            dust = PlayerPrefs.GetInt("dust", 0);
            dust++;//= Mathf.Abs((start - oldDate).TotalMinutes);
            plantStats[8] = DateTime.Now.ToString();
            db.ChangeDustDate(transform.name, plantStats[8]);

            PlayerPrefs.SetInt("dust", dust);
            PlayerPrefs.Save();
            DustText.GetComponent <Text>().text = dust.ToString();
            SpawnDust();
        }
    }