Ejemplo n.º 1
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary" || other.tag == "Enemy")
        {
            return;
        }

        if (explosion != null)
        {
            Instantiate(explosion, transform.position, transform.rotation);
        }

        if (other.tag == "Player")
        {
            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            gameController.GameOver();
        }
        if (other.tag == "Player2")
        {
            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            gameController.GameOver();             // if multiplayer do game over accure if only one of the ship if dead
        }

        gameController.AddScore(scoreValue);
        Destroy(other.gameObject);
        Destroy(gameObject);
    }
    // destroy the player in contact.
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary" || other.tag == "Enemy")
        {
            return;
        }

        // explode this object.

        /*
         *      if (explosion != null)
         *      {
         *              Instantiate(explosion, transform.position, transform.rotation);
         *      }
         */

        // in contact with player,
        if (other.tag == "Player")
        {
            damagePlayer(other.transform);
            // spawn explostion at player's position.
            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            gameController.GameOver();
        }

        // add to the score.
        gameController.AddScore(scoreValue);
        // destroy any object in contact and itself.
        //Destroy (other.gameObject);
        //Destroy (gameObject);
    }
Ejemplo n.º 3
0
    void OnTriggerEnter(Collider other)
    {
        print("We are detecting " + other.name);
        if (other.tag == "Boundary" || other.tag == "Enemy")
        {
            return;
        }

        if (explosion != null)
        {
            print(this.name + " Should be exploding");
            Instantiate(explosion, transform.position, transform.rotation);
        }

        if (other.tag == "Player")
        {
            print("We see the player explode");
            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            gameController.GameOver();
        }

        gameController.AddScore(scoreValue);
        Destroy(other.gameObject);
        Destroy(gameObject);
    }
Ejemplo n.º 4
0
    void OnTriggerEnter(Collider other)
    {
        //If colide boundary or other enemy do nothing and return to game
        if (other.tag == "Boundary" || other.tag == "Enemy")
        {
            return;
        }

        life--;

        //Perform explosion
        if (explosion != null && life <= 0)
        {
            Instantiate(explosion, transform.position, transform.rotation);
        }

        //Colide with player is game over for player
        if (other.tag == "Player")
        {
            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            gameController.GameOver();
        }

        Destroy(other.gameObject);
        gameController.AddScore(scoreValueOnHit);

        //If no remaining life destroy me,
        if (life <= 0)
        {
            Destroy(gameObject);
            gameController.AddScore(scoreValue);
        }
    }
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary" || other.tag == "Enemy")
        {
            return;
        }

        if (explosion != null)
        {
            Instantiate(explosion, transform.position, transform.rotation);
        }

        if (other.tag == "Player")
        {
            Aura aura = other.GetComponent <Aura>();

            if (!aura.m_IsActive)
            {
                Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
                gameController.GameOver();
                Destroy(other.gameObject);
            }
        }

        gameController.AddScore(scoreValue);

        Destroy(gameObject);
    }
Ejemplo n.º 6
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary" || other.tag == "Enemy")
        {
            return;
        }


        if (explosion != null)
        {
            Instantiate(explosion, transform.position, transform.rotation);
        }

        if (other.tag == "Player")
        {
            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            gameController.GameOver(gameObject.name);
        }

        gameController.AddScore(scoreValue);

        // Prevent indestructable objects from being destroyed
        if (other.tag != "Indestructable")
        {
            Destroy(other.gameObject);
        }

        Destroy(gameObject);
    }
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary" || other.tag == "Enemy")
        {
            return;
        }

        if (explosion != null)
        {
            // ADDRESSABLES UPDATES
            explosion.InstantiateAsync(transform.position, transform.rotation);
        }

        if (other.tag == "Player")
        {
            // ADDRESSABLES UPDATES
            playerExplosion.InstantiateAsync(other.transform.position, other.transform.rotation);

            gameController.GameOver();
        }

        gameController.AddScore(scoreValue);

        // ADDRESSABLES UPDATES
        Addressables.ReleaseInstance(other.gameObject);
        Addressables.ReleaseInstance(gameObject);
    }
Ejemplo n.º 8
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary" || other.tag == "Enemy")
        {
            return;
        }

        if (explosion != null)
        {
            Instantiate(explosion, transform.position, transform.rotation);
        }

        if (other.tag == "Player")
        {
            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            gameController.PlayerNums--;
            //gameController.gameOverText.text = Convert.ToString(gameController.PlayerNums);
            if (gameController.PlayerNums == 0)
            {
                gameController.GameOver();
            }
        }

        gameController.AddScore(scoreValue);
        Destroy(other.gameObject);
        Destroy(gameObject);
    }
