protected override void FixedUpdate() { if (Target == null || !Target.gameObject.activeSelf || Target.CurHealth <= 0) { DeleteObjectSystem.AddDeleteObject(gameObject); } base.FixedUpdate(); }
public override void DamageReceive(float statDamage, FieldObject receiveObject) #region Function Content { for (int i = 0; i < 4; ++i) { if (_status._abilities[i] == null) { continue; } Ability[i].Beaten(_curTarget); } //데미지를 받습니다. float damage = Mathf.Max(statDamage - (_status._defensivePower - receiveObject.DefensiveCleavage), 0); UnitController uc = receiveObject.GetComponent <UnitController>(); if (uc != null) { for (int i = 0; i < 4; ++i) { if (uc.Ability[i] == null) { continue; } uc.Ability[i].Hit(ref damage); } } CurHealth -= damage; _healthBarImage.fillAmount = RemainHealth; //체력이 0 초과라면 : 아래 코드 구문 실행 x if (CurHealth > 0) { return; } //사망 처리 한다. _isDead = true; _healthBarObject.SetActive(false); gameObject.transform.position = Vector3.zero; //해당 유닛과 체력바를 삭제 목록에 올립니다. DeleteObjectSystem.AddDeleteObject(gameObject, true); }
protected override void OnTriggerEnter(Collider other) { base.OnTriggerEnter(other); if (other.isTrigger) { return; } FieldObject obj = other.GetComponent <FieldObject>(); if (obj == null || Target != obj) { return; } if (obj.CurHealth <= 0) { ParentTower.UpdateTarget(); } DeleteObjectSystem.AddDeleteObject(gameObject); }