GaugeIncreasing.cs 1.95 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;

    Color color;
    //Text textBlink;

    float timeSpan;
    float checkTime;

    // 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");
        color = new Color(255f, 0, 0);
        timeSpan = 0.0f;
        checkTime = 0.1667f;
        
        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);
                

            }
        }

        timeSpan += Time.deltaTime;
        if (timeSpan > checkTime)
        {
            gauge.value += 0.01f;
            apple.transform.localScale += new Vector3(0.05f, 0.05f, 0.05f);
            
            timeSpan = 0;
        }

    }

}