Table of Contents

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

SpriteAnimationWindrose.WindroseCycles

_isLoopable

If the animation should loop

[SerializeField]
protected bool _isLoopable

Field Value

bool

Properties

AnimationType

The type of the animation.

public override AnimationType AnimationType { get; }

Property Value

AnimationType

Cycles

public SpriteAnimationWindrose.WindroseCycles Cycles { get; }

Property Value

SpriteAnimationWindrose.WindroseCycles

IsLoopable

If the animation is loopable.

public bool IsLoopable { get; set; }

Property Value

bool

PerformerType

The type of the performer.

public override Type PerformerType { get; }

Property Value

Type

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 Vector2Int

The 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 Vector2

The 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 WindroseDirection

The 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 WindroseDirection

The 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 int
cycles Dictionary<WindroseDirection, List<Sprite>>
isLoopable bool

Returns

SpriteAnimationWindrose

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 WindroseDirection

The windrose direction.

cycle Cycle

The 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.