示例#1
0
    // Update is called once per frame
    void Update()
    {
        /*count += Time.deltaTime;
         * if ((int)count == 5)
         * {
         *  anim_eyes.SetBool("Clicked", true);
         *  count = 0;
         * }
         * else
         * {
         *  anim_eyes.SetBool("Clicked", false);
         * }*/

        TimeSpan ts = DateTime.ParseExact(ui.GetDateJeu(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture) - DateTime.ParseExact(datePlantage, "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

        tempsDePousseActuel = ts.TotalHours;

        indexImage = (int)Decimal.Round((decimal)((tempsDePousseActuel * 5) / tempsPousseMin), 0);

        if (tempsDePousseActuel <= tempsPousseMin)
        {
            ChangeImage(indexImage - 1);
        }
        else
        {
            ChangeImage(4);
        }

        if (tempsDePousseActuel > (tempsPousseMin / 4) * (indexImage - 1))
        {
            //indexImage++;
            ChangeImage(indexImage - 1);
        }

        /* if (tempsDePousseActuel <= tempsPousseMin)
         * {
         *  tempsDePousseActuel += Time.deltaTime;
         * }*/

        if (tempsDePousseActuel >= tempsPousseMin)
        {
            if (nbActuel % tpsRepetition == 0)
            {
                if (jeu.GetProfil(1).IdNiveau == 1)
                {
                    GameObject ferm = Instantiate(bulleAideDebutant, new Vector3(transform.position.x, transform.position.y + 1.5f, transform.position.z), new Quaternion(0f, 0f, 0f, 0f));
                    ferm.GetComponent <PetitFermierController>().SetPhraseRecolterDeb();
                    //ferm.transform.SetParent(ui.transform);
                }
                else if (jeu.GetProfil(1).IdNiveau == 2)
                {
                    GameObject newFermier = Instantiate(fermier);
                    newFermier.transform.SetParent(ui.gameObject.transform);
                    newFermier.GetComponent <FermierController>().SetPhraseRecolterInt();
                }
            }
            nbActuel += 1;
        }

        if (tempsDePousseActuel > tempsPousseMax)
        {
            // TODO : faire perdre des points parce que légume pourrit
            ParselleController parcelle = gameObject.transform.parent.gameObject.GetComponent <ParselleController>();
            parcelle.Supprimer(500, true);
        }
    }