private void OnTriggerEnter(Collider other) { if (other.tag == "Bullet") { //普通射击 if (other.name.Contains("BlueLaserProjectile")) { GameObject hitObj = pool.CreateObject("BulletHitPool_0", transform.position, Quaternion.identity); pool.MyDestory(hitObj, 0.3f); other.gameObject.SetActive(false); } //特殊攻击 else if (other.name.Contains("BlueRingProjectile")) { GameObject hitObj = pool.CreateObject("BulletHitPool_1", transform.position, Quaternion.identity); pool.MyDestory(hitObj, 0.3f); other.gameObject.SetActive(false); } else if (other.name.Contains("BaseStrikeEffect")) { GameObject hitObj = pool.CreateObject("SwordHitPool_1", transform.position, Quaternion.identity); pool.MyDestory(hitObj, 0.3f); } else if (other.name.Contains("RedLaserBoltImpact")) { GameObject hitObj = pool.CreateObject("SwordHitPool_0", transform.position, Quaternion.identity); pool.MyDestory(hitObj, 0.3f); } else if (other.name.Contains("Slash04")) { GameObject hitObj = pool.CreateObject("RoundHitPool", transform.position, Quaternion.identity); pool.MyDestory(hitObj, 0.3f); } //敌人受伤 OnDamage(player.attack); } }
private void OnTriggerEnter(Collider other) { if (other.tag == "Building" && transform.name.Contains("BlueLaserProjectile")) { GameObject hitObj = pool.CreateObject("BulletHitPool_0", transform.position, Quaternion.identity); pool.MyDestory(hitObj, 0.3f); gameObject.SetActive(false); } if (other.tag == "Player" && transform.name.Contains("ShockwaveProjectile")) { float attackValue = GameObject.FindGameObjectWithTag("Enemy").GetComponent <EnemyState>().attack; other.GetComponent <PlayerState>().OnDamage(attackValue); } }
public IEnumerator SlashDely() { yield return(new WaitForSeconds(0.3f)); GameObject slash = pool.CreateObject("SlashPool", transform.position + new Vector3(-0.5f, 1, 1.5f), transform.rotation); pool.MyDestory(slash, 0.4f); }