Esempio n. 1
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Enemy")
        {
            if (other.GetComponent <EnemyHealthScript>() != null)
            {
                Debug.Log("Trigger ---> Enemy hit by launcher");
                EnemyHealthScript enemy = other.GetComponent <EnemyHealthScript>();

                if (enemy.gameObject.name.Contains("left"))
                {
                    if (enemy.currentHealth > 0)
                    {
                        MoveUpwards.killConfirmed = true;
                        Shoot.missedShotsAttemps  = 0;
                        Shoot.missedLeftShots     = 0;
                        Shoot.LeftShotHit         = true;
                        Shoot.LeftEnemyCount     += 1;
                        enemy.ApplyDamage(enemy.maxHealth);
                    }
                }
                else if (enemy.gameObject.name.Contains("right"))
                {
                    if (enemy.currentHealth > 0)
                    {
                        MoveUpwards.killConfirmed = true;
                        Shoot.missedShotsAttemps  = 0;
                        Shoot.missedRightShots    = 0;
                        Shoot.RightShotHit        = true;
                        Shoot.RightEnemyCount    += 1;
                        enemy.ApplyDamage(enemy.maxHealth);
                    }
                }
            }
        }
    }
Esempio n. 2
0
    //void Update()
    //{
    //    if (takeDamage)
    //    {


    //        takeDamage = false;
    //    }
    //}

    void OnTriggerEnter(Collider other)
    {
        //Debug.Log("Boom");

        //take damage
        health_enemy = other.GetComponent <EnemyHealthScript>();
        //disable enemyAttck
        other.GetComponent <EnemyAttck>().enabled = false;

        //take damage to player
        health_player.TakeDamage(1, 1);
        //take damage to enemy
        if (health_enemy != null)
        {
            health_enemy.ApplyDamage(100);
        }

        Instantiate(explosion, player.transform.position, Quaternion.identity);
        CameraShaker.Instance.ShakeOnce(1f, 1f, .05f, 1.2f);
    }