Esempio n. 1
0
    // Timer co-routine
    private IEnumerator ThirstTimer()
    {
        yield return(new WaitForSeconds(thirstCounter));

        // When timer runs out, call alter view function and issue warning about being thirsty
        StartCoroutine(displayCanvas.DisplayStressGUI(displayCanvas.thirstyCanvas));
        StartCoroutine(Stressed());
        yield return(new WaitForSeconds(thirstCounter / 2));

        string level = "GameOver";

        endgame.EndTheGame(level, 8.0f);
    }
Esempio n. 2
0
    /// Called when the viewer's trigger is used, between OnGazeEnter and OnGazeExit.
    public void OnGazeTrigger()
    {
        // Call EndTheGame script
        EndGame endgame = FindObjectOfType <EndGame>();
        string  level   = "EndGame";

        endgame.EndTheGame(level, 10.0f);
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        if (!endGameScript.IsDead())
        {
            if (waitForStartScript.HasStarted())
            {
                timeLeft -= Time.deltaTime;
            }

            if (timeLeft <= 0)
            {
                endGameScript.EndTheGame(GameObject.Find("Tank"));
                timeLeft = 0;
            }
        }

        timeTextComponent.text  = string.Format("Time: {0:00.00}s", timeLeft);
        scoreTextComponent.text = string.Format("Score: {0:00000}", scoreHandlerScript.GetScore());
    }
Esempio n. 4
0
    private void checkCollisions(Collision2D collision)
    {
        if (collision.gameObject.tag == "Tank")
        {
            endGameScript.EndTheGame(collision.gameObject);
            return;
        }

        if (collision.gameObject.tag == "Enemy")
        {
            Destroy(collision.gameObject);
            scoreHandlerScript.AddToScore(100);

            GameObject     newParticleObject = Instantiate <GameObject>(enemyParticlesObject);
            ParticleSystem particleSystem    = newParticleObject.GetComponent <ParticleSystem>();
            particleSystem.transform.position = collision.gameObject.transform.position;
            particleSystem.Play();
            AudioSource.PlayClipAtPoint(Resources.Load <AudioClip>("GameScene/Audio/explosion"), new Vector3(0, 0, 0));
            Destroy(newParticleObject, particleSystem.main.startLifetime.constant); // destroy after the lifetime of the particles
            return;
        }
    }