public void OnDamage(int damage, IAttackAble by) { this.hp -= damage; if (this.hp <= 0) { Dead(); } else { if (!this.damageEffecting) { StartCoroutine(this.DamagedEffectPocess()); } } }
void OnTriggerEnter2D(Collider2D other) { TileMapObject objUnit = other.GetComponent <TileMapObject>(); if (objUnit) { IDamageAble damageAbleObj = objUnit.GetComponentInParent <IDamageAble>(); if (damageAbleObj != null) { IAttackAble attackAble = actor as IAttackAble; if (damageAbleObj != null && attackAble != null) { damageAbleObj.OnDamage(attackAble.AttackPower, attackAble); } StopMove(); } if (!this.warpping) { Portal portal = objUnit.GetComponentInParent <Portal>(); if (portal) { EnterPortal(portal); } } if (!this.warpping) { EnterToOtherMap[] enterToOtherMapList = objUnit.GetComponentsInParent <EnterToOtherMap>(); if (enterToOtherMapList != null && enterToOtherMapList.Length > 0) { EnterToOtherMap enterToOtherMap = enterToOtherMapList[0]; enterToOtherMap.EnterBy(this.actor); } } } }