Platformer Pro  2.3.2
A platform game kit for Unity.
PlatformerPro.Enemy Class Reference

Base class for an enemy. More...

Inheritance diagram for PlatformerPro.Enemy:
PlatformerPro.PersistableObject PlatformerPro.IMob PlatformerPro.PlatformerProMonoBehaviour PlatformerPro.RotatingEnemy PlatformerPro.SequenceDrivenEnemy

Public Member Functions

virtual void OnChangeAnimationState ()
 Raises the change animation state event. This version is public as it just triggers an update not a change. More...
 
virtual void OnEnemyAIEvent (string eventName)
 Raises an enemy AI event. More...
 
virtual void SwitchDirection ()
 Call this to switch the direction of all associated movements. More...
 
virtual void HitCharacter (Character character, DamageInfo info)
 Called when the enemy hits the character causing damage. More...
 
virtual void AttackFinished ()
 Called when the enemies current attack finished More...
 
virtual void MovementComplete ()
 Called when a compeletable movement finishes. More...
 
virtual void Reset ()
 Reset this instance. More...
 
virtual void Damage (DamageInfo info)
 Damage the enemy with the specified damage information. More...
 
virtual void Heal (int amount)
 Heal the enemy by the specified amount. More...
 
virtual void SetHealth (int amount)
 Heal the enemy by the specified amount. More...
 
virtual void Die (DamageInfo info)
 Kill the enemy. More...
 
virtual void Translate (float x, float y, bool applyYTransformsInWorldSpace)
 Translate the character by the supplied amount. More...
 
virtual void AddVelocity (float x, float y)
 Adds velocity. More...
 
virtual void SetVelocityX (float x)
 Sets X velocity. More...
 
virtual void SetVelocityY (float y)
 Sets Y velocity. More...
 
virtual void AddAnimationOverride (string overrideState)
 Adds an animation override. NOTE: Currently only one override is supported at a time. Note overrides are used to refer to an animator or layer override (depending on animation type) not forcing the override of a single animation which is done with ForceAnimation(). More...
 
virtual void RemoveAnimationOverride (string overrideState)
 Removes an animation override. NOTE: Currently only one override is supported at a time. More...
 
virtual void ApplyGravity ()
 Applies the gravity. More...
 
virtual void MakeInvulnerable (float invulnerableTime)
 Makes the enemy invulnerable for the given number of settings. More...
 
virtual void MakeVulnerable ()
 Makes the enemy vulnerable. More...
 
virtual void ApplyFeetCollisions ()
 Applies the feet collisions. More...
 
virtual void ApplySideCollisions ()
 Applies the Side collisions. More...
 
virtual bool IsColliderIgnored (Collider2D collider)
 Check if a given collider should be ignored in collisions. More...
 
virtual void AddIgnoredCollider (Collider2D collider)
 Adds a collider to the list of ignored colliders. More...
 
virtual void RemoveIgnoredCollider (Collider2D collider)
 Removes a collider from the list of ignored colliders. More...
 
- Public Member Functions inherited from PlatformerPro.PersistableObject
void SetPersistenceState (bool state)
 Sets the persistence state. More...
 
void SetPersistenceState (bool state, string extraPersistenceData)
 Sets the persistence state, overriding extra persistence data More...
 
- Public Member Functions inherited from PlatformerPro.PlatformerProMonoBehaviour
virtual void Validate (PlatformerProMonoBehaviour myTarget)
 Override this method if you want to provide custom validation. The actual code should be surrounded by the if UNITY_EDITOR / endif directive. More...
 

Public Attributes

int health = 1
 Enemies health. More...
 
bool continueMovementOnDamage
 If true the movement system will control damage. Generally used for Graph based enemy AI. More...
 
float invulnerableTime = 0.5f
 How long the enemy is invulnerable to damage after being hit. More...
 
float damageTime = 0.5f
 How long the enemy in the damaged movement after being hit. More...
 
bool continueMovementOnFall
 Should movements keep moving while falling. More...
 
bool switchCollidersOnDirectionChange
 Should we switch colliders when the enemy changes direction (used for asymmetric characters). More...
 
int startFacingDirection = 1
 The facing direction on start. Typically 1 or -1. More...
 
bool enemyInteractsWithPlatforms
 Does this enemy interact with platforms? More...
 
LayerMask geometryLayerMask
 The layers that are considered when working out collisions. i.e. the things we can't move through. More...
 
bool characterCanFall
 Does the character fall if there is no platform below it? More...
 
float terminalVelocity = -15f
 Maximum fall speed (note that any individual movement may override this if it wants to). More...
 
bool useCharacterGravity
 Should we use the characters gravity or a custom one. More...
 
float customGravity = -15f
 Custom gravity. More...
 
