public static bool ApplyDamage(GameObject src, float amount, DamageType type = DamageType.Normal) { StatusComponent status = src.GetComponent <StatusComponent>(); if (status) { status.TakeDamage(amount, type); return(true); } else { // Debug.LogWarning("Source GameObj has no Status Component. Can't apply damage to him"); return(false); } }
public override void OnTick(GameObject obj) { if (m_OnHitEffect) { GameObject fx = MonoBehaviour.Instantiate(m_OnHitEffect); fx.transform.position = obj.transform.position + new Vector3(0, 0, -15); Vector3 pos = fx.transform.position; Collider2D[] overlaps = Physics2D.OverlapCircleAll(pos, 2.0f); foreach (Collider2D overlap in overlaps) { if (overlap.gameObject.CompareTag("Enemy")) { StatusComponent st = overlap.GetComponent <StatusComponent>(); if (st) { st.TakeDamage(m_Damage); } } } } }