Ejemplo n.º 1
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "LaserPlayer")
        {
            Destroy(other.gameObject);

            if (_playerScript != null)
            {
                _playerScript.AddScore(40);
            }

            _audioSource.Play();
            DestroyEnemyBossShip();
        }

        if (other.tag == "PlayerHomingMissile")
        {
            if (_playerScript != null)
            {
                _playerScript.AddScore(10);
            }

            Destroy(other.gameObject);

            _audioSource.Play();
            DestroyEnemyBossShip();
        }
    }
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player")
        {
            PlayerScript player = other.transform.GetComponent <PlayerScript>();

            if (player != null)
            {
                player.Damage();
            }
            _player.PlayClip(_explosionSoundEffect);
            DestroyEnemyMine();
        }

        if (other.tag == "LaserPlayer")
        {
            Destroy(other.gameObject);
            _player.AddScore(5);
            _player.PlayClip(_explosionSoundEffect);
            DestroyEnemyMine();
        }

        if (other.tag == "PlayerHomingMissile")
        {
            if (_player != null)
            {
                _player.AddScore(10);
            }

            Destroy(other.gameObject);
            _player.PlayClip(_explosionSoundEffect);
            DestroyEnemyMine();
        }
    }
Ejemplo n.º 3
0
 public void takeDamage(float damage, PlayerScript ps)
 {
     life -= damage;
     if (life <= 0)
     {
         ps.AddScore(score);
         ps.AddKill();
         die();
     }
 }
Ejemplo n.º 4
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player")
        {
            PlayerScript player = other.transform.GetComponent <PlayerScript>();

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

            //           _audioSource.Play();
            DestroyEnemyShip();
        }

        if (other.tag == "LaserPlayer")
        {
            Destroy(other.gameObject);

            if (_player != null)
            {
                _player.AddScore(15); // calls the AddScore() method in the PlayerScript to add 15 points to the score
                                      // the value of 15 is set to this type of enemy, but we could expand later with a
                                      // Switch statement to attribute different values to "points"
            }

            //           _audioSource.Play();
            DestroyEnemyShip();
        }

        if (other.tag == "PlayerHomingMissile")
        {
            if (_player != null)
            {
                _player.AddScore(10);
            }

            Destroy(other.gameObject);

            _audioSource.Play();
            DestroyEnemyShip();
        }
    }
Ejemplo n.º 5
0
 public void Kill()
 {
     if (Opponent)
     {
         Opponent.AddScore();
     }
     Opponent               = null;
     transform.position     = startPosition;
     transform.rotation     = Quaternion.identity;
     spriteRenderer.enabled = true;
 }
Ejemplo n.º 6
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "Bubble")
     {
         GameObject   player       = GameObject.Find("Player");
         PlayerScript playerScript = player.GetComponent <PlayerScript>();
         playerScript.AddScore();
         Instantiate(sound);
         Destroy(gameObject);
     }
 }
Ejemplo n.º 7
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player")
        {
            PlayerScript player = other.transform.GetComponent <PlayerScript>();

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

            _audioSource.Play();
            Enemy6Damage();
        }

        if (other.tag == "LaserPlayer")
        {
            Destroy(other.gameObject);

            if (_player != null)
            {
                _player.AddScore(60);
            }

            _audioSource.Play();
            Enemy6Damage();
        }

        if (other.tag == "PlayerHomingMissile")
        {
            if (_player != null)
            {
                _player.AddScore(60);
            }

            Destroy(other.gameObject);

            _audioSource.Play();
            Enemy6Damage();
        }
    }
Ejemplo n.º 8
0
 private void Death()
 {
     if (explosion != null)
     {
         Instantiate(explosion, transform.position, transform.rotation);
     }
     if (tag == "Asteroid")
     {
         player.AddScore(scoreValue);
     }
     isDead = true;
     if (tag == "Player")
     {
         FindObjectOfType <GameManager>().EndGame();
     }
     Destroy(gameObject);
 }