Particles using display coordinates, particle growtime, character death&stun animations
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using FarseerPhysics;
|
||||
|
||||
namespace Subsurface.Particles
|
||||
{
|
||||
@@ -7,67 +8,104 @@ namespace Subsurface.Particles
|
||||
{
|
||||
public enum DrawTargetType { Air = 1, Water = 2, Both = 3 }
|
||||
|
||||
public readonly string name;
|
||||
public readonly string Name;
|
||||
|
||||
public readonly Sprite sprite;
|
||||
public readonly Sprite Sprite;
|
||||
|
||||
public readonly float angularVelocityMin, angularVelocityMax;
|
||||
public readonly float AngularVelocityMin, AngularVelocityMax;
|
||||
|
||||
public readonly float startRotationMin, startRotationMax;
|
||||
public readonly float StartRotationMin, StartRotationMax;
|
||||
|
||||
public readonly Vector2 startSizeMin, startSizeMax;
|
||||
public readonly Vector2 sizeChangeMin, sizeChangeMax;
|
||||
public readonly Vector2 StartSizeMin, StartSizeMax;
|
||||
public readonly Vector2 SizeChangeMin, SizeChangeMax;
|
||||
|
||||
public readonly Color startColor;
|
||||
public readonly float startAlpha;
|
||||
public readonly Color StartColor;
|
||||
public readonly float StartAlpha;
|
||||
|
||||
public readonly Vector4 colorChange;
|
||||
public readonly Vector4 ColorChange;
|
||||
|
||||
public readonly float lifeTime;
|
||||
public readonly float LifeTime;
|
||||
|
||||
public readonly bool deleteOnHit;
|
||||
public readonly float GrowTime;
|
||||
|
||||
public readonly Vector2 velocityChange;
|
||||
public readonly bool DeleteOnCollision;
|
||||
|
||||
public readonly Vector2 VelocityChange;
|
||||
|
||||
public readonly DrawTargetType DrawTarget;
|
||||
|
||||
public readonly bool rotateToDirection;
|
||||
public readonly bool RotateToDirection;
|
||||
|
||||
public ParticlePrefab(XElement element)
|
||||
{
|
||||
name = element.Name.ToString();
|
||||
Name = element.Name.ToString();
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
if (subElement.Name.ToString().ToLower() != "sprite") continue;
|
||||
|
||||
sprite = new Sprite(subElement);
|
||||
Sprite = new Sprite(subElement);
|
||||
}
|
||||
|
||||
angularVelocityMin = ToolBox.GetAttributeFloat(element, "angularvelocitymin", 0.0f);
|
||||
angularVelocityMax = ToolBox.GetAttributeFloat(element, "angularvelocitymax", 0.0f);
|
||||
if (element.Attribute("angularvelocity") == null)
|
||||
{
|
||||
AngularVelocityMin = ToolBox.GetAttributeFloat(element, "angularvelocitymin", 0.0f);
|
||||
AngularVelocityMax = ToolBox.GetAttributeFloat(element, "angularvelocitymax", 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
AngularVelocityMin = ToolBox.GetAttributeFloat(element, "angularvelocity", 0.0f);
|
||||
AngularVelocityMax = AngularVelocityMin;
|
||||
}
|
||||
|
||||
startSizeMin = ToolBox.GetAttributeVector2(element, "startsizemin", Vector2.One);
|
||||
startSizeMax = ToolBox.GetAttributeVector2(element, "startsizemax", Vector2.One);
|
||||
if (element.Attribute("startsize") == null)
|
||||
{
|
||||
StartSizeMin = ToolBox.GetAttributeVector2(element, "startsizemin", Vector2.One);
|
||||
StartSizeMax = ToolBox.GetAttributeVector2(element, "startsizemax", Vector2.One);
|
||||
}
|
||||
else
|
||||
{
|
||||
StartSizeMin = ToolBox.GetAttributeVector2(element, "startsize", Vector2.One);
|
||||
StartSizeMax = StartSizeMin;
|
||||
}
|
||||
|
||||
sizeChangeMin = ToolBox.GetAttributeVector2(element, "sizechangemin", Vector2.Zero);
|
||||
sizeChangeMax = ToolBox.GetAttributeVector2(element, "sizechangemax", Vector2.Zero);
|
||||
if (element.Attribute("sizechange") == null)
|
||||
{
|
||||
SizeChangeMin = ToolBox.GetAttributeVector2(element, "sizechangemin", Vector2.Zero);
|
||||
SizeChangeMax = ToolBox.GetAttributeVector2(element, "sizechangemax", Vector2.Zero);
|
||||
}
|
||||
else
|
||||
{
|
||||
SizeChangeMin = ToolBox.GetAttributeVector2(element, "sizechange", Vector2.Zero);
|
||||
SizeChangeMax = SizeChangeMin;
|
||||
}
|
||||
|
||||
startRotationMin = ToolBox.GetAttributeFloat(element, "startrotationmin", 0.0f);
|
||||
startRotationMax = ToolBox.GetAttributeFloat(element, "startrotationmax", 0.0f);
|
||||
GrowTime = ToolBox.GetAttributeFloat(element, "growtime", 0.0f);
|
||||
|
||||
startColor = new Color(ToolBox.GetAttributeVector4(element, "startcolor", Vector4.One));
|
||||
startAlpha = ToolBox.GetAttributeFloat(element, "startalpha", 1.0f);
|
||||
if (element.Attribute("startrotation") == null)
|
||||
{
|
||||
StartRotationMin = ToolBox.GetAttributeFloat(element, "startrotationmin", 0.0f);
|
||||
StartRotationMax = ToolBox.GetAttributeFloat(element, "startrotationmax", 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
StartRotationMin = ToolBox.GetAttributeFloat(element, "startrotatio", 0.0f);
|
||||
StartRotationMax = StartRotationMin;
|
||||
}
|
||||
|
||||
deleteOnHit = ToolBox.GetAttributeBool(element, "deleteonhit", false);
|
||||
StartColor = new Color(ToolBox.GetAttributeVector4(element, "startcolor", Vector4.One));
|
||||
StartAlpha = ToolBox.GetAttributeFloat(element, "startalpha", 1.0f);
|
||||
|
||||
colorChange = ToolBox.GetAttributeVector4(element, "colorchange", Vector4.Zero);
|
||||
DeleteOnCollision = ToolBox.GetAttributeBool(element, "deleteoncollision", false);
|
||||
|
||||
lifeTime = ToolBox.GetAttributeFloat(element, "lifetime", 5.0f);
|
||||
ColorChange = ToolBox.GetAttributeVector4(element, "colorchange", Vector4.Zero);
|
||||
|
||||
velocityChange = ToolBox.GetAttributeVector2(element, "velocitychange", Vector2.Zero);
|
||||
LifeTime = ToolBox.GetAttributeFloat(element, "lifetime", 5.0f);
|
||||
|
||||
rotateToDirection = ToolBox.GetAttributeBool(element, "rotatetodirection", false);
|
||||
VelocityChange = ToolBox.GetAttributeVector2(element, "velocitychange", Vector2.Zero);
|
||||
VelocityChange = ConvertUnits.ToDisplayUnits(VelocityChange);
|
||||
|
||||
RotateToDirection = ToolBox.GetAttributeBool(element, "rotatetodirection", false);
|
||||
|
||||
switch (ToolBox.GetAttributeString(element, "drawtarget", "air").ToLower())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user