TopDown Engine  v4.1
MoreMountains.TopDownEngine.CharacterHandleWeapon Class Reference

Add this class to a character so it can use weapons Note that this component will trigger animations (if their parameter is present in the Animator), based on the current weapon's Animations Animator parameters : defined from the Weapon's inspector More...

Inheritance diagram for MoreMountains.TopDownEngine.CharacterHandleWeapon:
MoreMountains.TopDownEngine.CharacterAbility MoreMountains.TopDownEngine.TopDownMonoBehaviour MoreMountains.Tools.MMMonoBehaviour MoreMountains.TopDownEngine.CharacterHandleSecondaryWeapon

Public Member Functions

override string HelpBoxText ()
 This method is only used to display a helpbox text at the beginning of the ability's inspector. More...
 
delegate void OnWeaponChangeDelegate ()
 
virtual void Setup ()
 Grabs various components and inits stuff More...
 
override void ProcessAbility ()
 Every frame we check if it's needed to update the ammo display More...
 
virtual void ShootStart ()
 Causes the character to start shooting More...
 
virtual void ShootStop ()
 Causes the character to stop shooting More...
 
virtual void ForceStop ()
 Forces the weapon to stop More...
 
virtual void Reload ()
 Reloads the weapon More...
 
virtual void ChangeWeapon (Weapon newWeapon, string weaponID, bool combo=false)
 Changes the character's current weapon to the one passed as a parameter More...
 
override void Flip ()
 Flips the current weapon if needed More...
 
virtual void UpdateAmmoDisplay ()
 Updates the ammo display bar and text. More...
 
override void UpdateAnimator ()
 Override this to send parameters to the character's animator. This is called once per cycle, by the Character class, after Early, normal and Late process(). More...
 
- Public Member Functions inherited from MoreMountains.TopDownEngine.CharacterAbility
delegate void AbilityEvent ()
 
virtual void ForceInitialization ()
 Call this any time you want to force this ability to initialize (again) More...
 
virtual void ResetInput ()
 Resets all input for this ability. Can be overridden for ability specific directives More...
 
virtual void EarlyProcessAbility ()
 The first of the 3 passes you can have in your ability. Think of it as EarlyUpdate() if it existed More...
 
virtual void LateProcessAbility ()
 The last of the 3 passes you can have in your ability. Think of it as LateUpdate() More...
 
virtual void PermitAbility (bool abilityPermitted)
 Changes the status of the ability's permission More...
 
virtual void ResetAbility ()
 Override this to reset this ability's parameters. It'll be automatically called when the character gets killed, in anticipation for its respawn. More...
 
virtual void SetInputManager (InputManager newInputManager)
 Changes the reference to the input manager with the one set in parameters More...
 
virtual void PlayAbilityStartSfx ()
 Plays the ability start sound effect More...
 
virtual void PlayAbilityUsedSfx ()
 Plays the ability used sound effect More...
 
virtual void StopAbilityUsedSfx ()
 Stops the ability used sound effect More...
 
virtual void PlayAbilityStopSfx ()
 Plays the ability stop sound effect More...
 
virtual void PlayAbilityStartFeedbacks ()
 Plays the ability start sound effect More...
 
virtual void StopStartFeedbacks ()
 Stops the ability used sound effect More...
 
virtual void PlayAbilityStopFeedbacks ()
 Plays the ability stop sound effect More...
 

Public Attributes

Weapon InitialWeapon
 the initial weapon owned by the character More...
 
bool CanPickupWeapons = true
 if this is set to true, the character can pick up PickableWeapons More...
 
MMFeedbacks WeaponUseFeedback
 a feedback that gets triggered at the character level everytime the weapon is used More...
 
Transform WeaponAttachment
 the position the weapon will be attached to. If left blank, will be this.transform. More...
 
Transform ProjectileSpawn
 the position from which projectiles will be spawned (can be safely left empty) More...
 
bool AutomaticallyBindAnimator = true
 if this is true this animator will be automatically bound to the weapon More...
 
int AmmoDisplayID = 0
 the ID of the AmmoDisplay this ability should update More...
 
bool AutoIK = true
 if this is true, IK will be automatically setup if possible More...
 
