public void Damage(int damageAmount) { for (int i = hpList.Count - 1; i >= 0; i--) { HP hp = hpList[i]; if (damageAmount > hp.GetFragmentAmount()) { damageAmount -= hp.GetFragmentAmount(); hp.Damage(hp.GetFragmentAmount()); } else { hp.Damage(damageAmount); break; } } if (OnDamaged != null) { OnDamaged(this, EventArgs.Empty); } if (IsDead()) { if (OnDead != null) { OnDead(this, EventArgs.Empty); } } }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.name == "Axe") { hp.Damage(10); } }
//checks collision private void OnTriggerEnter(Collider other) { HP Temp = other.GetComponent <HP>(); if (Temp != null) { Temp.Damage(SpikeDamage); } }
void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Shell") { hp.Damage(damage); Destroy(other.gameObject); } }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.CompareTag("Enemy")) { HP v = collision.gameObject.GetComponent <HP>(); v.Damage(damage); } Destroy(gameObject); }
void OnTriggerEnter(Collider other) { Debug.Log("OnTriggerEnter : " + other.gameObject.tag); if (other.gameObject.CompareTag("bulletPrefab")) { hp.Damage(damage); Destroy(other.gameObject); } }
void OnTriggerEnter(Collider other) { if (other.CompareTag("shell")) { //HPクラスのダメージ関数を呼び出してダメージを与える hp.Damage(damage); Destroy(other.gameObject); } }