Esempio n. 1
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);
        }
    }
Esempio n. 2
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Boundary" || other.tag == "Enemy")
     {
         return;
     }
     if (other.tag == "Player")
     {
         Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
         gameController.GameOver();
     }
     if (other.tag == "shot")
     {
         Instantiate(explosion, transform.position, transform.rotation);
         gameController.AddScore(scoreValue);
         Destroy(other.gameObject);
         Destroy(gameObject);
     }
     if (other.tag == "Blast")
     {
         Instantiate(Misselblast, transform.position, transform.rotation);
         gameController.AddScore(scoreValue);
         Destroy(other.gameObject);
         Destroy(gameObject);
     }
     if (other.tag == "echoBlast")
     {
         Instantiate(explosion, transform.position, transform.rotation);
         gameController.AddScore(scoreValue);
         Destroy(gameObject);
     }
 }
Esempio n. 3
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary" || other.tag == "Enemy" || other.tag == "Bolt")
        {
            return;
        }

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

        if (other.tag == "Player")
        {
            //Give player the power
            gameObject.GetComponent <Powerup>().GivePowerup(other.gameObject);
            gameController.AddScore(scoreValue);
            Destroy(gameObject);
            return;
        }

        gameController.AddScore(scoreValue);
        Destroy(other.gameObject);
        Destroy(gameObject);
    }
Esempio n. 4
0
    IEnumerator operateBunusFunction()
    {
        yield return(new WaitForSeconds(delayTime));

        Debug.Log("time's up");
        switch (surpriseType)
        {
        case E_SurpriseType.e_addScore:
            gameController.AddScore(pointsToAdd);
            break;

        case E_SurpriseType.e_subScore:
            gameController.AddScore(-pointsToAdd);
            break;

        case E_SurpriseType.e_addTime:
            timerGameObject.increaseTimeRemaining(timeToAdd);
            break;

        case E_SurpriseType.e_subTime:
            timerGameObject.increaseTimeRemaining(-timeToAdd);
            break;
        }

        if (explosion != null)
        {
            Instantiate(explosion, transform.position, transform.rotation);
        }
        Destroy(gameObject);
    }
Esempio n. 5
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary" || other.tag == "Enemy" || other.tag == "EnemyWithBomb")
        {
            return;
        }



        if (other.tag == "Bullet")
        {
            counter++;
            Destroy(other.gameObject);
        }
        if (counter == hit)
        {
            if (explosion != null)
            {
                Instantiate(explosion, transform.position, transform.rotation);
                if (this.tag == "EnemyWithBomb")
                {
                    Instantiate(itemBomb, transform.position, transform.rotation);
                }
                if (this.tag == "EnemyWithPowerUp")
                {
                    Instantiate(itemPowerUp, transform.position, transform.rotation);
                }
                gameController.AddScore(scoreValue);
                Destroy(gameObject);
                playerExplose.Play();
            }
        }


        if (other.tag == "Bomb")
        {
            Collider[] nearObjects = Physics.OverlapSphere(transform.position, 4f);

            foreach (Collider enemy in nearObjects)
            {
                if (enemy.tag != "Player" && enemy.tag != "Boundary")
                {
                    Instantiate(explosion, enemy.transform.position, enemy.transform.rotation);
                    Destroy(enemy.gameObject);
                }
                if (enemy.tag == "Enemy" || enemy.tag == "EnemyWithBomb")
                {
                    gameController.AddScore(scoreValue - 10);
                }
            }
            Destroy(other.gameObject);
            Destroy(gameObject);
        }
    }
Esempio 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.PlayerNums--;
            //gameController.gameOverText.text = Convert.ToString(gameController.PlayerNums);
            if (gameController.PlayerNums == 0)
            {
                gameController.GameOver();
            }
        }

        gameController.AddScore(scoreValue);
        Destroy(other.gameObject);
        Destroy(gameObject);
    }
Esempio n. 7
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;
    }
Esempio 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.GameOver(gameObject.name);
        }

        gameController.AddScore(scoreValue);

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

        Destroy(gameObject);
    }
Esempio n. 9
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);
    }
Esempio n. 10
0
    public void EnemyTakeDamage(int amount)
    {
        if (isDead)
        {
            return;
        }

        currentHealth -= amount;
        if (HitExplosion != null)
        {
            Instantiate(HitExplosion, transform.position, transform.rotation);
        }


        /*	if (isHit) {
         *
         *              GetComponentInChildren<Renderer>().material.SetColor ("_EmissionColor", Color.black);
         */



        // If the current health is less than or equal to zero...
        if (currentHealth <= 0)
        {
            Death();

            GameController.AddScore(scoreValue);
        }
    }
