Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        int currentTime = (int)Time.time - timeStart;


        if (currentTime % 5 == 0)
        {
            gameTime = currentTime / 5;
        }

        if (!oneTimeBackSpawn)
        {
            if (gameTime == 5)
            {
                Time.timeScale = 1;
                Instantiate(backEmployee, new Vector3(UnityEngine.Random.Range(2, 3), 0, -9.95f), Quaternion.identity);
                oneTimeBackSpawn = true;
            }
        }

        if (!oneTimeFrontSpawn)
        {
            if (gameTime == 6)
            {
                Instantiate(frontEmployee, new Vector3(UnityEngine.Random.Range(2, 3), 0, -9.95f), Quaternion.identity);

                if (spawnCraig == true)
                {
                    Instantiate(craig, new Vector3(UnityEngine.Random.Range(2, 3), 0, -9.95f), Quaternion.identity);
                }
                oneTimeFrontSpawn = true;
            }
        }

        if (!oneTimeOpen)
        {
            if (gameTime == 7)
            {
                OpenOrClose(true);
                oneTimeOpen = true;
            }
        }

        if (!oneTimeClose)
        {
            if (gameTime >= 17)
            {
                if (!GameObject.FindGameObjectWithTag("customer") && !GameObject.FindGameObjectWithTag("frontEmployee1") && !GameObject.FindGameObjectWithTag("backEmployee") && !GameObject.FindGameObjectWithTag("frontEmployee2") && GameObject.Find("Spawnpoint").GetComponent <LockingTheDoor>().isLocked == true)
                {
                    OpenOrClose(false);
                    oneTimeClose = true;
                }
            }
        }

        if (gameTime >= 24)
        {
            timeUI.text = "0" + (gameTime - 24).ToString();
        }

        else if (gameTime < 10)
        {
            timeUI.text = "0" + gameTime.ToString();
        }

        else
        {
            timeUI.text = gameTime.ToString();
        }

        if (GameObject.Find("Spawnpoint").GetComponent <LockingTheDoor>().isLocked == true)
        {
            spawner.CancelInvoke();
        }
    }