public void Detonate() { Active = false; World.AddEffect(new ExplosionSource(World, Position, 6)); foreach (var offset in Main.GetWithin(grenadeType.explosionRadius)) { var pos = Position + offset; var displacement = pos - Position; var dist2 = displacement.Magnitude2; var radius2 = grenadeType.explosionRadius * grenadeType.explosionRadius; if (dist2 > radius2) { continue; } foreach (var hit in World.entities[pos]) { if (hit is ICharacter d && hit != this) { var multiplier = (radius2 - displacement.Magnitude2) / radius2; ExplosionDamage damage = new ExplosionDamage() { damage = (int)(grenadeType.explosionDamage * multiplier), knockback = displacement.Normal * grenadeType.explosionForce * multiplier }; Source.Witness(new InfoEvent(Name + new ColoredString(" explosion damages ", Color.White, Color.Black) + d.Name)); d.OnDamaged(damage); } } } }
public void Detonate() { item.Destroy(); item.World.AddEffect(new ExplosionSource(item.World, item.Position, 6)); foreach (var offset in Main.GetWithin(type.explosionRadius)) { var pos = item.Position + offset; var displacement = pos - item.Position; var dist2 = displacement.Magnitude2; var radius2 = type.explosionRadius * type.explosionRadius; if (dist2 > radius2) { continue; } foreach (var hit in item.World.entities[pos]) { if (hit is ICharacter d && hit != item) { var multiplier = (radius2 - displacement.Magnitude2) / radius2; ExplosionDamage damage = new ExplosionDamage() { damage = (int)(type.explosionDamage * multiplier), knockback = displacement.Normal * type.explosionForce * multiplier }; d.OnDamaged(damage); } } } }
public void applyExplosion(ExplosionDamage explosionDamage, Vector3 offset) { addToDamageStack(explosionDamage); float proximity = offset.magnitude; Vector3 force = offset.normalized * (explosionDamage.getRawDamage() / (proximity * explosionResistance)); body.AddForce(force, ForceMode.Impulse); }
public override float calcExplosionDamage(ExplosionDamage token) { base.calcExplosionDamage(token); float damage = token.Damage; switch (token.Level) { case FieldActionController.ExplisionLevel.ONE: break; case FieldActionController.ExplisionLevel.TWO: damage = Parameter.CurrentHP * 0.5f; break; case FieldActionController.ExplisionLevel.THREE: return ExplosionDamage.INSTANTDEATH; } damage = (damage * ParameterOffset.ResistExplosion); damage = Mathf.Max(1, damage); return damage; }
protected void Explode(Collider coll) { if (coll.CompareTag("Enemy")) { EnemyController enemy = coll.GetComponent<EnemyController>(); Vector3 offset = enemy.transform.position - transform.position; float proximity = offset.magnitude; float damageMultiplier = 2 - (proximity / explosionRadius); ExplosionDamage explosiveDamage = new ExplosionDamage(damageMultiplier * damage.getRawDamage(), duration, DamageTypes.Fire); enemy.applyExplosion(explosiveDamage, offset); enemy.applyStatus(status); } }
private void Awake() { transform = GetComponent <Transform>(); missile = GetComponent <AAMissile>(); explosionDamage = GetComponent <ExplosionDamage>(); if (fireClip != null) { fireSource = gameObject.AddComponent <AudioSource>(); fireSource.clip = fireClip; fireSource.minDistance = fireMinDistance; fireSource.maxDistance = fireMaxDistance; fireSource.loop = false; fireSource.dopplerLevel = 0.0f; fireSource.spatialBlend = 1.0f; fireSource.volume = fireVolume; fireSource.pitch = Random.Range(0.9f, 1.3f); fireSource.outputAudioMixerGroup = mixerGroup ?? null; fireSource.Stop(); } if (loopClip != null) { loopSource = gameObject.AddComponent <AudioSource>(); loopSource.clip = loopClip; loopSource.minDistance = loopMinDistance; loopSource.maxDistance = loopMaxDistance; loopSource.loop = true; loopSource.dopplerLevel = 1.0f; loopSource.volume = loopVolume; loopSource.spatialBlend = 1.0f; loopSource.outputAudioMixerGroup = mixerGroup ?? null; loopSource.Stop(); } }
public virtual float calcExplosionDamage(ExplosionDamage token) { return 0; }
public override float calcExplosionDamage(ExplosionDamage token) { base.calcExplosionDamage(token); float damage = 0; switch (token.Level) { case FieldActionController.ExplisionLevel.ONE: break; case FieldActionController.ExplisionLevel.TWO: damage =Parameter.CurrentHP * 0.5f; break; case FieldActionController.ExplisionLevel.THREE: damage = Parameter.CurrentHP * 0.9f; damage = Mathf.Max(1, damage); break; } damage = (damage * ParameterOffset.ResistExplosion); damage = Mathf.Max(1, damage); /* if (attacker != null) { damagedFromCharacterAttack(damage, attacker); } else { GameController.SoundController.playSE(SoundNameList.Character_Damage); GameController.PlayingLogger.damaged(Parameter.Name, damage, isDead); Parameter.CurrentHP -= damage; } isDead = Parameter.CurrentHP <= 0; if (isDead) callDead(new Explosion(this)); */ return damage; }
private void Start() { explosionDamage = GetComponent <ExplosionDamage>(); }