Example #1
0
 void DamagePlayer()
 {
     if (Time.time > _nextFire)
     {
         _nextFire = Time.time + fireRate;
         healthComponent.health -= 2;
         player.PlayerDamageBehaviour();
     }
 }
Example #2
0
    void DamagePlayer()
    {
        if (Time.time > _nextFire)
        {
            _nextFire = Time.time + fireRate;

            _healthComponent.health -= damage;
            _playerMain.PlayerDamageBehaviour();
        }
    }
Example #3
0
 // Update is called once per frame
 void Update()
 {
     if (_attackPlayer && _nextAttack < Time.time)
     {
         _nextAttack = Time.time + attackRate;
         if (!_healthComponent.invincible)
         {
             _healthComponent.health -= damage;
             _playerMain.PlayerDamageBehaviour();
         }
     }
 }
Example #4
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.collider.CompareTag("Player"))
        {
            _playerMain              = collision.collider.GetComponent <PlayerMain>();
            _healthComponent         = collision.collider.GetComponent <HealthComponent>();
            _healthComponent.health -= damage;
            _uiManager.UpdateHealth();
            _playerMain.PlayerDamageBehaviour();
        }

        if (collision.collider.CompareTag("Ground"))
        {
            Destroy(gameObject);
        }
    }
Example #5
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player") && projType == ProjectileType.Enemy)
        {
            if (!_playerMain.invulnerable)
            {
                _healthComponent         = collision.GetComponent <HealthComponent>();
                _healthComponent.health -= _damage;
                _playerMain.PlayerDamageBehaviour();
                Destroy(gameObject);
            }
        }

        if (collision.CompareTag("Enemy") && projType == ProjectileType.Player)
        {
            //Debug.Log("HitTarget");
            _healthComponent         = collision.GetComponent <HealthComponent>();
            _healthComponent.health -= _damage;
            //_enemyOnetest = collision.GetComponent<EnemyBasic>();
            //_enemyOnetest.DamageBehaviour();
            Destroy(gameObject);
        }

        if (collision.CompareTag("pProj") && projType == ProjectileType.Enemy)
        {
            Destroy(gameObject);
        }
        else if (collision.CompareTag("eProj") && projType == ProjectileType.Player)
        {
            Destroy(gameObject);
        }

        if (collision.CompareTag("Ground"))
        {
            Destroy(gameObject);
        }
        else
        {
            projectileLife--;
        }

        if (collision.CompareTag("Ground") && projType == ProjectileType.Enemy)
        {
            Destroy(gameObject);
        }

        if (collision.CompareTag("Shield") && projType == ProjectileType.Player)
        {
            Destroy(gameObject);
        }

        //if (collision.CompareTag("Player") && projType == ProjectileType.Enemy)
        //{
        //    Debug.Log("HitTarget");
        //    healthComponent = collision.GetComponent<HealthComponent>();
        //    healthComponent.health -= _damage;
        //    player.PlayerDamageBehaviour();
        //    Destroy(gameObject);
        //}


        //destroy if hits enemy projectile
    }