float feetHeight
 If the cahracter can fall where are its feet in y? More...
 
float groundedLookAhead
 How far do we look ahead when determining if we are grounded. More...
 
float feetWidth
 If the cahracter can fall where are its feet in x (offset from centre)? More...
 
bool detectSideCollisions
 Does the character detect side collisions? More...
 
float sideHeight
 The height of the side collisions. More...
 
float sideWidth
 The width of the side collisions. More...
 
bool switchDirectionOnSideHit
 If the charcter runs in to the wall should it switch direciton on all movements? More...
 
bool useDefaultPersistence
 Does this Item get persistence defaults form the Game manager? More...
 
PersistableEnemyType enemyPersistenceImplementation
 How do we implement the persistence settings. More...
 
RaycastHit2D[] leftFeetCollisions
 Stores left foot collissions. More...
 
RaycastHit2D[] rightFeetCollisions
 Stores right foot collissions. More...
 
- Public Attributes inherited from PlatformerPro.PersistableObject
bool enablePersistence
 Should we enable persistence? More...
 
string guid = System.Guid.NewGuid().ToString()
 Unique ID for this object. You shoulnd't need to edit this, use editor debug mode if you must. More...
 
GameObject target
 GameObject to apply persitence settings to, defaults to self. More...
 
PersistableObjectType persistenceImplementation
 How do we implement the persistence settings. More...
 
bool defaultStateIsDisabled
 If true then the obejct starts disabled. More...
 
string spawnedObjectName
 If this item was spawned then save the name of the prefab here. More...
 

Protected Member Functions

virtual void OnDamaged (DamageInfo info)
 Raises the damaged event. More...
 
virtual void OnDied (DamageInfo info)
 Raises the died event. More...
 
virtual void OnCollided (DamageInfo info)
 Raises the collided event. More...
 
virtual void OnChangeAnimationState (AnimationState state, AnimationState previousState)
 Raises the change animation state event. More...
 
virtual void OnChangeAnimationState (AnimationState state, AnimationState previousState, int priority)
 Raises the change animation state event. More...
 
virtual void OnCharacterDamaged (DamageInfo info)
 Raises the hit character event. More...
 
virtual void OnMovementHasCompleted ()
 Raises the MovementHasCompleted Event. More...
 
override void PostInit ()
 Set up the character More...
 
override void SetPersistenceDefaults ()
 Sets the persistence defaults. More...
 
virtual void HandleWillExitScene (object sender, SceneEventArgs e)
 Handles the will exit scene event. used to save data. More...
 
virtual void DoUpdate ()
 Run each frame to determine and execute move. More...
 
virtual void SwitchColliders ()
 Switches left and right collider direction and flips position of all colliders about y axis. More...
 
virtual void DoBaseCollisions ()
 Does the base collisions. More...
 
virtual void DecideOnNextMovement ()
 Decides on the next movement. Extracted out so it can be easily overriden. More...
 
override void ApplyCustomPersistence (PersistableObjectData data)
 Custom persistable implementation. Override to customise. More...
 
virtual void SavePersistenceData ()
 Gets the extra persistence data which is used to save enemy state. NOTE: Generally you should override ExtraPersistenceData to save a different set of data. More...
 
- Protected Member Functions inherited from PlatformerPro.PersistableObject
virtual void ProcessState ()
 Processes the persisted state. More...
 
virtual void ApplyExtraPersistenceData (PersistableObjectData data)
 Apply any extra data. This differs from custom persistence, as custom persistence must control both data and ctivation state. More...
 

Protected Attributes

Transform myTransform
 Cached copy of the enemies transform. More...
 
EnemyMovement movement
 Reference to the class that controls the enemy movement. More...
 
EnemyMovement damageMovement
 Reference to the class that controls the enemy damage movement. More...
 
EnemyMovement deathMovement
 Reference to the class that controls the enemy death movement. More...
 
AnimationState animationState
 The enemies current animation state. More...
 
string overrideState
 The enemies current animation overridestate. More...
 
AnimationEventArgs animationEventArgs
 A cached animation event args that we update so we don't need to allocate. More...
 
bool Active = true
 Is this enemy active? More...
 
float invulnerableTimer = -1.0f
 Timer for invulnerability. Character is invulnerable when this is greater than zero. More...
 
DamageInfoEventArgs damageEventArgs
 Cached copy of damage event args to save on allocations. More...
 
EnemyAI enemyAi
 The enemy ai (can be null meaning only movements will control the character). More...
 
int currentFacingDirection
 The direction currently faced. Used for switch collider calculations and for AI that needs actual facing direction. More...
 
Transform[] collidersForSwitching
 If we switch colliders when the character turns this is the list of transforms of Collider2D's to switch. More...
 