bool ContinuousPress = false
 if this is true you won't have to release your fire button to auto reload More...
 
bool GettingHitInterruptsAttack = false
 whether or not this character getting hit should interrupt its attack (will only work if the weapon is marked as interruptable) More...
 
bool UseSecondaryAxisThresholdToShoot = false
 whether or not pushing the secondary axis above its threshold should cause the weapon to shoot More...
 
bool ForceWeaponAimControl = false
 if this is true, the ForcedWeaponAimControl mode will be applied to all weapons equipped by this character More...
 
WeaponAim.AimControls ForcedWeaponAimControl = WeaponAim.AimControls.PrimaryMovement
 if ForceWeaponAimControl is true, the AimControls mode to apply to all weapons equipped by this character More...
 
bool ForceAlwaysShoot = false
 if this is true, the character will continuously fire its weapon More...
 
bool BufferInput
 whether or not attack input should be buffered, letting you prepare an attack while another is being performed, making it easier to chain them More...
 
bool NewInputExtendsBuffer
 if this is true, every new input will prolong the buffer More...
 
float MaximumBufferDuration = 0.25f
 the maximum duration for the buffer, in seconds More...
 
bool RequiresPerfectTile = false
 if this is true, and if this character is using GridMovement, then input will only be triggered when on a perfect tile More...
 
Weapon CurrentWeapon
 the weapon currently equipped by the Character More...
 
OnWeaponChangeDelegate OnWeaponChange
 a delegate you can hook to, to be notified of weapon changes More...
 
- Public Attributes inherited from MoreMountains.TopDownEngine.CharacterAbility
AudioClip AbilityStartSfx
 the sound fx to play when the ability starts More...
 
AudioClip AbilityInProgressSfx
 the sound fx to play while the ability is running More...
 
AudioClip AbilityStopSfx
 the sound fx to play when the ability stops More...
 
MMFeedbacks AbilityStartFeedbacks
 the feedbacks to play when the ability starts More...
 
MMFeedbacks AbilityStopFeedbacks
 the feedbacks to play when the ability stops More...
 
bool AbilityPermitted = true
 if true, this ability can perform as usual, if not, it'll be ignored. You can use this to unlock abilities over time for example More...
 
CharacterStates.MovementStates[] BlockingMovementStates
 an array containing all the blocking movement states. If the Character is in one of these states and tries to trigger this ability, it won't be permitted. Useful to prevent this ability from being used while Idle or Swimming, for example. More...
 
CharacterStates.CharacterConditions[] BlockingConditionStates
 an array containing all the blocking condition states. If the Character is in one of these states and tries to trigger this ability, it won't be permitted. Useful to prevent this ability from being used while dead, for example. More...
 
Weapon.WeaponStates[] BlockingWeaponStates
 an array containing all the blocking weapon states. If one of the character's weapons is in one of these states and yet the character tries to trigger this ability, it won't be permitted. Useful to prevent this ability from being used while attacking, for example. More...
 
AbilityEvent OnAbilityStart
 
AbilityEvent OnAbilityStop
 

Protected Member Functions

override void PreInitialization ()
 Sets the weapon attachment More...
 
override void Initialization ()
 Gets and stores components for further use More...
 
virtual void HandleCharacterState ()
 Checks character state and stops shooting if not in normal state More...
 
virtual void HandleFeedbacks ()
 Triggers the weapon used feedback if needed More...
 
override void HandleInput ()
 Gets input and triggers methods based on what's been pressed More...
 
virtual void HandleBuffer ()
 Triggers an attack if the weapon is idle and an input has been buffered More...
 
virtual void ExtendBuffer ()
 Extends the duration of the buffer if needed More...
 
virtual void InstantiateWeapon (Weapon newWeapon, string weaponID, bool combo=false)
 Instantiates the specified weapon More...
 
virtual void HandleWeaponAim ()
 Applies aim if possible More...
 
virtual void HandleWeaponIK ()
 Sets IK handles if needed More...
 
virtual void HandleWeaponModel (Weapon newWeapon, string weaponID, bool combo=false, Weapon weapon=null)
 
override void InitializeAnimatorParameters ()
 Adds required animator parameters to the animator parameters list if they exist More...
 
override void OnHit ()
 Override this to describe what should happen to this ability when the character takes a hit More...
 
