Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        player = FindObjectOfType <PlayerBehaviour>();

        paused         = false;
        Time.timeScale = 1f;
        pauseMenu.SetActive(false);
        endTime.SetActive(false);

        delaycpy = delay;
        if (delaycpy % 60 > 0)
        {
            m         = (int)delaycpy / 60;
            delaycpy -= m * 60;
            s         = (int)delaycpy;
        }
        //Debug.Log(m + " - " + s);

        current       = imgs[player.index];
        index         = player.index;
        current.color = new Color(1, 0, 0);
        iMenu.SetActive(false);
        Goal.GetComponent <Text>().text = score + " / " + maxScore;
        Won.SetActive(false);

        deltaT = Time.deltaTime;
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        Debug.Log(deltaT);
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            isPaused();
            deltaT = 0;
        }
        else
        {
            deltaT = Time.deltaTime;
        }

        //Counter
        if (m >= 0)
        {
            s -= deltaT;
            if (s <= 0)
            {
                m--;
                s = 60;
            }
        }
        else if (m <= 0)
        {
            Time.timeScale = 0f;
            timer.SetActive(false);
            endTime.SetActive(true);
        }

        //Power Up time.
        if (player.isPwrdUp)
        {
            powerUp.SetActive(true);
            powerUp.GetComponent <Text>().text = "Ends in... " + (int)player.pwrDelay;
        }
        else
        {
            powerUp.SetActive(false);
        }

        if (player.isHit)
        {
            damaged.SetActive(true);
            damaged.GetComponent <Text>().text = "Pain ends in..." + (int)player.hitDelay;
        }
        else
        {
            damaged.SetActive(false);
        }

        //State system
        if (index != player.index)
        {
            for (int i = 0; i < imgs.Length; i++)
            {
                imgs[i].color = Color.white;
            }
            index = player.index;
        }
        else
        {
            current       = imgs[player.index];
            current.color = new Color(0.8f, 0.4f, 0.2f);
        }

        //imgs
        timer.GetComponent <Text>().text = "Time: " + (int)m + ": " + (int)s;
        Goal.GetComponent <Text>().text  = score + " / " + maxScore;

        if (score == maxScore)
        {
            Time.timeScale = 0f;
            Won.SetActive(true);
        }
    }