using System.Collections; using System.Collections.Generic; using UnityEngine; public class WeaponHitbox : MonoBehaviour { private BoxCollider2D col; private WeaponStat _stat; private string atktype; //À̹ø °ø°Ý¿¡¼­ ÀÌ¹Ì ¶§¸° ÀûµéÀÇ ID¸¦ ÀúÀåÇÏ´Â ¸®½ºÆ® private HashSet hitEnemies = new HashSet(); private PlayerController playerController; public float sGageAmount = 20; public float aGageAmount = 30; void Awake() { playerController = GetComponentInParent(); col = GetComponent(); gameObject.SetActive(false); } private void OnEnable() { hitEnemies.Clear(); } public void Setup(WeaponStat stat, string atkType) { _stat = stat; if (atkType == "SAtk") // ¾à°ø°Ý { col.size = stat.data.sboxSize; col.offset = stat.data.sboxOffset; } else if (atkType == "AAtk") // °­°ø°Ý { col.size = stat.data.aboxSize; col.offset = stat.data.aboxOffset; } atktype = atkType; } private void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Enemy")) { int enemyID = other.gameObject.GetInstanceID(); if (hitEnemies.Contains(enemyID)) return; hitEnemies.Add(enemyID); Mob enemy = other.GetComponent(); if (enemy != null && atktype == "SAtk") { playerController.ChargeTagGauge(sGageAmount); enemy.TakeDamage(_stat.data.sDamage, _stat.data.hitStunTime, transform.position); } else if (enemy != null && atktype == "AAtk") { playerController.ChargeTagGauge(aGageAmount); enemy.TakeDamage(_stat.data.aDamage, _stat.data.hitStunTime, transform.position); } } } }