Class SpriteAnimationWindrose
The Windrose Animation. This animation has multiple cycles, each referring to a cardinal position.
Namespace : SpriteAnimations
Fields
_cycles
[SerializeField]
[HideInInspector]
protected SpriteAnimationWindrose.WindroseCycles _cycles
Field Value
_isLoopable
If the animation should loop
[SerializeField]
protected bool _isLoopable
Field Value
Properties
AnimationType
The type of the animation.
public override AnimationType AnimationType { get; }
Property Value
Cycles
public SpriteAnimationWindrose.WindroseCycles Cycles { get; }
Property Value
IsLoopable
If the animation is loopable.
public bool IsLoopable { get; set; }
Property Value
PerformerType
The type of the performer.
public override Type PerformerType { get; }
Property Value
Methods
CalculateFramesCount()
Calculates the maximum size of all cycles.
public override int CalculateFramesCount()
Returns
- int
The maximum size of all cycles.
DirectionFromInput(Vector2Int)
Returns the windrose direction based on the signed input.
public static WindroseDirection DirectionFromInput(Vector2Int signedInput)
Parameters
signedInput
Vector2IntThe signed input representing the x and y coordinates.
Returns
- WindroseDirection
The windrose direction based on the signed input.
DirectionSign(Vector2)
Returns the sign of each axis of the movement input.
public static Vector2Int DirectionSign(Vector2 movementInput)
Parameters
movementInput
Vector2The movement input vector.
Returns
- Vector2Int
A Vector2Int representing the sign of each component of the movement input.
FindOrCreateCycle(WindroseDirection)
Find or create a SpriteAnimationCycle for the specified direction.
public Cycle FindOrCreateCycle(WindroseDirection direction)
Parameters
direction
WindroseDirectionThe direction to find or create the cycle for.
Returns
- Cycle
The found or created SpriteAnimationCycle.
InputFromDirection(WindroseDirection)
Converts a WindroseDirection enum value into a Vector2Int representing the corresponding direction.
public static Vector2Int InputFromDirection(WindroseDirection direction)
Parameters
direction
WindroseDirectionThe WindroseDirection enum value.
Returns
- Vector2Int
A Vector2Int representing the direction.
OnDemand(int, Dictionary<WindroseDirection, List<Sprite>>, bool)
Creates a new SpriteAnimationWindrose on demand.
Remember that all the sprites lists in the dictionary should have the same length so the animation stay consistent.
public static SpriteAnimationWindrose OnDemand(int fps, Dictionary<WindroseDirection, List<Sprite>> cycles, bool isLoopable = false)
Parameters
fps
intcycles
Dictionary<WindroseDirection, List<Sprite>>isLoopable
bool
Returns
TryGetCycle(WindroseDirection, out Cycle)
Tries to get the sprite animation cycle associated with the given windrose direction.
public bool TryGetCycle(WindroseDirection direction, out Cycle cycle)
Parameters
direction
WindroseDirectionThe windrose direction.
cycle
CycleThe sprite animation cycle associated with the direction, if found.
Returns
- bool
True if the sprite animation cycle was found, false otherwise.
UseAsTemplate(Dictionary<WindroseDirection, List<Sprite>>)
Creates a new SpriteAnimationWindrose using the provided cycles as a template.
public SpriteAnimationWindrose UseAsTemplate(Dictionary<WindroseDirection, List<Sprite>> cycles)
Parameters
cycles
Dictionary<WindroseDirection, List<Sprite>>A dictionary of WindroseDirection and lists of Sprites representing the cycles.
Returns
- SpriteAnimationWindrose
A new SpriteAnimationWindrose instance.