public static void StartExplosion(Vector3Int WorldPOS, float strength, bool isEmp = false) { int Radius = (int)Math.Round(strength / (Math.PI * 75)); if (Radius > 150) { Radius = 150; } byte ShakingStrength = 25; if (strength > 800) { ShakingStrength = 75; } else if (strength > 8000) { ShakingStrength = 125; } else if (strength > 80000) { ShakingStrength = 255; } ExplosionUtils.PlaySoundAndShake(WorldPOS, ShakingStrength, Radius / 20, isEmp); //Generates the conference var explosionData = new ExplosionData(); circleBres(explosionData, WorldPOS.x, WorldPOS.y, Radius); float InitialStrength = strength / explosionData.CircleCircumference.Count; foreach (var ToPoint in explosionData.CircleCircumference) { var Line = ExplosionPropagationLine.Getline(); Line.SetUp(WorldPOS.x, WorldPOS.y, ToPoint.x, ToPoint.y, InitialStrength, isEmp); Line.Step(); } }
/// <summary> /// Plays explosion sound and shakes ground /// </summary> private void PlaySoundAndShake(Vector3Int explosionPosition) { byte shakeIntensity = (byte)Mathf.Clamp(damage / 5, byte.MinValue, byte.MaxValue); ExplosionUtils.PlaySoundAndShake(explosionPosition, shakeIntensity, (int)shakeDistance); }