NoAllocationSmartFeetcast rightFoot
 The right foot collider. More...
 
NoAllocationSmartFeetcast leftFoot
 The left foot collider. More...
 
NoAllocationSmartSidecast rightSide
 The right side collider. More...
 
NoAllocationSmartSidecast leftSide
 The left side collider. More...
 
Character characterForGravity
 If gravity comes from a character reference this is the gravity we are using. More...
 
bool grounded
 Is the enemy grounded. More...
 
float ignoredSlope
 The angle of the ignored slope. More...
 
PlatformCollisionArgs platformCollisionArgs
 The platform collision arguments. More...
 
Platform parentPlatform
 Stores the aprent platform if we have one. More...
 
Character currentTarget
 The current target. More...
 
HashSet< Collider2D > ignoredColliders
 A list of colliders to ingore during collisions. More...
 

Static Protected Attributes

const float MAX_ENEMY_SLOPE = 60.0f
 Max slope an enemy will calcualte/walk on More...
 
const float DefaultSideLookAhead = 0.05f
 Default side look ahead. More...
 

Properties

override string Header [get]
 
virtual Transform Transform [get]
 Gets cache copy of the transform. More...
 
virtual int FacingDirection [get]
 Returns the direction the enemy is facing. 0 for none, 1 for right, -1 for left. More...
 
virtual AnimationState AnimationState [get, protected set]
 The enemies current animation state. More...
 
virtual string OverrideState [get, protected set]
 The enemies current animation override state. More...
 
virtual Vector2 Velocity [get, set]
 The characters velocity. More...
 
virtual Vector2 PreviousVelocity [get, set]
 The characters velocity in the previous frame. More...
 
virtual bool IsInvulnerable [get]
 Is the character currently invulnerable? More...
 
virtual EnemyState State [get, protected set]
 The current AI state. More...
 
int StartingHealth [get, protected set]
 Health the enemy started with More...
 
virtual int? LastFacedDirection [get]
 Returns the direction the character is facing, but if direction is currently 0 instead returns the direction last faced. More...
 
virtual float SlopeTargetRotation [get, protected set]
 If slopes are on this is the rotation we are rotating towards. More...
 
virtual float SlopeActualRotation [get]
 If slopes are on this is the rotation we are currently on. More...
 
virtual float PreviousRotation [get, set]
 The characters rotation in the previous frame. More...
 
virtual float IgnoredSlope [get, set]
 Gets the ignored slope. The ignored slope is used primary for internal physics calculations and is the largest slope that was ignored by the side colliders last frame. More...
 
virtual float MinSideAngle [get]
 Gets the minimum angle at which geometry is considered a wall. More...
 
virtual int ZLayer [get, set]
 Gets or sets the characters current z layer. More...
 
virtual EnemyAI AI [get]
 Gets the enemy AI or null if there is no AI. More...
 
virtual bool Grounded [get]
 Returns true if we are grounded or false otherwise. More...
 
virtual bool GroundedLeft [get, protected set]
 Returns true if we are grounded on the left foot. More...
 
virtual bool GroundedRight [get, protected set]
 Returns true if we are grounded on the left foot. More...
 
virtual int GroundLayer [get, protected set]
 If grounded this is the layer of the ground. Undefined if not grounded. More...
 
virtual float? Gravity [get]
 Gravity for this enemy More...
 
virtual EnemyMovement CurrentMovement [get]
 Gets the current movement or null if no movement is acgtive (for example when falling with continueMovementOnFall off). More...
 
virtual float Friction [get, set]
 Gets the friction. More...
 
virtual Transform CurrentTargetTransform [get]
 The current targets position or enemies position if no target found. More...
 
virtual Character CurrentTarget [get, set]
 The current target. More...
 
override string ExtraPersistenceData [get]
 Gets the extra persistence data. More...
 
virtual EnemyPersistenceData ExtraPersistenceDataAsObject [get]
 Gets the extra persistence data in object form which is used to save enemy state. More...
 
- Properties inherited from PlatformerPro.PersistableObject
virtual string ExtraPersistenceData [get]
 Gets the extra persistence data. More...
 
- Properties inherited from PlatformerPro.PlatformerProMonoBehaviour
virtual string Header [get]
 Gets the header string used to describe the component. More...
 
virtual string DocLink [get]
 Gets a link to documentation site. More...
 
virtual string VideoLink [get]
 Gets a link to a youtube video. More...
 
virtual string Deprecated [get]
 If non-null this component is deprecated. The string shows a message indicating how it should be replaced. More...
 
- Properties inherited from PlatformerPro.IMob
AnimationState AnimationState [get]
 The current animation state. More...
 
int FacingDirection [get]
 Returns the direction being faced. 0 for none, 1 for right, -1 for left. More...
 
