Beispiel #1
0
    private void OnTriggerStay(Collider other)
    {
        if (other.tag == "PlayerBody")
        {
            if (damageTimer <= 0)
            {
                state = State.Combat;
                if (Vector3.Distance(player.transform.position, transform.position) < 2)
                {
                    Player_Controller player = other.GetComponentInParent <Player_Controller>();
                    player.Damage();
                }
                damageTimer = 1;
            }
            else
            {
                damageTimer -= Time.deltaTime;
            }
        }

        if (other.tag == "ShockWave")
        {
            state = State.Combat;
        }
    }
Beispiel #2
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player")
        {
            Player_Controller player = other.GetComponent <Player_Controller>();
            if (player != null)
            {
                player.Damage();
            }
            AudioSource.PlayClipAtPoint(_audioClipPlayerHit, transform.position);
            GameObject Effect = Instantiate(_particleEffect, transform.position, Quaternion.identity);
            Destroy(Effect, 0.5f);
            Destroy(this.gameObject);
        }

        if (other.tag == "Bullet")
        {
            other.gameObject.SetActive(false);
            if (_player != null)
            {
                _player.AddScore(10);
            }
            AudioSource.PlayClipAtPoint(_audioClipExplosion, transform.position);
            GameObject Effect = Instantiate(_particleEffect, transform.position, Quaternion.identity);
            Destroy(Effect, 0.5f);
            Destroy(GetComponent <Collider2D>());
            Destroy(this.gameObject);
        }
    }
Beispiel #3
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Player" && _IsEnemyLaser == true)
     {
         Player_Controller _PlayerController = other.GetComponent <Player_Controller>();
         if (_PlayerController != null)
         {
             _PlayerController.Damage();
         }
         Destroy(this.gameObject);
     }
 }
Beispiel #4
0
    //collision with the laser
    public void OnTriggerEnter2D(Collider2D other)
    {
        //tag check for Laser
        if (other.tag == "Laser")
        {
            //access the laser
            Laser laser = other.GetComponent <Laser>();

            //nullcheck
            if (laser != null)
            {
                //destroy the laser
                Destroy(laser.gameObject);
            }

            //enemy explosion animation
            Instantiate(_enemyExplosion, transform.position, Quaternion.identity);

            //update the score and destroy enemy with an explosion
            //AudioSource.PlayClipAtPoint(_explosionSound, transform.position);
            _UImanager.UpdateScore();
            Destroy(this.gameObject);
        }

        //tag check for Player
        if (other.tag == "Player")
        {
            //access the player
            Player_Controller player = other.GetComponent <Player_Controller>();

            //nullcheck
            if (player != null)
            {
                player.Damage();
            }

            //enemy explosion animation
            Instantiate(_enemyExplosion, transform.position, Quaternion.identity);


            //update the score and destroy the enemy with an explosion
            _UImanager.UpdateScore();
            Destroy(this.gameObject);
        }
    }
Beispiel #5
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player")
        {
            _EnemyExplotion.Play();

            Player_Controller playerCon = other.transform.GetComponent <Player_Controller>();

            if (playerCon != null)
            {
                playerCon.Damage();
            }
            _EnemyDestroy.SetTrigger("OnEnemyDead");
            _speedEnemy = 0.0f;
            Destroy(GetComponent <Collider2D>());
            Destroy(this.gameObject, 2.8f);
        }

        //If other is laser
        //destroy laser
        //destroy us
        if (other.tag == "Laser")
        {
            _EnemyExplotion.Play();

            Destroy(other.gameObject);
            if (playerController != null)
            {
                playerController.AddPointsToScore();
            }
            _EnemyDestroy.SetTrigger("OnEnemyDead");
            _speedEnemy = 0.0f;
            Destroy(GetComponent <Collider2D>()); //Add a time to destroy de Collider to destroy all missiles that impact
            Destroy(this.gameObject, 2.8f);
        }
    }