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();
            }
        }
    }
Beispiel #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();
            }
        }
    }
    void Start()
    {
        ButtonRandom random_button_next = GameObject.Find("Button_Random").GetComponent <ButtonRandom>();

        this.updatable  = false;
        this.random_key = random_button_next.random_next_key;
        this.GetComponent <Image>().sprite = this.random_list[this.random_key];
    }
        void ReleaseDesignerOutlets()
        {
            if (ButtonRandom != null)
            {
                ButtonRandom.Dispose();
                ButtonRandom = null;
            }

            if (TextRandom != null)
            {
                TextRandom.Dispose();
                TextRandom = null;
            }
        }
 // Update is called once per frame
 void Update()
 {
     if (this.updatable_next)
     {
         ButtonRandom random_button = GameObject.Find("Button_Random").GetComponent <ButtonRandom>();
         random_button.GetComponent <Image>().sprite = this.GetComponent <Image>().sprite;
         random_button.random_key = this.random_next_key;
         random_button.updatable  = false;
         print("Random_next Button");
         this.random_next_key = Random.Range(0, this.random_list_next.Count);
         this.GetComponent <Image>().sprite = this.random_list_next[this.random_next_key];
         this.updatable_next = false;
     }
 }