Nicer looking explosions
This commit is contained in:
@@ -159,18 +159,21 @@
|
|||||||
</smoke>
|
</smoke>
|
||||||
|
|
||||||
<explosionfire
|
<explosionfire
|
||||||
startsizemin="1.0,1.0" startsizemax="1.5,1.5"
|
startsizemin="0.25,0.15" startsizemax="0.5,0.25"
|
||||||
sizechangemin="0.5,0.5" sizechangemax="0.6,0.6"
|
sizechangemin="0.2,0.2" sizechangemax="0.3,0.3"
|
||||||
startrotationmin ="0.0" startrotationmax="360"
|
startrotationmin ="-50.0" startrotationmax="50"
|
||||||
startcolor="1.0, 1.0, 1.0" startalpha="1.0"
|
startcolor="1.0, 1.0, 1.0" startalpha="1.0"
|
||||||
colorchange="-0.6, -0.6, -0.6, -0.5"
|
colorchange="-0.6, -0.6, -0.6, -0.5"
|
||||||
lifetime="5.0"
|
lifetime="5.0"
|
||||||
growtime ="0.05"
|
growtime ="0.05"
|
||||||
drawtarget="air"
|
drawtarget="air"
|
||||||
collideswithwalls="true"
|
collideswithwalls="true"
|
||||||
|
collisionradius="100"
|
||||||
blendstate="additive"
|
blendstate="additive"
|
||||||
velocitychange="0.0, 0.5">
|
velocitychange="0.0, 1.0"
|
||||||
<sprite texture="Content/Particles/explosion.png" sourcerect="0,0,128,128"/>
|
animduration="1.2"
|
||||||
|
loopanim="false">
|
||||||
|
<animatedsprite texture="Content/Particles/FlameRoundParticleSheet.png" sourcerect="0,0,2048,2048" columns="10" rows="5" origin="0.5,0.8"/>
|
||||||
</explosionfire>
|
</explosionfire>
|
||||||
|
|
||||||
<weld
|
<weld
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public float CameraShake;
|
public float CameraShake;
|
||||||
|
|
||||||
private bool sparks, shockwave, flames;
|
private bool sparks, shockwave, flames, smoke;
|
||||||
|
|
||||||
public Explosion(XElement element)
|
public Explosion(XElement element)
|
||||||
{
|
{
|
||||||
@@ -26,6 +26,7 @@ namespace Barotrauma
|
|||||||
sparks = ToolBox.GetAttributeBool(element, "sparks", true);
|
sparks = ToolBox.GetAttributeBool(element, "sparks", true);
|
||||||
shockwave = ToolBox.GetAttributeBool(element, "shockwave", true);
|
shockwave = ToolBox.GetAttributeBool(element, "shockwave", true);
|
||||||
flames = ToolBox.GetAttributeBool(element, "flames", true);
|
flames = ToolBox.GetAttributeBool(element, "flames", true);
|
||||||
|
smoke = ToolBox.GetAttributeBool(element, "smoke", true);
|
||||||
|
|
||||||
CameraShake = ToolBox.GetAttributeFloat(element, "camerashake", attack.Range*0.1f);
|
CameraShake = ToolBox.GetAttributeFloat(element, "camerashake", attack.Range*0.1f);
|
||||||
}
|
}
|
||||||
@@ -53,8 +54,13 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
if (flames)
|
if (flames)
|
||||||
{
|
{
|
||||||
GameMain.ParticleManager.CreateParticle("explosionfire", worldPosition + Rand.Vector(50f),
|
GameMain.ParticleManager.CreateParticle("explosionfire", ClampParticlePos(worldPosition + Rand.Vector(50f), hull),
|
||||||
Rand.Vector(Rand.Range(50f, 100.0f)), 0.0f, hull);
|
Rand.Vector(Rand.Range(50.0f, 100.0f)), 0.0f, hull);
|
||||||
|
}
|
||||||
|
if (smoke)
|
||||||
|
{
|
||||||
|
GameMain.ParticleManager.CreateParticle("smoke", ClampParticlePos(worldPosition + Rand.Vector(50f), hull),
|
||||||
|
Rand.Vector(Rand.Range(1.0f, 10.0f)), 0.0f, hull);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,9 +97,19 @@ namespace Barotrauma
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Vector2 ClampParticlePos(Vector2 particlePos, Hull hull)
|
||||||
|
{
|
||||||
|
if (hull == null) return particlePos;
|
||||||
|
|
||||||
|
return new Vector2(
|
||||||
|
MathHelper.Clamp(particlePos.X, hull.WorldRect.X, hull.WorldRect.Right),
|
||||||
|
MathHelper.Clamp(particlePos.Y, hull.WorldRect.Y - hull.WorldRect.Height, hull.WorldRect.Y));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private IEnumerable<object> DimLight(LightSource light)
|
private IEnumerable<object> DimLight(LightSource light)
|
||||||
{
|
{
|
||||||
float currBrightness= 1.0f;
|
float currBrightness = 1.0f;
|
||||||
float startRange = light.Range;
|
float startRange = light.Range;
|
||||||
|
|
||||||
while (light.Color.A > 0.0f)
|
while (light.Color.A > 0.0f)
|
||||||
@@ -101,7 +117,7 @@ namespace Barotrauma
|
|||||||
light.Color = new Color(light.Color.R, light.Color.G, light.Color.B, currBrightness);
|
light.Color = new Color(light.Color.R, light.Color.G, light.Color.B, currBrightness);
|
||||||
light.Range = startRange * currBrightness;
|
light.Range = startRange * currBrightness;
|
||||||
|
|
||||||
currBrightness -= CoroutineManager.DeltaTime*10.0f;
|
currBrightness -= CoroutineManager.DeltaTime * 20.0f;
|
||||||
|
|
||||||
yield return CoroutineStatus.Running;
|
yield return CoroutineStatus.Running;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user