void OnTriggerEnter2D(Collider2D hitInfo) { Enemy2D enemy = hitInfo.GetComponent <Enemy2D>(); Cherry cherry = hitInfo.GetComponent <Cherry>(); if (enemy != null) { enemy.TakeDamage(damage); } if (cherry) { cherry.Remove(); } Destroy(gameObject); }
public IEnumerator BreakCor(Enemy2D enemy) { enemy.mover.StopMove(); enemy.isBusy = true; // направление enemy.mover.RotateTo(transform.position); yield return(new WaitForSeconds(HatchList.Instance.BreakTime)); if (enemy != null) { enemy.mover.RestoreMove(); enemy.isBusy = false; TakeDamage(); } }
private IEnumerator EnemyDeadCor(float time, Enemy2D enemy) { yield return(new WaitForSeconds(time)); enemy?.Dead(false); }