protected virtual void OnTriggerEnter2D(Collider2D other) { GameObject go = other.gameObject; if (noHit != (noHit | (1 << go.layer))) { /*if(go.layer == 15) * { * Debug.Log("Ricoche dans trigger"); * return; * }*/ //if (statAttaque.ePower == 0 || statAttaque.eRadius == 0) { if (dommageHit == (dommageHit | (1 << go.gameObject.layer))) { Personnages en = go.GetComponent <Personnages>() as Personnages; en.DommagePerso(dmg); } //}else if if (myTransform != null) { Collider2D[] colliders = Physics2D.OverlapCircleAll(myTransform.position, statAttaque.eRadius, dommageHit); foreach (Collider2D nerbyObject in colliders) { if (dommageHit == (dommageHit | (1 << nerbyObject.gameObject.layer))) { if (Rigidbody2DExt.AddExplosionForce(nerbyObject.GetComponent <Rigidbody2D>(), statAttaque.ePower, myTransform.position, statAttaque.eRadius, statAttaque.upwardsModifier)) { // if (nerbyObject == other) // continue; Personnages en = nerbyObject.GetComponent <Personnages>() as Personnages; en.DommagePerso(dmg); } } } if (effetExplosion != null && statAttaque.eRadius != 0) { Transform clone = Instantiate(effetExplosion, myTransform.position, myTransform.rotation) as Transform; ShockWaveForce wave = clone.GetComponent <ShockWaveForce>(); wave.radius = statAttaque.eRadius * 1.3f; Destroy(clone.gameObject, 1f); } } if (effetContact != null && myTransform != null) { Transform clone = Instantiate(effetContact, myTransform.position, myTransform.rotation) as Transform; Destroy(clone.gameObject, 1f); } Destroy(gameObject); } }
public void Explosion(int dmg, PlayerCharacter2D pl, float fireRate) { if (CanAttack) { if (effetAttaquePrefab != null) { Transform clone = Instantiate(effetAttaquePrefab, firePoint.position, firePoint.rotation) as Transform; ShockWaveForce wave = clone.GetComponent <ShockWaveForce>(); wave.radius = statAttaque.eRadius * 1.3f; Destroy(clone.gameObject, 1f); } attaqueCooldown = fireRate; if (Rigidbody2DExt.AddExplosionForce(pl.GetComponent <Rigidbody2D>(), statAttaque.ePower, firePoint.position, statAttaque.eRadius, statAttaque.upwardsModifier)) { pl.DommagePerso(dmg); } } }