override void OnDeath ()
 Override this to describe what should happen to this ability when the character respawns More...
 
override void OnRespawn ()
 Override this to describe what should happen to this ability when the character respawns More...
 
- Protected Member Functions inherited from MoreMountains.TopDownEngine.CharacterAbility
virtual void Awake ()
 On awake we proceed to pre initializing our ability More...
 
virtual void Start ()
 On Start(), we call the ability's intialization More...
 
virtual void BindAnimator ()
 Binds the animator from the character and initializes the animator parameters More...
 
virtual void InternalHandleInput ()
 Internal method to check if an input manager is present or not More...
 
virtual void RegisterAnimatorParameter (string parameterName, AnimatorControllerParameterType parameterType, out int parameter)
 Registers a new animator parameter to the list More...
 
virtual void OnEnable ()
 On enable, we bind our respawn delegate More...
 
virtual void OnDisable ()
 On disable, we unbind our respawn delegate More...
 

Protected Attributes

float _fireTimer = 0f
 
float _secondaryHorizontalMovement
 
float _secondaryVerticalMovement
 
WeaponAim _weaponAim
 
ProjectileWeapon _projectileWeapon
 
WeaponIK _weaponIK
 
Transform _leftHandTarget = null
 
Transform _rightHandTarget = null
 
float _bufferEndsAt = 0f
 
bool _buffering = false
 
int _weaponEquippedAnimationParameter
 
int _weaponEquippedIDAnimationParameter
 
CharacterGridMovement _characterGridMovement
 
List< WeaponModel_weaponModels
 
- Protected Attributes inherited from MoreMountains.TopDownEngine.CharacterAbility
Character _character
 
TopDownController _controller
 
TopDownController2D _controller2D
 
TopDownController3D _controller3D
 
GameObject _model
 
Health _health
 
CharacterMovement _characterMovement
 
InputManager _inputManager
 
Animator _animator = null
 
CharacterStates _state
 
SpriteRenderer _spriteRenderer
 
MMStateMachine< CharacterStates.MovementStates_movement
 
MMStateMachine< CharacterStates.CharacterConditions_condition
 
AudioSource _abilityInProgressSfx
 
bool _abilityInitialized = false
 
float _verticalInput
 
float _horizontalInput
 
bool _startFeedbackIsPlaying = false
 
List< CharacterHandleWeapon_handleWeaponList
 

Static Protected Attributes

const string _weaponEquippedAnimationParameterName = "WeaponEquipped"
 
const string _weaponEquippedIDAnimationParameterName = "WeaponEquippedID"
 

Properties

virtual int HandleWeaponID [get]
 
virtual Animator CharacterAnimator [get, set]
 an animator to update when the weapon is used More...
 
virtual WeaponAim WeaponAimComponent [get]
 the weapon's weapon aim component, if it has one More...
 
- Properties inherited from MoreMountains.TopDownEngine.CharacterAbility
virtual bool AbilityAuthorized [get]
 
virtual bool AbilityInitialized [get]
 whether or not this ability has been initialized More...
 

Detailed Description

Add this class to a character so it can use weapons Note that this component will trigger animations (if their parameter is present in the Animator), based on the current weapon's Animations Animator parameters : defined from the Weapon's inspector

Member Function Documentation

◆ ChangeWeapon()

virtual void MoreMountains.TopDownEngine.CharacterHandleWeapon.ChangeWeapon ( Weapon  newWeapon,
string  weaponID,
bool  combo = false 
)
virtual

Changes the character's current weapon to the one passed as a parameter

Parameters
newWeaponThe new weapon.

◆ ExtendBuffer()

virtual void MoreMountains.TopDownEngine.CharacterHandleWeapon.ExtendBuffer ( )
protectedvirtual

Extends the duration of the buffer if needed

◆ Flip()

override void MoreMountains.TopDownEngine.CharacterHandleWeapon.Flip ( )
virtual

Flips the current weapon if needed

Reimplemented from MoreMountains.TopDownEngine.CharacterAbility.

◆ ForceStop()

virtual void MoreMountains.TopDownEngine.CharacterHandleWeapon.ForceStop ( )
virtual

Forces the weapon to stop

