2026-02-02 12:41:06 +00:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
2026-01-30 09:58:52 +00:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
public class WeaponHitbox : MonoBehaviour
|
|
|
|
|
|
{
|
|
|
|
|
|
private BoxCollider2D col;
|
|
|
|
|
|
private WeaponStat _stat;
|
|
|
|
|
|
|
2026-02-02 12:41:06 +00:00
|
|
|
|
private string atktype;
|
|
|
|
|
|
|
|
|
|
|
|
//<2F>̹<EFBFBD> <20><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD> <20>̹<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ID<49><44> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20><><EFBFBD><EFBFBD>Ʈ
|
|
|
|
|
|
private HashSet<int> hitEnemies = new HashSet<int>();
|
|
|
|
|
|
|
2026-01-30 09:58:52 +00:00
|
|
|
|
void Awake()
|
|
|
|
|
|
{
|
|
|
|
|
|
col = GetComponent<BoxCollider2D>();
|
|
|
|
|
|
gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-02 12:41:06 +00:00
|
|
|
|
private void OnEnable()
|
|
|
|
|
|
{
|
|
|
|
|
|
hitEnemies.Clear();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-30 09:58:52 +00:00
|
|
|
|
public void Setup(WeaponStat stat, string atkType)
|
|
|
|
|
|
{
|
|
|
|
|
|
_stat = stat;
|
|
|
|
|
|
|
|
|
|
|
|
if (atkType == "SAtk") // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
{
|
|
|
|
|
|
col.size = stat.data.sboxSize;
|
|
|
|
|
|
col.offset = stat.data.sboxOffset;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (atkType == "AAtk") // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
{
|
|
|
|
|
|
col.size = stat.data.aboxSize;
|
|
|
|
|
|
col.offset = stat.data.aboxOffset;
|
|
|
|
|
|
}
|
2026-02-02 12:41:06 +00:00
|
|
|
|
atktype = atkType;
|
2026-01-30 09:58:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-02 12:41:06 +00:00
|
|
|
|
private void OnTriggerEnter2D(Collider2D other)
|
2026-01-30 09:58:52 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (other.CompareTag("Enemy"))
|
|
|
|
|
|
{
|
2026-02-02 12:41:06 +00:00
|
|
|
|
int enemyID = other.gameObject.GetInstanceID();
|
|
|
|
|
|
if (hitEnemies.Contains(enemyID)) return;
|
|
|
|
|
|
|
|
|
|
|
|
hitEnemies.Add(enemyID);
|
|
|
|
|
|
|
|
|
|
|
|
Mob enemy = other.GetComponent<Mob>();
|
|
|
|
|
|
|
|
|
|
|
|
if (enemy != null && atktype == "SAtk")
|
|
|
|
|
|
{
|
|
|
|
|
|
enemy.TakeDamage(_stat.data.sDamage, _stat.data.hitStunTime, transform.position);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
else if (enemy != null && atktype == "AAtk")
|
|
|
|
|
|
{
|
|
|
|
|
|
enemy.TakeDamage(_stat.data.aDamage, _stat.data.hitStunTime, transform.position);
|
|
|
|
|
|
}
|
2026-01-30 09:58:52 +00:00
|
|
|
|
}
|
2026-02-02 12:41:06 +00:00
|
|
|
|
}
|
2026-01-30 09:58:52 +00:00
|
|
|
|
}
|