int LastFacedDirection [get]
 Returns the direction being faced, but if direction is currently 0 instead returns the direction last faced. More...
 
Vector2 Velocity [get]
 The characters velocity relative to self. More...
 
Vector2 PreviousVelocity [get]
 The characters velocity in the previous frame relative to self. More...
 
float SlopeTargetRotation [get]
 If slopes are on this is the rotation we are rotating towards. More...
 
float SlopeActualRotation [get]
 If slopes are on this is the rotation we are currently on. More...
 
float PreviousRotation [get]
 If slopes are on this is the rotation we were at last frame. More...
 
float IgnoredSlope [get, set]
 Gets the ignored slope. The ignored slope is used primary for internal physics calculations and is the largest slope that was ignored by the side colliders last frame. More...
 
float MinSideAngle [get]
 Gets the minimum angle at which geometry is considered a wall. More...
 
int ZLayer [get, set]
 Gets or sets the characters current z layer. More...
 
bool Grounded [get]
 Returns true if we are grounded or false otherwise. More...
 
int GroundLayer [get]
 If grounded this is the layer of the ground. Undefined if not grounded. More...
 
float Gravity [get]
 Gravity currently acting on the character. More...
 
float Friction [get, set]
 Gets the friction. More...
 

Events

System.EventHandler< AnimationEventArgsChangeAnimationState
 Event for anmation state changes. More...
 
System.EventHandler< DamageInfoEventArgsDamaged
 Event for damage. More...
 
System.EventHandler< DamageInfoEventArgsDied
 Event for death. More...
 
System.EventHandler< DamageInfoEventArgsCollided
 Event for being hit but not damaged. More...
 
System.EventHandler< DamageInfoEventArgsCharacterDamaged
 Event for damaging a character. More...
 
System.EventHandler< EmptyEventArgsMovementHasCompleted
 Event sent when current movement completes. More...
 
System.EventHandler< EnemyAIEventArgsEnemyAIEvent
 A generic event sent by an enemy AI. More...
 
- Events inherited from PlatformerPro.IMob
System.EventHandler< AnimationEventArgsChangeAnimationState
 Event for anmation state changes. More...
 

Detailed Description

Base class for an enemy.

Member Function Documentation

◆ AddAnimationOverride()

virtual void PlatformerPro.Enemy.AddAnimationOverride ( string  overrideState)
virtual

Adds an animation override. NOTE: Currently only one override is supported at a time. Note overrides are used to refer to an animator or layer override (depending on animation type) not forcing the override of a single animation which is done with ForceAnimation().

Parameters
overrideStateOverride State, null values iwll be ignored.

◆ AddIgnoredCollider()

virtual void PlatformerPro.Enemy.AddIgnoredCollider ( Collider2D  collider)
virtual

Adds a collider to the list of ignored colliders.

Parameters
colliderCollider.

◆ AddVelocity()

virtual void PlatformerPro.Enemy.AddVelocity ( float  x,
float  y 
)
virtual

Adds velocity.

Parameters
xThe velocity to add to x.
yThe velocity to add to y.

◆ ApplyCustomPersistence()

override void PlatformerPro.Enemy.ApplyCustomPersistence ( PersistableObjectData  data)
protectedvirtual

Custom persistable implementation. Override to customise.

Parameters
dataData.

Reimplemented from PlatformerPro.PersistableObject.

◆ ApplyFeetCollisions()

virtual void PlatformerPro.Enemy.ApplyFeetCollisions ( )
virtual

Applies the feet collisions.

Reimplemented in PlatformerPro.RotatingEnemy.

◆ ApplyGravity()

virtual void PlatformerPro.Enemy.ApplyGravity ( )
virtual

Applies the gravity.

◆ ApplySideCollisions()

virtual void PlatformerPro.Enemy.ApplySideCollisions ( )
virtual

Applies the Side collisions.

◆ AttackFinished()

virtual void PlatformerPro.Enemy.AttackFinished ( )
virtual

Called when the enemies current attack finished

◆ Damage()

virtual void PlatformerPro.Enemy.Damage ( DamageInfo  info)
virtual

Damage the enemy with the specified damage information.

Parameters
infoThe damage info.

Reimplemented in PlatformerPro.SequenceDrivenEnemy.

◆ DecideOnNextMovement()

virtual void PlatformerPro.Enemy.DecideOnNextMovement ( )
protectedvirtual

Decides on the next movement. Extracted out so it can be easily overriden.

Reimplemented in PlatformerPro.SequenceDrivenEnemy.

◆ Die()

virtual void PlatformerPro.Enemy.Die ( DamageInfo  info)
virtual

Kill the enemy.

Parameters
infoInfo.

◆ DoBaseCollisions()