◆ HandleBuffer()

virtual void MoreMountains.TopDownEngine.CharacterHandleWeapon.HandleBuffer ( )
protectedvirtual

Triggers an attack if the weapon is idle and an input has been buffered

◆ HandleCharacterState()

virtual void MoreMountains.TopDownEngine.CharacterHandleWeapon.HandleCharacterState ( )
protectedvirtual

Checks character state and stops shooting if not in normal state

◆ HandleFeedbacks()

virtual void MoreMountains.TopDownEngine.CharacterHandleWeapon.HandleFeedbacks ( )
protectedvirtual

Triggers the weapon used feedback if needed

◆ HandleInput()

override void MoreMountains.TopDownEngine.CharacterHandleWeapon.HandleInput ( )
protectedvirtual

Gets input and triggers methods based on what's been pressed

Reimplemented from MoreMountains.TopDownEngine.CharacterAbility.

◆ HandleWeaponAim()

virtual void MoreMountains.TopDownEngine.CharacterHandleWeapon.HandleWeaponAim ( )
protectedvirtual

Applies aim if possible

◆ HandleWeaponIK()

virtual void MoreMountains.TopDownEngine.CharacterHandleWeapon.HandleWeaponIK ( )
protectedvirtual

Sets IK handles if needed

◆ HandleWeaponModel()

virtual void MoreMountains.TopDownEngine.CharacterHandleWeapon.HandleWeaponModel ( Weapon  newWeapon,
string  weaponID,
bool  combo = false,
Weapon  weapon = null 
)
protectedvirtual

◆ HelpBoxText()

override string MoreMountains.TopDownEngine.CharacterHandleWeapon.HelpBoxText ( )
virtual

This method is only used to display a helpbox text at the beginning of the ability's inspector.

Reimplemented from MoreMountains.TopDownEngine.CharacterAbility.

◆ Initialization()

override void MoreMountains.TopDownEngine.CharacterHandleWeapon.Initialization ( )
protectedvirtual

Gets and stores components for further use

Reimplemented from MoreMountains.TopDownEngine.CharacterAbility.

◆ InitializeAnimatorParameters()

override void MoreMountains.TopDownEngine.CharacterHandleWeapon.InitializeAnimatorParameters ( )
protectedvirtual

Adds required animator parameters to the animator parameters list if they exist

Reimplemented from MoreMountains.TopDownEngine.CharacterAbility.

◆ InstantiateWeapon()

virtual void MoreMountains.TopDownEngine.CharacterHandleWeapon.InstantiateWeapon ( Weapon  newWeapon,
string  weaponID,
bool  combo = false 
)
protectedvirtual

Instantiates the specified weapon

Parameters
newWeapon
weaponID
combo

◆ OnDeath()

override void MoreMountains.TopDownEngine.CharacterHandleWeapon.OnDeath ( )
protectedvirtual

Override this to describe what should happen to this ability when the character respawns

Reimplemented from MoreMountains.TopDownEngine.CharacterAbility.

◆ OnHit()

override void MoreMountains.TopDownEngine.CharacterHandleWeapon.OnHit ( )
protectedvirtual

Override this to describe what should happen to this ability when the character takes a hit

Reimplemented from MoreMountains.TopDownEngine.CharacterAbility.

◆ OnRespawn()

override void MoreMountains.TopDownEngine.CharacterHandleWeapon.OnRespawn ( )
protectedvirtual

Override this to describe what should happen to this ability when the character respawns

Reimplemented from MoreMountains.TopDownEngine.CharacterAbility.

◆ OnWeaponChangeDelegate()

delegate void MoreMountains.TopDownEngine.CharacterHandleWeapon.OnWeaponChangeDelegate ( )

◆ PreInitialization()

override void MoreMountains.TopDownEngine.CharacterHandleWeapon.PreInitialization ( )
protectedvirtual

Sets the weapon attachment

Reimplemented from MoreMountains.TopDownEngine.CharacterAbility.

◆ ProcessAbility()

override void MoreMountains.TopDownEngine.CharacterHandleWeapon.ProcessAbility ( )
virtual

Every frame we check if it's needed to update the ammo display

Reimplemented from MoreMountains.TopDownEngine.CharacterAbility.

