![]() |
Platformer Pro
2.3.2
A platform game kit for Unity.
|
An enemy that has a sequence of moves which happen in order (can loop). More...
Public Member Functions | |
virtual void | ChangeState (int newState) |
Changes the state. You can also call from your own code to force a state change. More... | |
virtual void | ChangePhase (int newPhase, int newState) |
Changes the phase. You can also call from your own code to froce phase change. More... | |
override void | Damage (DamageInfo info) |
Damage the enemy with the specified damage information. More... | |
override void | MovementComplete () |
Called when the enemies current attack finished More... | |
![]() | |
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 | Reset () |
Reset this instance. 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... | |
![]() | |
void | SetPersistenceState (bool state) |
Sets the persistence state. More... | |
void | SetPersistenceState (bool state, string extraPersistenceData) |
Sets the persistence state, overriding extra persistence data More... | |
![]() | |
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 | |
float | sightDistance = 5.0f |
How far can the enemy see? More... | |
float | sightYOffset |
Y position of the characters 'eyes'. More... | |
LayerMask | sightLayers |
Layers to check for obstacle and characters. More... | |
float | hearingRadius = 1.0f |
Range of the proximity sense. More... | |
Vector2 | hearingOffset |
Centre point of the proximity sense. More... | |
LayerMask | hearingLayers |
Layers to check for proximity sense. More... | |
float | maxTargetDistance |
LDistance at which the target is "lost". More... | |
List< EnemyPhase > | phaseInfo |
List of the states in the sequence. More... | |
List< EnemyStateInfo > | globalGotos |
List of GOTO conditions that are evaluated every loop. More... | |
![]() | |
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... | |
![]() | |
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 | OnPhaseEnter () |
Raises the phase enter event. More... | |
virtual void | OnPhaseExit () |
Raises the phase exit event. More... | |
virtual void | OnStateEnter () |
Raises the state enter event. More... | |
virtual void | OnStateExit () |
Raises the state exit event. More... | |
override void | PostInit () |
Set up the character More... | |
override void | DoUpdate () |
Run each frame to determine and execute move. More... | |
override void | DecideOnNextMovement () |
Decides on the next movement. Here we use the state sequence. More... | |
virtual bool | CheckStateExitCondition (EnemyStateInfo currentState) |
Checks if the states exit condition has been met. More... | |
virtual bool | CheckPhaseExitCondition (EnemyPhase currentPhase) |
Checks if the phase exit condition has been met. More... | |
virtual bool | CheckForCharacter () |
Try to find a character by looking and listening. More... | |
virtual bool | See () |
Look for a character. More... | |
virtual bool | Hear () |
Listen for a character. More... | |
![]() | |
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 | 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 | 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... | |
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... | |
![]() | |
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 | |
int | currentPhase |
The currently active phase. More... | |
int | currentState |
The currently active state. More... | |
float | phaseTimer |
Stores how long we have been in current phase. If the same state is played multiple times this tracks the time in the CURRENT iteration. More... | |
int | phaseLoopCount |
Tracks how many times we have played the current phase. More... | |
int | phaseHitCount |
Stores the number of times we have been damaged while in current phase. More... | |
float | stateTimer |
Stores how long we have been in current state. If the same state is played multiple times this tracks the time in the CURRENT iteration. More... | |
bool | stateMovementComplete |
Stores the completion state of current move. More... | |
int | stateHitCount |
Stores the number of times we have been damaged while in current state. More... | |
int | infiniteLoopCheck |
Tracks how many times we have changed state in a frame, if its too many this is likely a loop. More... | |
Collider2D[] | proximityColliders |
Used to store results of hearing overlap call. More... | |
bool | willExitState |
Tracks if exit condition for state has been met. More... | |
bool | willExitPhase |
Tracks if exit condition for phase has been met. More... | |
bool | hasRunCheckForCharacter |
Track if we have run the check for player call so we don't eat resources by running it more than once a frame. More... | |
bool | checkForCharacterResult |
Result of the last check for character. More... | |
CharacterHealth | currentTargetHealth |
Cached character health for current target. More... | |
float | startingHealth |
Capture starting health in case we need to calcualte based on health percentage. More... | |
![]() | |
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 int | MaxStateChanges = 20 |
Maximum number of state changes in a frame. More... | |
![]() | |
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 | |
int | CurrentPhase [get] |
Gets the index of the current phase. More... | |
int | CurrentState [get] |
Gets the index of the current state. More... | |
![]() | |
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... | |
![]() | |
virtual string | ExtraPersistenceData [get] |
Gets the extra persistence data. More... | |
![]() | |
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... | |
![]() | |
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< SequenceEnemyPhaseEventArgs > | PhaseEnter |
Event for anmation state changes. More... | |
System.EventHandler< SequenceEnemyPhaseEventArgs > | PhaseExit |
Event for damage. More... | |
System.EventHandler< StateEventArgs > | StateEnter |
Event for anmation state changes. More... | |
System.EventHandler< StateEventArgs > | StateExit |
Event for state exit. More... | |
![]() | |
System.EventHandler< AnimationEventArgs > | ChangeAnimationState |
Event for anmation state changes. More... | |
System.EventHandler< DamageInfoEventArgs > | Damaged |
Event for damage. More... | |
System.EventHandler< DamageInfoEventArgs > | Died |
Event for death. More... | |
System.EventHandler< DamageInfoEventArgs > | Collided |
Event for being hit but not damaged. More... | |
System.EventHandler< DamageInfoEventArgs > | CharacterDamaged |
Event for damaging a character. More... | |
System.EventHandler< EmptyEventArgs > | MovementHasCompleted |
Event sent when current movement completes. More... | |
System.EventHandler< EnemyAIEventArgs > | EnemyAIEvent |
A generic event sent by an enemy AI. More... | |
![]() | |
System.EventHandler< AnimationEventArgs > | ChangeAnimationState |
Event for anmation state changes. More... | |
An enemy that has a sequence of moves which happen in order (can loop).
|
virtual |
Changes the phase. You can also call from your own code to froce phase change.
newPhase | New phase. |
newState | New state. |
|
virtual |
Changes the state. You can also call from your own code to force a state change.
newState | New state index. |
|
protectedvirtual |
Try to find a character by looking and listening.
true
, if for character was checked, false
otherwise.
|
protectedvirtual |
Checks if the phase exit condition has been met.
true
, if exit condition was checked, false
otherwise.
|
protectedvirtual |
Checks if the states exit condition has been met.
true
, if exit condition was checked, false
otherwise.enemy | Enemy. |
stateTImer | Time we have been in this state. |
|
virtual |
Damage the enemy with the specified damage information.
info | The damage info. |
Reimplemented from PlatformerPro.Enemy.
|
protectedvirtual |
Decides on the next movement. Here we use the state sequence.
Reimplemented from PlatformerPro.Enemy.
|
protectedvirtual |
Run each frame to determine and execute move.
Reimplemented from PlatformerPro.Enemy.
|
protectedvirtual |
Listen for a character.
|
virtual |
Called when the enemies current attack finished
Reimplemented from PlatformerPro.Enemy.
|
protectedvirtual |
Raises the phase enter event.
|
protectedvirtual |
Raises the phase exit event.
|
protectedvirtual |
Raises the state enter event.
|
protectedvirtual |
Raises the state exit event.
|
protectedvirtual |
Set up the character
Reimplemented from PlatformerPro.Enemy.
|
protectedvirtual |
Look for a character.
|
protected |
Result of the last check for character.
|
protected |
The currently active phase.
|
protected |
The currently active state.
|
protected |
Cached character health for current target.
List<EnemyStateInfo> PlatformerPro.SequenceDrivenEnemy.globalGotos |
List of GOTO conditions that are evaluated every loop.
|
protected |
Track if we have run the check for player call so we don't eat resources by running it more than once a frame.
LayerMask PlatformerPro.SequenceDrivenEnemy.hearingLayers |
Layers to check for proximity sense.
Vector2 PlatformerPro.SequenceDrivenEnemy.hearingOffset |
Centre point of the proximity sense.
float PlatformerPro.SequenceDrivenEnemy.hearingRadius = 1.0f |
Range of the proximity sense.
|
protected |
Tracks how many times we have changed state in a frame, if its too many this is likely a loop.
|
staticprotected |
Maximum number of state changes in a frame.
float PlatformerPro.SequenceDrivenEnemy.maxTargetDistance |
LDistance at which the target is "lost".
|
protected |
Stores the number of times we have been damaged while in current phase.
List<EnemyPhase> PlatformerPro.SequenceDrivenEnemy.phaseInfo |
List of the states in the sequence.
|
protected |
Tracks how many times we have played the current phase.
|
protected |
Stores how long we have been in current phase. If the same state is played multiple times this tracks the time in the CURRENT iteration.
|
protected |
Used to store results of hearing overlap call.
float PlatformerPro.SequenceDrivenEnemy.sightDistance = 5.0f |
How far can the enemy see?
LayerMask PlatformerPro.SequenceDrivenEnemy.sightLayers |
Layers to check for obstacle and characters.
float PlatformerPro.SequenceDrivenEnemy.sightYOffset |
Y position of the characters 'eyes'.
|
protected |
Capture starting health in case we need to calcualte based on health percentage.
|
protected |
Stores the number of times we have been damaged while in current state.
|
protected |
Stores the completion state of current move.
|
protected |
Stores how long we have been in current state. If the same state is played multiple times this tracks the time in the CURRENT iteration.
|
protected |
Tracks if exit condition for phase has been met.
|
protected |
Tracks if exit condition for state has been met.
|
get |
Gets the index of the current phase.
|
get |
Gets the index of the current state.
System.EventHandler<SequenceEnemyPhaseEventArgs> PlatformerPro.SequenceDrivenEnemy.PhaseEnter |
Event for anmation state changes.
System.EventHandler<SequenceEnemyPhaseEventArgs> PlatformerPro.SequenceDrivenEnemy.PhaseExit |
Event for damage.
System.EventHandler<StateEventArgs> PlatformerPro.SequenceDrivenEnemy.StateEnter |
Event for anmation state changes.
System.EventHandler<StateEventArgs> PlatformerPro.SequenceDrivenEnemy.StateExit |
Event for state exit.