virtual void PlatformerPro.Enemy.DoBaseCollisions ( )
protectedvirtual

Does the base collisions.

◆ DoUpdate()

virtual void PlatformerPro.Enemy.DoUpdate ( )
protectedvirtual

Run each frame to determine and execute move.

Reimplemented in PlatformerPro.SequenceDrivenEnemy, and PlatformerPro.RotatingEnemy.

◆ HandleWillExitScene()

virtual void PlatformerPro.Enemy.HandleWillExitScene ( object  sender,
SceneEventArgs  e 
)
protectedvirtual

Handles the will exit scene event. used to save data.

◆ Heal()

virtual void PlatformerPro.Enemy.Heal ( int  amount)
virtual

Heal the enemy by the specified amount.

Parameters
amountAmount.

◆ HitCharacter()

virtual void PlatformerPro.Enemy.HitCharacter ( Character  character,
DamageInfo  info 
)
virtual

Called when the enemy hits the character causing damage.

Parameters
characterCharacter.
infoDamage info.

◆ IsColliderIgnored()

virtual bool PlatformerPro.Enemy.IsColliderIgnored ( Collider2D  collider)
virtual

Check if a given collider should be ignored in collisions.

Returns
true if this instance is ignoring he specified collider; otherwise, false.
Parameters
colliderCollider.

Implements PlatformerPro.IMob.

◆ MakeInvulnerable()

virtual void PlatformerPro.Enemy.MakeInvulnerable ( float  invulnerableTime)
virtual

Makes the enemy invulnerable for the given number of settings.

Parameters
invulnerableTimeInvulnerable time in seconds.

◆ MakeVulnerable()

virtual void PlatformerPro.Enemy.MakeVulnerable ( )
virtual

Makes the enemy vulnerable.

◆ MovementComplete()

virtual void PlatformerPro.Enemy.MovementComplete ( )
virtual

Called when a compeletable movement finishes.

Reimplemented in PlatformerPro.SequenceDrivenEnemy.

◆ OnChangeAnimationState() [1/3]

virtual void PlatformerPro.Enemy.OnChangeAnimationState ( )
virtual

Raises the change animation state event. This version is public as it just triggers an update not a change.

◆ OnChangeAnimationState() [2/3]

virtual void PlatformerPro.Enemy.OnChangeAnimationState ( AnimationState  state,
AnimationState  previousState 
)
protectedvirtual

Raises the change animation state event.

Parameters
stateCurrent state.
previousStatePrevious state.

◆ OnChangeAnimationState() [3/3]

virtual void PlatformerPro.Enemy.OnChangeAnimationState ( AnimationState  state,
AnimationState  previousState,
int  priority 
)
protectedvirtual

Raises the change animation state event.

Parameters
stateCurrent state.
previousStatePrevious state.
priorityAnimaton state priority.

◆ OnCharacterDamaged()

virtual void PlatformerPro.Enemy.OnCharacterDamaged ( DamageInfo  info)
protectedvirtual

Raises the hit character event.

Parameters
infoDamage info.

◆ OnCollided()

virtual void PlatformerPro.Enemy.OnCollided ( DamageInfo  info)
protectedvirtual

Raises the collided event.

Parameters
infoInfo.

◆ OnDamaged()

virtual void PlatformerPro.Enemy.OnDamaged ( DamageInfo  info)
protectedvirtual

Raises the damaged event.

Parameters
infoInfo.

◆ OnDied()

virtual void PlatformerPro.Enemy.OnDied ( DamageInfo  info)
protectedvirtual

Raises the died event.

Parameters
infoInfo.

◆ OnEnemyAIEvent()

virtual void PlatformerPro.Enemy.OnEnemyAIEvent ( string  eventName)
virtual

Raises an enemy AI event.

◆ OnMovementHasCompleted()

virtual void PlatformerPro.Enemy.OnMovementHasCompleted ( )
protectedvirtual

Raises the MovementHasCompleted Event.

◆ PostInit()

override void PlatformerPro.Enemy.PostInit ( )
protectedvirtual

Set up the character

Reimplemented from PlatformerPro.PersistableObject.

Reimplemented in PlatformerPro.SequenceDrivenEnemy, and PlatformerPro.RotatingEnemy.

◆ RemoveAnimationOverride()

virtual void PlatformerPro.Enemy.RemoveAnimationOverride ( string  overrideState)
virtual

Removes an animation override. NOTE: Currently only one override is supported at a time.

Parameters
overrideStateOverride State, will be removed if it matches current value.

◆ RemoveIgnoredCollider()

virtual void PlatformerPro.Enemy.RemoveIgnoredCollider ( Collider2D  collider)
virtual

Removes a collider from the list of ignored colliders.

Parameters
colliderCollider.

◆ Reset()