Ejemplo n.º 9
0
    void OnTriggerEnter(Collider impactObject)
    {
        if (impactObject.tag != "ChaseSensor" && impactObject.tag != "EnemyAI" && impactObject.tag != "Boundery" &&
            impactObject.tag != "Blast" && impactObject.tag != "echoBlast")
        {
            if (Player)
            {
                float damage = 10;
                gameController.sheildS.Damage(damage);
                damage = damage - gameController.sheildS.Health;
                if (damage > 0)
                {
                    gameController.healthS.Damage(damage);
                }

                Instantiate(smallExplotion, transform.position, transform.rotation);
                if (gameController.healthS.Health == 0)
                {
                    gameController.GameOver();
                    Instantiate(explosion, transform.position, transform.rotation);
                    Destroy(transform.parent.parent.gameObject);
                }
            }
        }
    }
Ejemplo n.º 10
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "PlayerBullet")
        {
            BulletData bulletdata = other.GetComponent <BulletData>();
            if (!bulletdata.getEnemyName().Equals(gameObject.name))
            {
                return;
            }
        }

        if (other.tag == "EnemyBullet" || other.tag == "Enemy" || other.tag == "Boundary")
        {
            return;
        }

        if (explosion != null)
        {
            Instantiate(explosion, transform.position, transform.rotation);
        }

        if (other.tag == "Player")
        {
            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            gameController.GameOver();
        }

        gameController.AddScore(scoreValue);
        Destroy(other.gameObject);
        Destroy(gameObject);
    }
Ejemplo n.º 11
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary" || other.tag == "Enemy")
        {
            return;
        }

        if (explosion != null)
        {
            Instantiate(explosion, transform.position, transform.rotation);
        }

        if (other.tag == "Player")
        {
            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            //GameObject.FindWithTag("Player").SetActive(false);
            Destroy(GameObject.FindGameObjectWithTag("Player"));
            gameController.GameOver();
        }

        gameController.AddScore(scoreValue);
        Destroy(gameObject);
        //Destroy(other.gameObject);
        Debug.Log(other.name);
        //ShipDestroyed = true;
    }
Ejemplo n.º 12
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary" || other.tag == "Enemy")
        {
            return;
        }

        if (explosion != null)
        {
            Instantiate(explosion, transform.position, transform.rotation);
        }

        if (other.tag == "Player")
        {
            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            FindObjectOfType <InputField>().readOnly = true;
            gameController.GameOver();
        }
        else
        {
            TextMeshPro textMeshPro = gameObject.GetComponentInChildren <TextMeshPro>();
            if (textMeshPro == null)
            {
                Debug.Log("????");
            }
            gameController.currentWords.Remove(textMeshPro.text);
            gameController.currentHazards.Remove(gameObject);
        }

        gameController.AddScore(scoreValue);
        Destroy(other.gameObject);
        Destroy(gameObject);
    }
Ejemplo n.º 13
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "shoot")
        {
            Instantiate(explosion, transform.position, transform.rotation);
        }

        if (other.tag == "Boundary" || other.tag == "Enemy")
        {
            return;
        }

        if (explosion != null)
        {
            Instantiate(explosion, transform.position, transform.rotation);
        }

        if (other.tag == "Player")
        {
            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            gameController.GameOver();
        }

        gameController.AddScore(scoreValue);
        Destroy(other.gameObject);
        Destroy(gameObject);
    }
Ejemplo n.º 14
0
 void OnMouseDown()
 {
     if (explosion != null)
     {
         Instantiate(explosion, transform.position, transform.rotation);
     }
     gameController.GameOver();
     Destroy(gameObject);
 }
Ejemplo n.º 15
0
 private void OnTriggerEnter(Collider aCol)
 {
     if (aCol.tag == "Player")
     {
         Instantiate(m_PlayerExplosion, aCol.transform.position, Quaternion.identity);
         Destroy(aCol.gameObject);
         m_GameController.GameOver();
     }
 }
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary" || other.tag == "Enemy" || other.tag == "Boss")
        {
            return;
        }

        if (explosion != null)
        {
            Instantiate(explosion, transform.position, explosion.transform.rotation);
        }

        if (this.tag == "Boss")
        {
            gameController.helthCounterBoss = gameController.helthCounterBoss - 1;
            if (gameController.helthCounterBoss == 0)
            {
                gameController.bossHelth.text = "";
                Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            }
            else
            {
                gameController.bossHelth.text = "";
                for (int i = 1; i <= gameController.helthCounterBoss; i++)
                {
                    gameController.bossHelth.text = gameController.bossHelth.text + "E";
                }
                return;
            }
        }

        if (other.tag == "Player")
        {
            gameController.helthCounter = gameController.helthCounter - 1;
            if (gameController.helthCounter == 0)
            {
                gameController.playerHelth.text = "";
                Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
                gameController.GameOver();
            }
            else
            {
                Destroy(gameObject);
                gameController.playerHelth.text = "";
                for (int i = 1; i <= gameController.helthCounter; i++)
                {
                    gameController.playerHelth.text = gameController.playerHelth.text + "E";
                }
                return;
            }
        }

        gameController.AddScore(scoreValue);
        Destroy(other.gameObject);
        Destroy(gameObject);
    }