Esempio n. 11
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Boundary" || other.tag == "Enemy" || other.tag == "Powerup")
     {
         return;
     }
     if (other.tag != "Player" && other.tag != "Shield")
     {
         Destroy(other.gameObject);
     }
     if (other.tag == "Player")
     {
         other.gameObject.GetComponent <Done_PlayerController>().LoseLife();
     }
     if (!doubleLife)
     {
         if (explosion != null)
         {
             Instantiate(explosion, transform.position, transform.rotation);
         }
         gameController.AddScore(scoreValue);
         if (isShip)
         {
             gameObject.GetComponent <Done_DropPowerup>().Drop();
         }
         Destroy(gameObject);
     }
     else
     {
         doubleLife = false;
         SetStandard();
     }
 }
    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);
    }
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary" || other.tag == "Enemy" || other.tag == "Upgrade" || other.tag == "Boss")
        {
            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);
        if (!(gameObject.tag == "Boss"))
        {
            Destroy(gameObject);
        }
    }
    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);
    }
    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);
    }
Esempio n. 16
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary" || other.tag == "Enemy" || other.tag == "PowerUp" || other.tag == "Hole")
        {
            return;
        }

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

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

        gameController.AddScore(scoreValue);

        Destroy(gameObject);
    }
Esempio n. 17
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);
    }
Esempio n. 18
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);
    }
    // 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);
    }
Esempio n. 20
0
 void OnMouseDown()
 {
     gameController.AddScore(scoreValue);
     if (explosion != null)
     {
         Instantiate(explosion, transform.position, transform.rotation);
     }
     Destroy(gameObject);
 }
    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);
    }
Esempio n. 22
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary" || other.tag == "Enemy")
        {
            return;
        }

        if (other.tag == "Shot")
        {
            var mover = other.gameObject.GetComponent <Done_Mover>();
            if (health <= gameController.GetPlayerStrength(mover.PlayerNetId))
            {
                gameController.AddScore(mover.PlayerNetId, scoreValue);
                gameController.LogDestructionEvent(tag, other.transform.position);
                health = 0;
            }
            else
            {
                health--;
            }
        }

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

        if (other.tag == "Player")
        {
            var boom = Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            NetworkServer.Spawn(boom);

            var player = other.gameObject.GetComponent <Done_PlayerController>();
            gameController.DamagePlayer(player.netId);
            health = 0;

            if (gameController.GetPlayerStrength(player.netId) <= 0)
            {
                Destroy(other.gameObject);
                gameController.CheckGameOver();
            }
        }
        else
        {
            Destroy(other.gameObject);
        }

        if (health <= 0)
        {
            Destroy(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);
    }
Esempio n. 24
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" || other.tag == "Enemy")
        {
            return;
        }

        if (!gameController.isMatch(name))
        {
            gameController.showWrongCard(name, gameObject);

            Instantiate(wrongCardExplosion, transform.position, transform.rotation);
            gameController.AddScore(-1);
            if (other.tag != "Player")
            {
                Destroy(other.gameObject);
            }
            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(10);
        gameController.newCard();
        Destroy(other.gameObject);
        Destroy(gameObject);
    }
Esempio n. 26
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 AsteroidDestroid()
    {
        //crear la moneda, añadir el score y mostrarlo por pantalla
        Instantiate(coin, transform.position, transform.rotation);
        scoreText.GetComponent <TextMesh>().text = "+" + scoreValue;
        Instantiate(scoreText, transform.position, scoreText.transform.rotation);

        if (gameController.missionLevel == false)
        {
            gameController.AddScore(scoreValue);
        }
        else
        {
            gameController.AddScoreMision();
        }

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



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

            gameController.AddScore(scoreValue);
        }


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

        if (divisible)
        {
            print("ok");
            Vector3 spawnPosition = new Vector3(transform.position.x - 1, transform.position.y, transform.position.z - 1);
            Instantiate(smaller, spawnPosition, Quaternion.identity);
            spawnPosition = new Vector3(transform.position.x + 1, transform.position.y, transform.position.z - 1);
            Instantiate(smaller, spawnPosition, Quaternion.identity);
            spawnPosition = new Vector3(transform.position.x, transform.position.y, transform.position.z + 1);
            Instantiate(smaller, spawnPosition, Quaternion.identity);
            Destroy(other.gameObject);
        }

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

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

        gameController.AddScore(scoreValue);
        Destroy(other.gameObject);
        Destroy(gameObject);
    }
Esempio n. 30
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);
    }