Melee weapons (+ stun baton), improved throw animation, new damage sound effects
This commit is contained in:
65
Subsurface/Source/Particles/ParticleEmitter.cs
Normal file
65
Subsurface/Source/Particles/ParticleEmitter.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using FarseerPhysics;
|
||||
using System;
|
||||
|
||||
namespace Subsurface.Particles
|
||||
{
|
||||
class ParticleEmitterPrefab
|
||||
{
|
||||
public readonly string Name;
|
||||
|
||||
public readonly ParticlePrefab particlePrefab;
|
||||
|
||||
public readonly float AngleMin, AngleMax;
|
||||
|
||||
public readonly float VelocityMin, VelocityMax;
|
||||
|
||||
public readonly float ParticleAmount;
|
||||
|
||||
public ParticleEmitterPrefab(XElement element)
|
||||
{
|
||||
Name = element.Name.ToString();
|
||||
|
||||
particlePrefab = Game1.ParticleManager.FindPrefab(ToolBox.GetAttributeString(element, "particle", ""));
|
||||
|
||||
if (element.Attribute("startrotation") == null)
|
||||
{
|
||||
AngleMin = ToolBox.GetAttributeFloat(element, "anglemin", 0.0f);
|
||||
AngleMax = ToolBox.GetAttributeFloat(element, "anglemax", 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
AngleMin = ToolBox.GetAttributeFloat(element, "angle", 0.0f);
|
||||
AngleMax = AngleMin;
|
||||
}
|
||||
|
||||
AngleMin = MathHelper.ToRadians(AngleMin);
|
||||
AngleMin = MathHelper.ToRadians(AngleMax);
|
||||
|
||||
if (element.Attribute("velocity") == null)
|
||||
{
|
||||
VelocityMin = ToolBox.GetAttributeFloat(element, "velocitymin", 0.0f);
|
||||
VelocityMax = ToolBox.GetAttributeFloat(element, "velocitymax", 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
VelocityMin = ToolBox.GetAttributeFloat(element, "velocity", 0.0f);
|
||||
VelocityMax = VelocityMin;
|
||||
}
|
||||
|
||||
ParticleAmount = ToolBox.GetAttributeInt(element, "particleamount", 1);
|
||||
}
|
||||
|
||||
public void Emit(Vector2 position)
|
||||
{
|
||||
for (int i = 0; i<ParticleAmount; i++)
|
||||
{
|
||||
float angle = Rand.Range(AngleMin, AngleMax);
|
||||
Vector2 velocity = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * Rand.Range(VelocityMin, VelocityMax);
|
||||
|
||||
Game1.ParticleManager.CreateParticle(particlePrefab, position, velocity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,15 +46,8 @@ namespace Subsurface.Particles
|
||||
}
|
||||
|
||||
public Particle CreateParticle(string prefabName, Vector2 position, Vector2 speed, float rotation=0.0f)
|
||||
{
|
||||
ParticlePrefab prefab;
|
||||
prefabs.TryGetValue(prefabName, out prefab);
|
||||
|
||||
if (prefab==null)
|
||||
{
|
||||
DebugConsole.ThrowError("Particle prefab "+prefabName+" not found!");
|
||||
return null;
|
||||
}
|
||||
{
|
||||
ParticlePrefab prefab = FindPrefab(prefabName);
|
||||
|
||||
return CreateParticle(prefab, position, speed, rotation);
|
||||
}
|
||||
@@ -74,6 +67,20 @@ namespace Subsurface.Particles
|
||||
|
||||
}
|
||||
|
||||
public ParticlePrefab FindPrefab(string prefabName)
|
||||
{
|
||||
ParticlePrefab prefab;
|
||||
prefabs.TryGetValue(prefabName, out prefab);
|
||||
|
||||
if (prefab == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Particle prefab " + prefabName + " not found!");
|
||||
return null;
|
||||
}
|
||||
|
||||
return prefab;
|
||||
}
|
||||
|
||||
private void RemoveParticle(int index)
|
||||
{
|
||||
particleCount--;
|
||||
@@ -83,8 +90,6 @@ namespace Subsurface.Particles
|
||||
particles[particleCount] = swap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void Update(float deltaTime)
|
||||
{
|
||||
for (int i = 0; i < particleCount; i++)
|
||||
|
||||
@@ -89,10 +89,13 @@ namespace Subsurface.Particles
|
||||
}
|
||||
else
|
||||
{
|
||||
StartRotationMin = ToolBox.GetAttributeFloat(element, "startrotatio", 0.0f);
|
||||
StartRotationMin = ToolBox.GetAttributeFloat(element, "startrotation", 0.0f);
|
||||
StartRotationMax = StartRotationMin;
|
||||
}
|
||||
|
||||
StartRotationMin = MathHelper.ToRadians(StartRotationMin);
|
||||
StartRotationMax = MathHelper.ToRadians(StartRotationMax);
|
||||
|
||||
StartColor = new Color(ToolBox.GetAttributeVector4(element, "startcolor", Vector4.One));
|
||||
StartAlpha = ToolBox.GetAttributeFloat(element, "startalpha", 1.0f);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user