virtual void PlatformerPro.Enemy.Reset ( )
virtual

Reset this instance.

◆ SavePersistenceData()

virtual void PlatformerPro.Enemy.SavePersistenceData ( )
protectedvirtual

Gets the extra persistence data which is used to save enemy state. NOTE: Generally you should override ExtraPersistenceData to save a different set of data.

◆ SetHealth()

virtual void PlatformerPro.Enemy.SetHealth ( int  amount)
virtual

Heal the enemy by the specified amount.

Parameters
amountAmount.

◆ SetPersistenceDefaults()

override void PlatformerPro.Enemy.SetPersistenceDefaults ( )
protectedvirtual

Sets the persistence defaults.

Reimplemented from PlatformerPro.PersistableObject.

◆ SetVelocityX()

virtual void PlatformerPro.Enemy.SetVelocityX ( float  x)
virtual

Sets X velocity.

Parameters
xThe new x speed.

Implements PlatformerPro.IMob.

◆ SetVelocityY()

virtual void PlatformerPro.Enemy.SetVelocityY ( float  y)
virtual

Sets Y velocity.

Parameters
xThe new y speed.

Implements PlatformerPro.IMob.

◆ SwitchColliders()

virtual void PlatformerPro.Enemy.SwitchColliders ( )
protectedvirtual

Switches left and right collider direction and flips position of all colliders about y axis.

◆ SwitchDirection()

virtual void PlatformerPro.Enemy.SwitchDirection ( )
virtual

Call this to switch the direction of all associated movements.

◆ Translate()

virtual void PlatformerPro.Enemy.Translate ( float  x,
float  y,
bool  applyYTransformsInWorldSpace 
)
virtual

Translate the character by the supplied amount.

Parameters
xThe x amount.
yThe y amount.
applyYTransformsInWorldSpaceShould Y transforms be in world space instead of realtive to the character position? Default is true.

Implements PlatformerPro.IMob.

Member Data Documentation

◆ Active

bool PlatformerPro.Enemy.Active = true
protected

Is this enemy active?

◆ animationEventArgs

AnimationEventArgs PlatformerPro.Enemy.animationEventArgs
protected

A cached animation event args that we update so we don't need to allocate.

◆ animationState

AnimationState PlatformerPro.Enemy.animationState
protected

The enemies current animation state.

◆ characterCanFall

bool PlatformerPro.Enemy.characterCanFall

Does the character fall if there is no platform below it?

◆ characterForGravity

Character PlatformerPro.Enemy.characterForGravity
protected

If gravity comes from a character reference this is the gravity we are using.

◆ collidersForSwitching

Transform [] PlatformerPro.Enemy.collidersForSwitching
protected

If we switch colliders when the character turns this is the list of transforms of Collider2D's to switch.

◆ continueMovementOnDamage

bool PlatformerPro.Enemy.continueMovementOnDamage

If true the movement system will control damage. Generally used for Graph based enemy AI.

◆ continueMovementOnFall

bool PlatformerPro.Enemy.continueMovementOnFall

Should movements keep moving while falling.

◆ currentFacingDirection

int PlatformerPro.Enemy.currentFacingDirection
protected

The direction currently faced. Used for switch collider calculations and for AI that needs actual facing direction.

◆ currentTarget

Character PlatformerPro.Enemy.currentTarget
protected

The current target.

◆ customGravity

float PlatformerPro.Enemy.customGravity = -15f

Custom gravity.

◆ damageEventArgs

DamageInfoEventArgs PlatformerPro.Enemy.damageEventArgs
protected

Cached copy of damage event args to save on allocations.

◆ damageMovement

EnemyMovement PlatformerPro.Enemy.damageMovement
protected

Reference to the class that controls the enemy damage movement.

◆ damageTime

float PlatformerPro.Enemy.damageTime = 0.5f

How long the enemy in the damaged movement after being hit.

◆ deathMovement

EnemyMovement PlatformerPro.Enemy.deathMovement
protected

Reference to the class that controls the enemy death movement.

◆ DefaultSideLookAhead

const float PlatformerPro.Enemy.DefaultSideLookAhead = 0.05f
staticprotected

Default side look ahead.

◆ detectSideCollisions

bool PlatformerPro.Enemy.detectSideCollisions

Does the character detect side collisions?

◆ enemyAi

EnemyAI PlatformerPro.Enemy.enemyAi
protected

The enemy ai (can be null meaning only movements will control the character).

◆ enemyInteractsWithPlatforms

bool PlatformerPro.Enemy.enemyInteractsWithPlatforms

Does this enemy interact with platforms?

◆ enemyPersistenceImplementation

PersistableEnemyType PlatformerPro.Enemy.enemyPersistenceImplementation

How do we implement the persistence settings.

◆ feetHeight

