private void Attack() { int enemyNum = EnemyCtrs.Count; if (enemyNum > 0) { for (int i = 0; i < EnemyCtrs.Count; i++) { PlayerCtr item = EnemyCtrs[i]; if (item.HP > 0) { item.TakeDamage(ATK); } if (item.HP <= 0) { EnemyCtrs.Remove(item); } } } else { StopAttack(); Ctr.MoveInstance.PauseMove(false); } }
private void OnCollisionEnter(Collision collision) { Transform tr = collision.transform; PlayerCtr pc = tr.GetComponentInParent <PlayerCtr>(); if (pc != null) { Direction dir = Utils.GetDirection(transform, tr); Debug.Log(transform.parent.name + "===" + dir.ToString()); Ctr.MoveInstance.PauseMove(true); EnemyCtrs.Add(pc); if (!InWar) { InvokeRepeating("Attack", 0f, 1f); } } }
public void Init() { EnemyCtrs.Clear(); InWar = false; }