◆ Reload()

virtual void MoreMountains.TopDownEngine.CharacterHandleWeapon.Reload ( )
virtual

Reloads the weapon

◆ Setup()

virtual void MoreMountains.TopDownEngine.CharacterHandleWeapon.Setup ( )
virtual

Grabs various components and inits stuff

◆ ShootStart()

virtual void MoreMountains.TopDownEngine.CharacterHandleWeapon.ShootStart ( )
virtual

Causes the character to start shooting

◆ ShootStop()

virtual void MoreMountains.TopDownEngine.CharacterHandleWeapon.ShootStop ( )
virtual

Causes the character to stop shooting

◆ UpdateAmmoDisplay()

virtual void MoreMountains.TopDownEngine.CharacterHandleWeapon.UpdateAmmoDisplay ( )
virtual

Updates the ammo display bar and text.

◆ UpdateAnimator()

override void MoreMountains.TopDownEngine.CharacterHandleWeapon.UpdateAnimator ( )
virtual

Override this to send parameters to the character's animator. This is called once per cycle, by the Character class, after Early, normal and Late process().

Reimplemented from MoreMountains.TopDownEngine.CharacterAbility.

Member Data Documentation

◆ _bufferEndsAt

float MoreMountains.TopDownEngine.CharacterHandleWeapon._bufferEndsAt = 0f
protected

◆ _buffering

bool MoreMountains.TopDownEngine.CharacterHandleWeapon._buffering = false
protected

◆ _characterGridMovement

CharacterGridMovement MoreMountains.TopDownEngine.CharacterHandleWeapon._characterGridMovement
protected

◆ _fireTimer

float MoreMountains.TopDownEngine.CharacterHandleWeapon._fireTimer = 0f
protected

◆ _leftHandTarget

Transform MoreMountains.TopDownEngine.CharacterHandleWeapon._leftHandTarget = null
protected

◆ _projectileWeapon

ProjectileWeapon MoreMountains.TopDownEngine.CharacterHandleWeapon._projectileWeapon
protected

◆ _rightHandTarget

Transform MoreMountains.TopDownEngine.CharacterHandleWeapon._rightHandTarget = null
protected

◆ _secondaryHorizontalMovement

float MoreMountains.TopDownEngine.CharacterHandleWeapon._secondaryHorizontalMovement
protected

◆ _secondaryVerticalMovement

float MoreMountains.TopDownEngine.CharacterHandleWeapon._secondaryVerticalMovement
protected

◆ _weaponAim

WeaponAim MoreMountains.TopDownEngine.CharacterHandleWeapon._weaponAim
protected

◆ _weaponEquippedAnimationParameter

int MoreMountains.TopDownEngine.CharacterHandleWeapon._weaponEquippedAnimationParameter
protected

◆ _weaponEquippedAnimationParameterName

const string MoreMountains.TopDownEngine.CharacterHandleWeapon._weaponEquippedAnimationParameterName = "WeaponEquipped"
staticprotected

◆ _weaponEquippedIDAnimationParameter

int MoreMountains.TopDownEngine.CharacterHandleWeapon._weaponEquippedIDAnimationParameter
protected

◆ _weaponEquippedIDAnimationParameterName

const string MoreMountains.TopDownEngine.CharacterHandleWeapon._weaponEquippedIDAnimationParameterName = "WeaponEquippedID"
staticprotected

◆ _weaponIK

WeaponIK MoreMountains.TopDownEngine.CharacterHandleWeapon._weaponIK
protected

◆ _weaponModels

List<WeaponModel> MoreMountains.TopDownEngine.CharacterHandleWeapon._weaponModels
protected

◆ AmmoDisplayID

int MoreMountains.TopDownEngine.CharacterHandleWeapon.AmmoDisplayID = 0

the ID of the AmmoDisplay this ability should update

◆ AutoIK

bool MoreMountains.TopDownEngine.CharacterHandleWeapon.AutoIK = true

if this is true, IK will be automatically setup if possible

◆ AutomaticallyBindAnimator

bool MoreMountains.TopDownEngine.CharacterHandleWeapon.AutomaticallyBindAnimator = true

if this is true this animator will be automatically bound to the weapon

◆ BufferInput