float PlatformerPro.Enemy.feetHeight

If the cahracter can fall where are its feet in y?

◆ feetWidth

float PlatformerPro.Enemy.feetWidth

If the cahracter can fall where are its feet in x (offset from centre)?

◆ geometryLayerMask

LayerMask PlatformerPro.Enemy.geometryLayerMask

The layers that are considered when working out collisions. i.e. the things we can't move through.

See also
Character.layerMask

◆ grounded

bool PlatformerPro.Enemy.grounded
protected

Is the enemy grounded.

◆ groundedLookAhead

float PlatformerPro.Enemy.groundedLookAhead

How far do we look ahead when determining if we are grounded.

◆ health

int PlatformerPro.Enemy.health = 1

Enemies health.

◆ ignoredColliders

HashSet<Collider2D> PlatformerPro.Enemy.ignoredColliders
protected

A list of colliders to ingore during collisions.

◆ ignoredSlope

float PlatformerPro.Enemy.ignoredSlope
protected

The angle of the ignored slope.

◆ invulnerableTime

float PlatformerPro.Enemy.invulnerableTime = 0.5f

How long the enemy is invulnerable to damage after being hit.

◆ invulnerableTimer

float PlatformerPro.Enemy.invulnerableTimer = -1.0f
protected

Timer for invulnerability. Character is invulnerable when this is greater than zero.

◆ leftFeetCollisions

RaycastHit2D [] PlatformerPro.Enemy.leftFeetCollisions

Stores left foot collissions.

◆ leftFoot

NoAllocationSmartFeetcast PlatformerPro.Enemy.leftFoot
protected

The left foot collider.

◆ leftSide

NoAllocationSmartSidecast PlatformerPro.Enemy.leftSide
protected

The left side collider.

◆ MAX_ENEMY_SLOPE

const float PlatformerPro.Enemy.MAX_ENEMY_SLOPE = 60.0f
staticprotected

Max slope an enemy will calcualte/walk on

◆ movement

EnemyMovement PlatformerPro.Enemy.movement
protected

Reference to the class that controls the enemy movement.

◆ myTransform

Transform PlatformerPro.Enemy.myTransform
protected

Cached copy of the enemies transform.

◆ overrideState

string PlatformerPro.Enemy.overrideState
protected

The enemies current animation overridestate.

◆ parentPlatform

Platform PlatformerPro.Enemy.parentPlatform
protected

Stores the aprent platform if we have one.

◆ platformCollisionArgs

PlatformCollisionArgs PlatformerPro.Enemy.platformCollisionArgs
protected

The platform collision arguments.

◆ rightFeetCollisions

RaycastHit2D [] PlatformerPro.Enemy.rightFeetCollisions

Stores right foot collissions.

◆ rightFoot

NoAllocationSmartFeetcast PlatformerPro.Enemy.rightFoot
protected

The right foot collider.

◆ rightSide

NoAllocationSmartSidecast PlatformerPro.Enemy.rightSide
protected

The right side collider.

◆ sideHeight

float PlatformerPro.Enemy.sideHeight

The height of the side collisions.

◆ sideWidth

float PlatformerPro.Enemy.sideWidth

The width of the side collisions.

◆ startFacingDirection

int PlatformerPro.Enemy.startFacingDirection = 1

The facing direction on start. Typically 1 or -1.

◆ switchCollidersOnDirectionChange

bool PlatformerPro.Enemy.switchCollidersOnDirectionChange

Should we switch colliders when the enemy changes direction (used for asymmetric characters).

◆ switchDirectionOnSideHit

bool PlatformerPro.Enemy.switchDirectionOnSideHit

If the charcter runs in to the wall should it switch direciton on all movements?

◆ terminalVelocity

float PlatformerPro.Enemy.terminalVelocity = -15f

Maximum fall speed (note that any individual movement may override this if it wants to).

◆ useCharacterGravity

bool PlatformerPro.Enemy.useCharacterGravity

Should we use the characters gravity or a custom one.

◆ useDefaultPersistence

bool PlatformerPro.Enemy.useDefaultPersistence

Does this Item get persistence defaults form the Game manager?

Property Documentation

◆ AI

virtual EnemyAI PlatformerPro.Enemy.AI
get

Gets the enemy AI or null if there is no AI.

The enemy A.

◆ AnimationState

virtual AnimationState PlatformerPro.Enemy.AnimationState
getprotected set

The enemies current animation state.

◆ CurrentMovement

virtual EnemyMovement PlatformerPro.Enemy.CurrentMovement
get

Gets the current movement or null if no movement is acgtive (for example when falling with continueMovementOnFall off).

◆ CurrentTarget

virtual Character PlatformerPro.Enemy.CurrentTarget
getset

The current target.

