GaugeIncreasing.cs 2.06 KB
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;

public class GaugeIncreasing : MonoBehaviour
{
    Slider gauge;
    GameObject text;
    GameObject afterText;
    GameObject cheerUp;
    GameObject clue;
    GameObject panel;
    GameObject apple;
    GameObject step;
    Text stepText;
    int beforeStep;
    int afterStep;

    Color color;


    // Start is called before the first frame update
    void Start()
    {
        gauge = GetComponent<Slider>();
        text = GameObject.Find("Text");
        afterText = GameObject.Find("AfterText");
        clue = GameObject.Find("Clue");
        panel = GameObject.Find("Panel");
        apple = GameObject.Find("SweetPepper");
        cheerUp = GameObject.Find("CheerUp");
        step = GameObject.Find("Step");
        stepText = step.GetComponent<Text>();
        beforeStep = int.Parse(stepText.text);

        color = new Color(255f, 0, 0);
        
        afterText.SetActive(false);
        panel.SetActive(false);
        clue.SetActive(false);
        cheerUp.SetActive(false);

    }

    // Update is called once per frame
    void Update()
    {
        
        if (gauge.value >= 0.5f && gauge.value < 1)
            cheerUp.SetActive(true);
        else if (gauge.value >= 1)
        {
            gauge.gameObject.transform.Find("Fill Area").Find("Fill").GetComponent<Image>().color = color;
            apple.transform.Rotate(0, 60 * Time.deltaTime, 0);
            cheerUp.SetActive(false);
            text.SetActive(false);
            afterText.SetActive(true);

            if (Input.GetKeyDown(KeyCode.A)) //
            {
                apple.SetActive(false);
                clue.SetActive(true);
                panel.SetActive(true);
                

            }
        }

        afterStep = int.Parse(stepText.text);

        if (beforeStep != afterStep)
        {
            gauge.value += 0.01f;
            apple.transform.localScale += new Vector3(0.05f, 0.05f, 0.05f);

            beforeStep = afterStep;
        }

    }

}