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
from
public Vector3 from
Field Value
- Vector3
speed
public float speed
Field Value
spin
public float spin
Field Value
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
heroLegionBuildertoVector3speedfloat
Returns
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
catalogLegionCatalogweaponLegionCatalog.OptionfromVector3toVector3speedfloatsortingLayerintsortingOrderint
Returns
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
catalogLegionCatalogunitLegionUnittoVector3speedfloat
Returns
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
catalogLegionCatalogweaponLegionCatalog.Option
Returns
Events
Arrived
When it reaches the target point. The projectile is removed after this.
public event Action<LegionProjectile> Arrived