bool MoreMountains.TopDownEngine.CharacterHandleWeapon.BufferInput

whether or not attack input should be buffered, letting you prepare an attack while another is being performed, making it easier to chain them

◆ CanPickupWeapons

bool MoreMountains.TopDownEngine.CharacterHandleWeapon.CanPickupWeapons = true

if this is set to true, the character can pick up PickableWeapons

◆ ContinuousPress

bool MoreMountains.TopDownEngine.CharacterHandleWeapon.ContinuousPress = false

if this is true you won't have to release your fire button to auto reload

◆ CurrentWeapon

Weapon MoreMountains.TopDownEngine.CharacterHandleWeapon.CurrentWeapon

the weapon currently equipped by the Character

◆ ForceAlwaysShoot

bool MoreMountains.TopDownEngine.CharacterHandleWeapon.ForceAlwaysShoot = false

if this is true, the character will continuously fire its weapon

◆ ForcedWeaponAimControl

WeaponAim.AimControls MoreMountains.TopDownEngine.CharacterHandleWeapon.ForcedWeaponAimControl = WeaponAim.AimControls.PrimaryMovement

if ForceWeaponAimControl is true, the AimControls mode to apply to all weapons equipped by this character

◆ ForceWeaponAimControl

bool MoreMountains.TopDownEngine.CharacterHandleWeapon.ForceWeaponAimControl = false

if this is true, the ForcedWeaponAimControl mode will be applied to all weapons equipped by this character

◆ GettingHitInterruptsAttack

bool MoreMountains.TopDownEngine.CharacterHandleWeapon.GettingHitInterruptsAttack = false

whether or not this character getting hit should interrupt its attack (will only work if the weapon is marked as interruptable)

◆ InitialWeapon

Weapon MoreMountains.TopDownEngine.CharacterHandleWeapon.InitialWeapon

the initial weapon owned by the character

◆ MaximumBufferDuration

float MoreMountains.TopDownEngine.CharacterHandleWeapon.MaximumBufferDuration = 0.25f

the maximum duration for the buffer, in seconds

◆ NewInputExtendsBuffer

bool MoreMountains.TopDownEngine.CharacterHandleWeapon.NewInputExtendsBuffer

if this is true, every new input will prolong the buffer

◆ OnWeaponChange

OnWeaponChangeDelegate MoreMountains.TopDownEngine.CharacterHandleWeapon.OnWeaponChange

a delegate you can hook to, to be notified of weapon changes

◆ ProjectileSpawn

Transform MoreMountains.TopDownEngine.CharacterHandleWeapon.ProjectileSpawn

the position from which projectiles will be spawned (can be safely left empty)

◆ RequiresPerfectTile

bool MoreMountains.TopDownEngine.CharacterHandleWeapon.RequiresPerfectTile = false

if this is true, and if this character is using GridMovement, then input will only be triggered when on a perfect tile

◆ UseSecondaryAxisThresholdToShoot

bool MoreMountains.TopDownEngine.CharacterHandleWeapon.UseSecondaryAxisThresholdToShoot = false

whether or not pushing the secondary axis above its threshold should cause the weapon to shoot

◆ WeaponAttachment

Transform MoreMountains.TopDownEngine.CharacterHandleWeapon.WeaponAttachment

the position the weapon will be attached to. If left blank, will be this.transform.

◆ WeaponUseFeedback

MMFeedbacks MoreMountains.TopDownEngine.CharacterHandleWeapon.WeaponUseFeedback

a feedback that gets triggered at the character level everytime the weapon is used

Property Documentation

◆ CharacterAnimator

virtual Animator MoreMountains.TopDownEngine.CharacterHandleWeapon.CharacterAnimator
getset

an animator to update when the weapon is used

◆ HandleWeaponID

virtual int MoreMountains.TopDownEngine.CharacterHandleWeapon.HandleWeaponID
get

the ID / index of this CharacterHandleWeapon. This will be used to determine what handle weapon ability should equip a weapon. If you create more Handle Weapon abilities, make sure to override and increment this

◆ WeaponAimComponent

virtual WeaponAim MoreMountains.TopDownEngine.CharacterHandleWeapon.WeaponAimComponent
get

the weapon's weapon aim component, if it has one


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