1 using Microsoft.Xna.Framework;
7 partial class DestructibleLevelWall : LevelWall, IDamageable
19 partial
void AddDamageProjSpecific(
float damage, Vector2 worldPosition)
21 if (damage <= 0.0f) {
return; }
22 Vector2 particlePos = worldPosition;
24 if (particleDir.LengthSquared() > 0.0001f) { particleDir = Vector2.Normalize(particleDir); }
25 if (!
Cells.Any(c => c.IsPointInside(particlePos)))
27 bool intersectionFound =
false;
28 foreach (var cell
in Cells)
30 foreach (var edge
in cell.Edges)
32 if (MathUtils.GetLineSegmentIntersection(worldPosition, cell.Center, edge.Point1 + cell.Translation, edge.Point2 + cell.Translation, out Vector2 intersection))
34 intersectionFound =
true;
35 particlePos = intersection;
36 particleDir = edge.GetNormal(cell);
40 if (intersectionFound) {
break; }
44 int particleAmount = MathHelper.Clamp((
int)damage, 1, 10);
45 for (
int i = 0; i < particleAmount; i++)
47 var particle = GameMain.ParticleManager.CreateParticle(
"iceexplosionsmall",
48 particlePos + Rand.Vector(5.0f),
49 particleDir * Rand.Range(30.0f, 500.0f) + Rand.Vector(20.0f));
50 GameMain.ParticleManager.CreateParticle(
"iceshards",
51 particlePos + Rand.Vector(5.0f),
52 particleDir * Rand.Range(100.0f, 500.0f) + Rand.Vector(100.0f));
void SetDamage(float damage)
List< VoronoiCell > Cells