Class LegionProjectile

Namespace
PixelUnitStudio
Assembly
PixelUnitStudio.Runtime.dll

Flies one projectile from its start point to the target point, calls Arrived when it lands, then removes it. Bows, crossbows, guns and staffs fly the catalog's projectile art (Projectiles/) straight; thrown weapons throw the weapon art itself in an arc. A thrown weapon doesn't rotate its art; it spins by swapping pre-rotated art (turns), so pixels don't break. Hit detection is up to the game. Usually called from the hit event of an attack motion (LegionEvents).

public sealed class LegionProjectile : MonoBehaviour
Inheritance
LegionProjectile

Constructors

LegionProjectile()

public LegionProjectile()

Fields

arc

public float arc

Field Value

float

from

public Vector3 from

Field Value

Vector3

speed

public float speed

Field Value

float

spin

public float spin

Field Value

float

to

public Vector3 to

Field Value

Vector3

turns

public Sprite[] turns

Field Value

Sprite[]

Methods

Launch(LegionBuilder, Vector3, float)

Fires from the back-hand weapon of an assembled hero (LegionBuilder) to to.

public static LegionProjectile Launch(LegionBuilder hero, Vector3 to, float speed = 10)

Parameters

hero LegionBuilder
to Vector3
speed float

Returns

LegionProjectile

Launch(LegionCatalog, Option, Vector3, Vector3, float, int, int)

Flies the projectile fired by weapon (the back-hand weapon option) from from to to. Null for weapons without a projectile (swords, etc.).

public static LegionProjectile Launch(LegionCatalog catalog, LegionCatalog.Option weapon, Vector3 from, Vector3 to, float speed = 10, int sortingLayer = 0, int sortingOrder = 200)

Parameters

catalog LegionCatalog
weapon LegionCatalog.Option
from Vector3
to Vector3
speed float
sortingLayer int
sortingOrder int

Returns

LegionProjectile

Launch(LegionCatalog, LegionUnit, Vector3, float)

Fires from the back-hand weapon of a saved hero prefab (LegionUnit) to to. The weapon option is looked up by name in catalog.

public static LegionProjectile Launch(LegionCatalog catalog, LegionUnit unit, Vector3 to, float speed = 10)

Parameters

catalog LegionCatalog
unit LegionUnit
to Vector3
speed float

Returns

LegionProjectile

Shoots(LegionCatalog, Option)

Whether weapon is one that fires a projectile (bow, crossbow, gun, staff, thrown).

public static bool Shoots(LegionCatalog catalog, LegionCatalog.Option weapon)

Parameters

catalog LegionCatalog
weapon LegionCatalog.Option

Returns

bool

Events

Arrived

When it reaches the target point. The projectile is removed after this.

public event Action<LegionProjectile> Arrived

Event Type

Action<LegionProjectile>