Class PlayerBehaviourCore
It is responsible for interconnecting all behaviors; storing global properties shared between behaviors; Collecting powerups
Inheritance
Object
Component
Behaviour
MonoBehaviour
PlayerBehaviourCore
Inherited Members
MonoBehaviour.IsInvoking()
MonoBehaviour.CancelInvoke()
MonoBehaviour.StopCoroutine(Coroutine)
MonoBehaviour.StopAllCoroutines()
MonoBehaviour.useGUILayout
MonoBehaviour.runInEditMode
Behaviour.enabled
Behaviour.isActiveAndEnabled
Component.GetComponent<T>()
Component.TryGetComponent<T>(out T)
Component.GetComponentInChildren<T>()
Component.GetComponentsInChildren<T>()
Component.GetComponentInParent<T>()
Component.GetComponentsInParent<T>()
Component.GetComponents<T>()
Component.transform
Component.gameObject
Component.tag
Object.GetInstanceID()
Object.GetHashCode()
Object.Instantiate(Object, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion, Transform)
Object.Instantiate(Object)
Object.Instantiate(Object, Transform)
Object.Instantiate<T>(T)
Object.Instantiate<T>(T, Vector3, Quaternion)
Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
Object.Instantiate<T>(T, Transform)
Object.Destroy(Object)
Object.DestroyImmediate(Object)
Object.DontDestroyOnLoad(Object)
Object.DestroyObject(Object)
Object.FindObjectsOfType<T>()
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindObjectOfType<T>()
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Object.ToString()
Object.name
Object.hideFlags
Assembly: Assembly-CSharp.dll
Syntax
public class PlayerBehaviourCore : MonoBehaviour, IPlayerBehaviourCore
Fields
|
Edit this page
View Source
_rigidbody
Declaration
public Rigidbody2D _rigidbody
Field Value
| Type |
Description |
| Rigidbody2D |
|
|
Edit this page
View Source
bodyAnimator
Declaration
public Animator bodyAnimator
Field Value
| Type |
Description |
| Animator |
|
|
Edit this page
View Source
bodyCollider
Declaration
public CircleCollider2D bodyCollider
Field Value
| Type |
Description |
| CircleCollider2D |
|
|
Edit this page
View Source
bodySpriteRenderer
Declaration
public SpriteRenderer bodySpriteRenderer
Field Value
| Type |
Description |
| SpriteRenderer |
|
|
Edit this page
View Source
debugAnimatorCrossFades
Declaration
public bool debugAnimatorCrossFades
Field Value
|
Edit this page
View Source
disableControls
Declaration
[Header("General Tweaks")]
[SerializeField]
public bool disableControls
Field Value
|
Edit this page
View Source
Declaration
[Header("Components")]
public PlayerInputBase input
Field Value
|
Edit this page
View Source
playerNumber
Declaration
[Header("Debug")]
protected int playerNumber
Field Value
|
Edit this page
View Source
powerUps
Declaration
[Header("Powerups")]
public List<EPowerUp> powerUps
Field Value
Methods
|
Edit this page
View Source
AddOrConsumePowerUp(EPowerUp)
Declaration
public virtual void AddOrConsumePowerUp(EPowerUp powerUp)
Parameters
|
Edit this page
View Source
ConsumePowerup(EPowerUp)
Consume consumable powerups and return if this is consumable. There are consumable and stackable powerups. The consumable ones execute a method and are discarted, while the others are added to powerup list
Declaration
public virtual bool ConsumePowerup(EPowerUp powerUp)
Parameters
Returns
|
Edit this page
View Source
ControlIsDisabled()
checks if the character's control is enabled.. Disabling character control is useful in some scenes. Also, if the character is using a mount, their control is disabled so that they remain on top of the mount.
Declaration
public bool ControlIsDisabled()
Returns
| Type |
Description |
| bool |
disabled bool
|
|
Edit this page
View Source
CrossFade(string, float)
Triggers crossfade in the animator. This is used by the Behavior components.
Declaration
public void CrossFade(string stateName, float normalizedTransitionDuration)
Parameters
| Type |
Name |
Description |
| string |
stateName |
Animator state name
|
| float |
normalizedTransitionDuration |
Specify time
|
|
Edit this page
View Source
DisableControls(bool)
Enables or disables the control
Declaration
public void DisableControls(bool disable)
Parameters
| Type |
Name |
Description |
| bool |
disable |
disable
|
|
Edit this page
View Source
GetAnimator()
Get Animator, some components need access to the animator to control animations.
Declaration
public Animator GetAnimator()
Returns
| Type |
Description |
| Animator |
animator
|
|
Edit this page
View Source
GetCollider()
Obtains the input, which is the intermediary through which control commands are received.
Declaration
public CircleCollider2D GetCollider()
Returns
| Type |
Description |
| CircleCollider2D |
Collider
|
|
Edit this page
View Source
Get sprite, some components need access to the animator to control sprites.
Declaration
public PlayerInputBase GetInput()
Returns
|
Edit this page
View Source
GetPowerUps()
Get powerups. This exists because it's not possible to implement this property in the interface and this be visible in the inspector at same time.
Declaration
public virtual List<EPowerUp> GetPowerUps()
Returns
|
Edit this page
View Source
GetRigidbody()
Get Collider, some components need access to the animator to control collisions.
Declaration
public Rigidbody2D GetRigidbody()
Returns
| Type |
Description |
| Rigidbody2D |
rigdbody 2D
|
|
Edit this page
View Source
GetSpriteRenderer()
Gets the sprite renderer. This exists because it's not possible to implement this property in the interface and this be visible in the inspector at same time.
Declaration
public SpriteRenderer GetSpriteRenderer()
Returns
| Type |
Description |
| SpriteRenderer |
SpriteRenderer
|
|
Edit this page
View Source
InvokeOnAddPowerup(EPowerUp)
Since the derived class cannot directly invoke an event from the basclass, we need this workaround
Declaration
protected void InvokeOnAddPowerup(EPowerUp powerUp)
Parameters
|
Edit this page
View Source
IsConsumablePowerup(EPowerUp)
Declaration
public virtual bool IsConsumablePowerup(EPowerUp powerUp)
Parameters
Returns
|
Edit this page
View Source
OnTriggerEnter2D(Collider2D)
Declaration
public void OnTriggerEnter2D(Collider2D col)
Parameters
| Type |
Name |
Description |
| Collider2D |
col |
|
|
Edit this page
View Source
RemovePowerup(EPowerUp)
Declaration
public void RemovePowerup(EPowerUp powerUp)
Parameters
|
Edit this page
View Source
Set parent. This is used by the Mount behaviour
Declaration
public void SetParent(Transform parentTransform)
Parameters
| Type |
Name |
Description |
| Transform |
parentTransform |
|
|
Edit this page
View Source
SetPlayerNumber(int)
Set the player number. This is defined by the level manager.
Declaration
public void SetPlayerNumber(int number)
Parameters
| Type |
Name |
Description |
| int |
number |
|
|
Edit this page
View Source
SetPowerUps(List<EPowerUp>)
Set the powerup list. This is used by the level manager when another level starts so that inherits the powerups acquired in a previous level.
Declaration
public void SetPowerUps(List<EPowerUp> powerUps)
Parameters
Events
|
Edit this page
View Source
onAddPowerUp
Some components need to know when a specific powerup was added
Declaration
public event Action<EPowerUp, PlayerBehaviourCore> onAddPowerUp
Event Type
|
Edit this page
View Source
onRemovePowerUp
Some components need to know when a specific powerup is removed
Declaration
public event Action<EPowerUp> onRemovePowerUp
Event Type
Implements
Extension Methods