Пример #1
0
 // When target is clicked, destroy it, update score, and generate explosion
 private void OnMouseDown()
 {
     if (gameManagerX.isGameActive)
     {
         Destroy(gameObject);
         gameManagerX.UpdateScore(pointValue);
         Explode();
         if (gameObject.CompareTag("Bad"))
         {
             gameManagerX.GameOver();
         }
     }
 }
    private void OnCollisionEnter(Collision collision)
    {
        //for destroying plane and displaying game over text
        if (collision.gameObject.CompareTag("Map"))
        {
            Cursor.visible = true;
            Destroy(gameObject);
            Instantiate(deathParticle, transform.position, deathParticle.transform.rotation);
            gameManager.GameOver();
        }

        //fpr displaying win text
        if (collision.gameObject.CompareTag("Finish") && point >= 6)
        {
            Cursor.visible = true;
            Destroy(gameObject);
            gameManager.Win();
        }

        //for displaying lose text when player finishes with not enough points
        if (collision.gameObject.CompareTag("Finish") && point < 6)
        {
            Cursor.visible = true;
            Destroy(gameObject);
            Instantiate(deathParticle, transform.position, deathParticle.transform.rotation);
            gameManager.Lose();
        }
    }
    // If target that is NOT the bad object collides with sensor, trigger game over
    private void OnTriggerEnter(Collider other)
    {
        Destroy(gameObject);

        if (other.gameObject.CompareTag("Sensor") && !gameObject.CompareTag("Bad"))
        {
            gameManagerX.GameOver();
        }
    }
Пример #4
0
    void Update()
    {
        countdown.text = ("time: " + timeLeft);

        if (timeLeft <= 0)
        {
            gameManagerX.GameOver();
        }
    }
Пример #5
0
 void Update()
 {
     timeLeft -= Time.deltaTime;
     text.text = "Time Left: " + Mathf.Round(timeLeft);
     if (timeLeft < 0)
     {
         gmX.GameOver();
     }
 }
Пример #6
0
    // If target that is NOT the bad object collides with sensor, trigger game over
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.collider.CompareTag("Sensor"))
        {
            Destroy(gameObject);

            if (!gameObject.CompareTag("Bad"))
            {
                gameManagerX.GameOver();
            }
        }
    }
    IEnumerator TimerCoroutine()
    {
        while (gameManagerX.isGameActive)
        {
            yield return(new WaitForSeconds(1));

            timeLeft         -= 1;
            timeLeftText.text = "Time: " + timeLeft;
            if (timeLeft <= 0)
            {
                gameManagerX.GameOver();
            }
        }
    }
Пример #8
0
    /// <summary>
    /// Countsdown the timer every second.
    /// </summary>
    private IEnumerator Countdown()
    {
        while (gameManager.isGameActive)
        {
            yield return(new WaitForSeconds(1f));

            time -= 1;
            UpdateText();

            if (time <= 0)
            {
                gameManager.GameOver();
            }
        }
    }
    private void Update()
    {
        if (running)
        {
            timeLeft -= Time.deltaTime;

            if (timeLeft < 1)
            {
                timeLeft = 0;
                gameManager.GameOver();
                // running = false;
            }

            text.text = "Time Left: " + (int)Math.Floor(timeLeft);
        }
    }
Пример #10
0
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.CompareTag("Ground"))
        {
            isOnGround = true;
            dirtParticle.Play();
        }
        else if (collision.gameObject.CompareTag("Obstacle"))
        {
            TakeDamage(1);
            playerAudio.PlayOneShot(crashSound, 1.0f);
            explosionParticle.Play();

            if (currentHealth == 0)
            {
                gameManagerController.gameOver = true;
                gameManagerController.GameOver();
                playerAnim.SetBool("Death_b", true);
                playerAnim.SetInteger("DeathType_int", 1);
                explosionParticle.Play();
                dirtParticle.Stop();
            }
        }
    }