public void testClick()
    {
        ButtonRandom     random_button      = GameObject.Find("Button_Random").GetComponent <ButtonRandom>();
        ButtonRandomNext random_button_next = GameObject.Find("Button_Random_Next").GetComponent <ButtonRandomNext>();
        Text             text_ponto         = GameObject.Find("Ponto_Text").GetComponent <Text>();

        print("Minha chave " + this.key);
        print("Chave random " + random_button.random_key);
        int value = 0;

        if (this.key == random_button.random_key)
        {
            print(text_ponto.text);
            value  = int.Parse(text_ponto.text);
            value += 30;
            print("Ganhou Ponto");
            text_ponto.text = value.ToString();
            random_button_next.updatable_next = true;
        }
        else if (this.key != random_button.random_key)
        {
            //PERDER PONTO E REFRESHA O PONTO
            if (int.Parse(text_ponto.text) != 0)
            {
                value  = int.Parse(text_ponto.text);
                value -= 30;
                print("Perdeu Ponto");
                text_ponto.text = value.ToString();
            }
        }
    }
示例#2
0
    public void testClick()
    {
        ButtonRandom     random_button      = GameObject.Find("Button_Random").GetComponent <ButtonRandom>();
        ButtonRandomNext random_button_next = GameObject.Find("Button_Random_Next").GetComponent <ButtonRandomNext>();
        Text             text_ponto         = GameObject.Find("Ponto_Text").GetComponent <Text>();

        print("Minha chave " + this.key);
        print("Chave random " + random_button.random_key);
        int value = 0;

        if (this.key == random_button.random_key)
        {
            print(text_ponto.text);
            value  = int.Parse(text_ponto.text);
            value += 30;
            print("Ganhou Ponto");
            text_ponto.text = value.ToString();
            random_button_next.updatable_next = true;

            Instantiate(comidas[Random.Range(0, comidas.Count)].transform, spawner.transform.position, Quaternion.identity);
        }
        else if (this.key != random_button.random_key)
        {
            //PERDER PONTO E REFRESHA O PONTO
            if (int.Parse(text_ponto.text) != 0)
            {
                value  = int.Parse(text_ponto.text);
                value -= 30;
                print("Perdeu Ponto");
                text_ponto.text = value.ToString();
            }
        }
    }
 // Update is called once per frame
 void Update()
 {
     if (this.updatable)
     {
         ButtonRandomNext random_button_next = GameObject.Find("Button_Random_Next").GetComponent <ButtonRandomNext>();
         print("My key " + this.random_key);
         print("Random_next_key " + random_button_next.random_next_key);
         this.random_key = random_button_next.random_next_key;
         this.GetComponent <Image>().sprite = this.random_list[this.random_key];
         this.updatable = false;
         random_button_next.updatable_next = true;
     }
 }