◆ CurrentTargetTransform

virtual Transform PlatformerPro.Enemy.CurrentTargetTransform
get

The current targets position or enemies position if no target found.

◆ ExtraPersistenceData

override string PlatformerPro.Enemy.ExtraPersistenceData
getprotected

Gets the extra persistence data.

The extra persistence data.

◆ ExtraPersistenceDataAsObject

virtual EnemyPersistenceData PlatformerPro.Enemy.ExtraPersistenceDataAsObject
get

Gets the extra persistence data in object form which is used to save enemy state.

◆ FacingDirection

virtual int PlatformerPro.Enemy.FacingDirection
get

Returns the direction the enemy is facing. 0 for none, 1 for right, -1 for left.

◆ Friction

virtual float PlatformerPro.Enemy.Friction
getset

Gets the friction.

The friction.

◆ Gravity

virtual float? PlatformerPro.Enemy.Gravity
get

Gravity for this enemy

◆ Grounded

virtual bool PlatformerPro.Enemy.Grounded
get

Returns true if we are grounded or false otherwise.

◆ GroundedLeft

virtual bool PlatformerPro.Enemy.GroundedLeft
getprotected set

Returns true if we are grounded on the left foot.

◆ GroundedRight

virtual bool PlatformerPro.Enemy.GroundedRight
getprotected set

Returns true if we are grounded on the left foot.

◆ GroundLayer

virtual int PlatformerPro.Enemy.GroundLayer
getprotected set

If grounded this is the layer of the ground. Undefined if not grounded.

◆ Header

override string PlatformerPro.Enemy.Header
get

◆ IgnoredSlope

virtual float PlatformerPro.Enemy.IgnoredSlope
getset

Gets the ignored slope. The ignored slope is used primary for internal physics calculations and is the largest slope that was ignored by the side colliders last frame.

◆ IsInvulnerable

virtual bool PlatformerPro.Enemy.IsInvulnerable
get

Is the character currently invulnerable?

The character.

◆ LastFacedDirection

virtual int? PlatformerPro.Enemy.LastFacedDirection
get

Returns the direction the character is facing, but if direction is currently 0 instead returns the direction last faced.

◆ MinSideAngle

virtual float PlatformerPro.Enemy.MinSideAngle
get

Gets the minimum angle at which geometry is considered a wall.

◆ OverrideState

virtual string PlatformerPro.Enemy.OverrideState
getprotected set

The enemies current animation override state.

◆ PreviousRotation

virtual float PlatformerPro.Enemy.PreviousRotation
getset

The characters rotation in the previous frame.

◆ PreviousVelocity

virtual Vector2 PlatformerPro.Enemy.PreviousVelocity
getset

The characters velocity in the previous frame.

◆ SlopeActualRotation

virtual float PlatformerPro.Enemy.SlopeActualRotation
get

If slopes are on this is the rotation we are currently on.

◆ SlopeTargetRotation

virtual float PlatformerPro.Enemy.SlopeTargetRotation
getprotected set

If slopes are on this is the rotation we are rotating towards.

◆ StartingHealth

int PlatformerPro.Enemy.StartingHealth
getprotected set

Health the enemy started with

◆ State

virtual EnemyState PlatformerPro.Enemy.State
getprotected set

The current AI state.

The state.

◆ Transform

virtual Transform PlatformerPro.Enemy.Transform
get

Gets cache copy of the transform.

◆ Velocity

virtual Vector2 PlatformerPro.Enemy.Velocity
getset

The characters velocity.

◆ ZLayer

virtual int PlatformerPro.Enemy.ZLayer
getset

Gets or sets the characters current z layer.

Event Documentation

◆ ChangeAnimationState

System.EventHandler<AnimationEventArgs> PlatformerPro.Enemy.ChangeAnimationState

Event for anmation state changes.

◆ CharacterDamaged

System.EventHandler<DamageInfoEventArgs> PlatformerPro.Enemy.CharacterDamaged

Event for damaging a character.

◆ Collided

System.EventHandler<DamageInfoEventArgs> PlatformerPro.Enemy.Collided

Event for being hit but not damaged.

◆ Damaged

System.EventHandler<DamageInfoEventArgs> PlatformerPro.Enemy.Damaged

Event for damage.

◆ Died

System.EventHandler<DamageInfoEventArgs> PlatformerPro.Enemy.Died

Event for death.

◆ EnemyAIEvent

System.EventHandler<EnemyAIEventArgs> PlatformerPro.Enemy.EnemyAIEvent

A generic event sent by an enemy AI.

◆ MovementHasCompleted

System.EventHandler<EmptyEventArgs> PlatformerPro.Enemy.MovementHasCompleted

Event sent when current movement completes.


The documentation for this class was generated from the following file: