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

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;
    //GameObject controller_L;
    GameObject controller_R;

    GameObject gaugeBar;


    Color color;
    //Text textBlink;

   // float timeSpan;
    //float checkTime;

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

        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 (controller_R.GetComponent<ActionTest>().GetTeleportDown()) //
            {
                apple.SetActive(false);
                clue.SetActive(true);
                panel.SetActive(true);
                afterText.SetActive(false);
                gaugeBar.SetActive(false);



            }
        }

        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;
        }


    }

}