Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        timer      = onTime;
        audioTimer = audioTimeBetweenTicks;

        torchSwitch = GetComponent <TorchSwitch>();

        countDown      = GameObject.FindWithTag("CountdownTimer").GetComponent <Text>();
        countDown.text = "";

        goal = transform.GetChild(3).GetComponent <TimedTorchGoal>();

        torchSwitch.Off();
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        if (goal.GetGoalReached())
        {
            goalReached    = true;
            countDown.text = "";
        }
        else
        {
            goalReached = false;
        }

        if (torchSwitch.GetTorchState())
        {
            startTimer = true;
        }


        if (startTimer == true && goalReached == false)
        {
            timer      -= Time.deltaTime;
            audioTimer -= Time.deltaTime;

            countDown.text = ((int)(timer + 1f)).ToString();

            if (audioTimer <= 0f)
            {
                audioTick.Play();
                float audioSpeedRatio = timer / onTime;
                if (audioSpeedRatio <= 0.15f)
                {
                    audioSpeedRatio = 0.15f;
                }
                audioTimer = audioTimeBetweenTicks * audioSpeedRatio;
            }

            if (timer <= 0f)
            {
                startTimer = false;
                torchSwitch.Off();
                audioTimer     = audioTimeBetweenTicks;
                timer          = onTime;
                countDown.text = "";
            }
        }
    }