Exemple #1
0
    public void CheckNeeds(Seed.Needs care)
    {
        rightNeed = false;

        if (careable)
        {
            for (int i = 0; i < needsList.ToArray().Length; i++)
            {
                Need need = needsPanel.transform.GetChild(i).gameObject.GetComponent <Need> ();
                if (need.type == care && !need.IsFullfilled())
                {
                    need.SetFullfilled();
                    rightNeed = true;
                    // Soma pontos
                    score.GetComponent <ScoreController> ().AddPoints(10);
                    plantStage.GetComponent <Image> ().sprite = plantStages [3 - RemainingNeeds()];
                    plantStage.GetComponent <Image> ().color  = new Color(1f, 1f, 1f, 1f);
                    errorMod = 1;
                    break;
                }
            }
            // Se for o cuidado errado
            if (!rightNeed)
            {
                // Desconta pontos
                score.GetComponent <ScoreController> ().SubtractPoints(errorMod);
                errorMod++;
                audioPlayer.PlayOneShot(errorAudio);
            }

            // Checa se todos as necessidades foram preenchidas, remove e adiciona outro vaso no lugar
            if (RemainingNeeds() == 0)
            {
                score.GetComponent <ScoreController> ().AddPoints(100);
                audioPlayer.PlayOneShot(clearAudio);
                careable = false;
                StartCoroutine(WaitUpAndDeactivate(3));
                StartCoroutine(WaitUpAndRenew(5));
            }
            else if (rightNeed)
            {
                audioPlayer.PlayOneShot(scoreAudio);
            }
        }
    }