private void OnCollisionEnter2D(Collision2D collision) { Destroy(gameObject); if (collision.gameObject.tag == "Unit") { UnitStatus status = collision.gameObject.GetComponent <UnitStatus>(); if (status != null && unitStatus != null) { audio.Play(); status.AddDamage(unitStatus.unitPower); damage.enabled = true; StartCoroutine("Span"); } } }
IEnumerator HealCheck() { for (int i = 0; i < 20; i++) { if (healunit[i] != null) { //回復処理 UnitStatus unitStatus = healunit[i].GetComponent <UnitStatus>(); UnitStatus magicunitStatus = gameObject.GetComponent <UnitStatus>(); audios[1].Play(); unitStatus.AddDamage(-magicunitStatus.unitHealingpower); } } yield return(new WaitForSeconds(waittime)); reHeal(); }
private void OnTriggerStay2D(Collider2D collision) { AttackRange attckRange = collision.gameObject.GetComponent <AttackRange>(); if (attckRange != null && candamage == true) { UnitStatus ustatus = collision.gameObject.GetComponent <UnitStatus>(); if (ustatus.unitCheck != unitStatus.unitCheck) { candamage = false; ustatus.AddDamage(unitStatus.unitPower); StartCoroutine("Span"); } } UnitStatus status = GetComponent <UnitStatus>(); if (status != null) { if (collision.gameObject.tag == "Base" && candamage == true && status.unitCheck == false) { candamage = false; BaseStatus baseStatus = collision.gameObject.GetComponent <BaseStatus>(); if (baseStatus != null) { baseStatus.damage(unitStatus.unitPower); StartCoroutine("Span"); } } /* * else if (collision.gameObject.name == "EnemyBase" && candamage == true && status.unitCheck == true) * { * candamage = false; * BaseStatus baseStatus = collision.gameObject.GetComponent<BaseStatus>(); * baseStatus.damage(unitStatus.unitPower); * StartCoroutine("Span"); * } */ } }