Ejemplo n.º 17
0
 //this method take away a life from the player, and eventually kill him if he reaches 0 lives
 public void LoseLife()
 {
     lives--;
     UpdateHealthBar();
     if (lives <= 0)
     {
         Instantiate(playerExplosion, transform.position, transform.rotation);
         gameController.GameOver();
         Destroy(gameObject);
     }
 }
Ejemplo n.º 18
0
 void decreaseTimeRemaining()
 {
     if (timeRemaining == 0)
     {
         gameController.GameOver();
     }
     else
     {
         timeRemaining -= timeToDecrease;
         //Debug.Log ("timeRemaining " + timeRemaining);
     }
 }
Ejemplo n.º 19
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("Enemy"))
        {
            Destroy(other.gameObject);
            Debug.Log("tag works");
            Done_GameController gameController = (Done_GameController)game.GetComponent(typeof(Done_GameController));
            gameController.GameOver();

            Destroy(GameObject.Find("renderer"));
            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
        }
    }
Ejemplo n.º 20
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary" || other.tag == "Enemy")
        {
            return;
        }

        // If the other is an indestructable object, destroy this unit
        if (other.tag == "Indestructable")
        {
            health = 0;
        }
        // Otherwise, subtract 1 health
        else
        {
            health--;
        }


        // Update the health bar to the percentage remaining
        Vector3 _newScale = healthBar.transform.localScale;

        _newScale.x = heathBarInitialWidth * (health / maxHealth);
        healthBar.transform.localScale = _newScale;

        // If the enemy is out of health, blow it up
        if (health <= 0)
        {
            if (explosion != null)
            {
                Instantiate(explosion, transform.position, transform.rotation);
            }

            if (other.tag == "Player")
            {
                Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
                gameController.GameOver(gameObject.name);
            }

            gameController.AddScore(scoreValue);

            destroySelf();
            Destroy(healthBar);
        }

        // Prevent indestructable objects from being destroyed
        if (other.tag != "Indestructable")
        {
            Destroy(other.gameObject);
        }
    }
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary")
        {
            return;
        }

        if (other.tag == "Enemy" || other.tag == "EnemyWithPowerUp" || other.tag == "EnemyWithBomb")
        {
            if (playerExplosion != null)
            {
                Instantiate(playerExplosion, transform.position, transform.rotation);
                Destroy(other.gameObject);
                Destroy(gameObject);
                gameController.GameOver();
            }
        }


        if (other.tag == "EnemyBullet")
        {
            counter++;
            Destroy(other.gameObject);

            if (counter == Live)
            {
                if (playerExplosion != null)
                {
                    Instantiate(playerExplosion, transform.position, transform.rotation);
                    Destroy(other.gameObject);
                    Destroy(gameObject);
                    gameController.GameOver();
                }
            }
            liveCount--;
            gameController.UpdateLive(liveCount);
        }
    }
    void OnTriggerEnter(Collider other)
    {
        if ((other.tag != "Coin") && (other.tag != "BoltUp"))
        {
            if (other.tag == "shoot")
            {
                Instantiate(explosion, transform.position, transform.rotation);
            }

            if (other.tag == "Boundary" || other.tag == "Enemy")
            {
                return;
            }

            if (explosion != null)
            {
                Instantiate(explosion, transform.position, transform.rotation);
            }

            if (other.tag == "Player")
            {
                Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
                gameController.GameOver();
            }

            if (gameController != null)
            {
                Destroy(other.gameObject);

                //si el asteroide no queda destruído simplemente quitarle una vida
                if (lifes > 0)
                {
                    if (other.name == "Sphere")
                    {
                        AsteroidDestroid();
                    }
                    else
                    {
                        lifes--;
                    }
                }
                //de no ser así ...
                else
                {
                    AsteroidDestroid();
                }
            }
        }
    }
