Exemple #1
0
    private void OnTriggerEnter(Collider other)
    {
        Debug.Log(other.tag);
        if (other.tag == "Enemy")
        {
            enemyObject = other.GetComponent <HealthTracker>();
            enemyObject.ReduceHealth(_damage);
        }

        if (other.tag == "Amulet")
        {
            Debug.Log("Found amulet");
            //amulet = other.GetComponent<AmuletBoss>();
            //amulet.TakeDamage(_damage);
        }
    }
Exemple #2
0
 // Update is called once per frame
 void Update()
 {
     if (!_isAttacking)
     {
         _cooldown += Time.deltaTime;
         if (Vector3.Distance(transform.position, _playerTransform.position)
             <= AttackDistance && _cooldown > AttackCooldown)
         {
             _playerTracker.isStopped = true;
             _isAttacking             = true;
             _attackTimer             = 0.0f;
             _animator.SetBool("Slashing", true);
             _hit = false;
         }
     }
     else
     {
         _attackTimer += Time.deltaTime;
         if (_attackTimer >= AttackDuration ||
             Vector3.Distance(_playerTransform.position, transform.position)
             >= 2 * AttackDistance)
         {
             _playerTracker.isStopped = false;
             _isAttacking             = false;
             _animator.SetBool("Slashing", false);
             _cooldown = 0.0f;
         }
         if (!_hit && _attackTimer > AttackDuration / 1.5)
         {
             if (_meleeCollider.bounds.Intersects(_playerCollider.bounds))
             {
                 _playerHealth.ReduceHealth(30);
             }
             _hit = true;
         }
     }
 }