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

Enemy which can rotate. More...

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

Public Member Functions

override void ApplyFeetCollisions ()
 Applies the feet collisions. More...
 
- Public Member Functions inherited from PlatformerPro.Enemy
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 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

float rotationSpeed = 360.0f
 Characters rotation speed. More...
 
float maxSlopeRotation = 180.0f
 The max slope rotation in degrees. More...
 
float minSideAngle = 60.0f
 Minimum angle that will be considered a wall. More...
 
- Public Attributes inherited from PlatformerPro.Enemy
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

override void PostInit ()
 Set up the character More...
 
override void DoUpdate ()
 Run each frame to determine and execute move. More...
 
virtual void CalculateTargetRotation ()
 Use the feet colliders to determine the target rotation. More...
 
virtual void DoRotation ()
 Rotate towards the target rotation. More...
 
- Protected Member Functions inherited from PlatformerPro.Enemy
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...
 
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

NoAllocationSmartFeetcast middleFoot
 The middle foot collider. More...
 
float slope
 Current slope angle. More...
 
RaycastHit2D leftFootCollision
 The left foot collision. More...
 
RaycastHit2D rightFootCollision
 The right foot collision. More...
 
RaycastHit2D middleFootCollision
 
int rotationPoint
 
Collider2D currentGround
 
- Protected Attributes inherited from PlatformerPro.Enemy
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...
 

Properties

override float SlopeActualRotation [get]
 If slopes are on this is the rotation we are currently on. More...
 
override float MinSideAngle [get]
 Gets the minimum angle at which geometry is considered a wall. More...
 
- Properties inherited from PlatformerPro.Enemy
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...
 

Additional Inherited Members

- Static Protected Attributes inherited from PlatformerPro.Enemy
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...
 
- Events inherited from PlatformerPro.Enemy
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

Enemy which can rotate.

Member Function Documentation

◆ ApplyFeetCollisions()

override void PlatformerPro.RotatingEnemy.ApplyFeetCollisions ( )
virtual

Applies the feet collisions.

Reimplemented from PlatformerPro.Enemy.

◆ CalculateTargetRotation()

virtual void PlatformerPro.RotatingEnemy.CalculateTargetRotation ( )
protectedvirtual

Use the feet colliders to determine the target rotation.

◆ DoRotation()

virtual void PlatformerPro.RotatingEnemy.DoRotation ( )
protectedvirtual

Rotate towards the target rotation.

◆ DoUpdate()

override void PlatformerPro.RotatingEnemy.DoUpdate ( )
protectedvirtual

Run each frame to determine and execute move.

Reimplemented from PlatformerPro.Enemy.

◆ PostInit()

override void PlatformerPro.RotatingEnemy.PostInit ( )
protectedvirtual

Set up the character

Reimplemented from PlatformerPro.Enemy.

Member Data Documentation

◆ currentGround

Collider2D PlatformerPro.RotatingEnemy.currentGround
protected

◆ leftFootCollision

RaycastHit2D PlatformerPro.RotatingEnemy.leftFootCollision
protected

The left foot collision.

◆ maxSlopeRotation

float PlatformerPro.RotatingEnemy.maxSlopeRotation = 180.0f

The max slope rotation in degrees.

◆ middleFoot

NoAllocationSmartFeetcast PlatformerPro.RotatingEnemy.middleFoot
protected

The middle foot collider.

◆ middleFootCollision

RaycastHit2D PlatformerPro.RotatingEnemy.middleFootCollision
protected

◆ minSideAngle

float PlatformerPro.RotatingEnemy.minSideAngle = 60.0f

Minimum angle that will be considered a wall.

◆ rightFootCollision

RaycastHit2D PlatformerPro.RotatingEnemy.rightFootCollision
protected

The right foot collision.

◆ rotationPoint

int PlatformerPro.RotatingEnemy.rotationPoint
protected

◆ rotationSpeed

float PlatformerPro.RotatingEnemy.rotationSpeed = 360.0f

Characters rotation speed.

◆ slope

float PlatformerPro.RotatingEnemy.slope
protected

Current slope angle.

Property Documentation

◆ MinSideAngle

override float PlatformerPro.RotatingEnemy.MinSideAngle
get

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

◆ SlopeActualRotation

override float PlatformerPro.RotatingEnemy.SlopeActualRotation
get

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


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