Ejemplo n.º 23
0
    private void OnCollisionEnter(Collision other)
    {
        if (explosion != null && other.gameObject.tag == "Player")
        {
            Instantiate(explosion, transform.position, transform.rotation);
            Destroy(gameObject);
        }

        if (other.gameObject.tag == "Player")
        {
            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            Destroy(other.gameObject);
            gameController.GameOver();
            Destroy(gameObject);
        }
    }
Ejemplo n.º 24
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Boundary")
     {
         return;
     }
     Instantiate(explosion, transform.position, transform.rotation);
     if (other.tag == "Player")
     {
         Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
         gameController.GameOver();
         Debug.Log("Cannot find End");
     }
     gameController.AddScore(scoreValue);
     Destroy(other.gameObject);
     Destroy(gameObject);
 }
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary" || other.tag == "explosion")
        {
            return;
        }

        if (other.tag == "Player")
        {
            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            gameController.GameOver();
            Destroy(other.gameObject);
        }

        if (other.tag == "Enemy")
        {
            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            Destroy(other.gameObject);
        }
    }
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary")
        {
            return;
        }

        if (explosion != null)
        {
            Instantiate(explosion, transform.position, transform.rotation);
        }

        if (other.tag == "Player")
        {
            if (gameController.playerInvincible)
            {
                gameController.AddScore(scoreValue);
                Destroy(gameObject);
                return;
            }
            else
            {
                Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
                if (--gameController.playerLives <= 0)
                {
                    gameController.GameOver();
                }
                else
                {
                    gameController.Respawn();
                }
                gameController.livesText.text = "Lives: " + gameController.playerLives;
            }
        }

        gameController.AddScore(scoreValue);

        Destroy(other.gameObject);
        Destroy(gameObject);
    }
Ejemplo n.º 27
0
    // 陨石碰撞
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary" || other.tag == "Enemy")
        {
            return;
        }

        if (explosion != null)
        {
            Instantiate(explosion, transform.position, transform.rotation);
        }

        if (other.tag == "Player" && other.GetComponent <Done_PlayerController>().server_plane_index == nm.plane_index)
        {
            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            gameController.GameOver();
        }

        gameController.AddScore(scoreValue);
//        Destroy(other.gameObject);
        Destroy(gameObject);
    }
Ejemplo n.º 28
0
 void Update()
 {
     time += Time.deltaTime;
     if (time >= interpolationPeriod && currentHealth > 0 && gameController.startedGame)
     {
         time          = 0.0f;
         currentHealth = currentHealth - 0.2f;
         //displayedHealth = currentHealth - 0.2f;
         //if (displayedHealth - currentHealth > 0){
         //    displayedHealth = displayedHealth - 0.05f;
         //}
         //else if (currentHealth - displayedHealth < 0){
         //    displayedHealth = displayedHealth + 0.05f;
         //}
         healthBar.sizeDelta = new Vector2(currentHealth, healthBar.sizeDelta.y);
         //d2FogsPE.Density =(float)(2 * (maxHealth - displayedHealth) / (maxHealth));
     }
     if (currentHealth <= 0)
     {
         gameController.GameOver();
     }
     healthBar.sizeDelta = new Vector2(currentHealth, healthBar.sizeDelta.y);
 }
Ejemplo n.º 29
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary" || other.tag == "Enemy")
        {
            return;
        }

        if (explosion != null)
        {
            explosion.GetComponent <AudioSource>().panStereo = transform.position.x / maxposX;
            Instantiate(explosion, transform.position, transform.rotation);
        }

        if (other.tag == "Player")
        {
            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            gameController.GameOver();
        }

        gameController.AddScore(scoreValue);
        Destroy(other.gameObject);
        Destroy(gameObject);
    }
Ejemplo n.º 30
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary" || other.tag == "Enemy" || other.tag == "Ad")
        {
            return;
        }

        if (explosion != null)
        {
            Instantiate(explosion, transform.position, transform.rotation);
        }

        if (other.tag == "Player")
        {
            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            gameController.GameOver();
            deathsNumber += 1;
            PlayerPrefs.SetInt("Deaths number:", deathsNumber);
            if (canIShowAd == 1 || deathsNumber == 4)
            {
                ShowAd();
                deathsNumber = 0;
                PlayerPrefs.SetInt("Deaths number:", deathsNumber);
            }
            if (deathsNumber > 4)
            {
                deathsNumber = 0;
                PlayerPrefs.SetInt("Deaths number:", deathsNumber);
            }
        }

        gameController.AddCoins(coinsValue);
        gameController.AddLevelCoins(levelCoinsValue);
        gameController.AddLevelScore(levelScoreValue);
        Destroy(other.gameObject);
        Destroy(gameObject);
    }