예제 #1
0
 // Start is called before the first frame update
 public void Enter(Enemy enemy)
 {
     deathTime    = Time.time;
     hpBar        = enemy.GetComponent <EnemyHitPoint>();
     dropableItem = enemy.GetComponent <ItemDropEvent>();
     if (dropableItem)
     {
         dropableItem.DropItem();
     }
 }
예제 #2
0
    public void DealDamage()
    {
        foreach (GameObject enemy in GameObject.FindGameObjectsWithTag("Enemy"))
        {
            if (IsTargetInAttackRange(enemy.transform) && !attackedEnemy.Contains(enemy.transform))
            {
                attackedEnemy.Add(enemy.transform);
                visualScript.HitFX(Random.Range(0, 2), enemy.transform.position + Vector3.up);

                EnemyHitPoint enemyScript = enemy.GetComponent <EnemyHitPoint>();
                if (enemyScript != null)
                {
                    enemyScript.TakeDamage(attackBaseDamage);
                }
                else
                {
                    Debug.LogWarning("Enemy Properties script not found in attacked enemy. this enemy won't take damage and show hp bar.");
                }
            }
        }
    }