Eye of the Nile Docs
Everything you need to know to get started!
Loading...
Searching...
No Matches
PlayerAbilityController Class Reference

Detailed Description

Handles player input related to activating abilities and manages AbilityOwner objects for each of the 4 active abilities.

Documentation updated 8/11/2024

Author
Roy Pascual, Stephen Nuttall

Public Member Functions

void UseAbilityChargingUp (AbilityOwner abilityOwner)
 This ability is subscribed to the AbilityOwner.ChargeUp event, and triggers the AbilityOwner.ChargingUp() coroutine. See more information in Events in AbilityOwner.cs.
 
void UseAbilityCoolingDown (AbilityOwner abilityOwner)
 This ability is subscribed to the AbilityOwner.CoolDown event, and triggers the AbilityOwner.CoolingDown() coroutine. See more information in Events in AbilityOwner.cs.
 
void UseAbilityUpdate (AbilityOwner abilityOwner)
 This ability is subscribed to the AbilityOwner.AbilityUpdate event, and triggers the AbilityOwner.UpdateWithinDuration() coroutine. See more information in Events in AbilityOwner.cs.
 

Public Attributes

ActiveAbilityData activeAbilities
 Reference to the ActiveAbilityData object.
 
List< UnityEvent > abilityEvents
 Runs the [i]th event when the [i]th ability is activated. Max size of 4 (0 - 3).
 

Private Member Functions

void SubscribeToAbility (AbilityOwner someAbility)
 Subscribes a function to each event in AbilityOwner to run a corresponding conroutine in AbilityOwner.
 
void UnsubscribeFromAbility (AbilityOwner someAbility)
 Unsubscribes from each event in AbilityOwner.
 
void TryChangeAbility (KeyCode key, AbilityOwner newAbility)
 Attempts to change the AbilityOwner for the given key. Also runs OnEquipped(), and activates the passive ability in the last slot.
 
void RefreshSlots (int[] slotNumbers)
 Refreshes the AbilityOwner.abilityInfo for all slots at the defined positions to match up with the active abilities. Also runs OnEquipped() and OnUnequipped, and activates or disables the passive ability in the last slot.
 
void Awake ()
 Initializes AbilityInputs and keyList. Initializes StoredAbilities and adds a new AbilityOwner for each keycode. Also sets a reference.
 
void Update ()
 Check if any of the ability keybinds are pressed. If so, activate the corresponding ability. Check if a change to ActiveAbilityData was made. If so, refresh the AbilityOwners that were affected. Update the cooldown visuals based on the remaining cooldown time.
 

Private Attributes

DataManager dataManager
 Reference to the data manager.
 
TotalAbilityUI totalAbilityUI
 Reference to the TotalAbilityUI.
 
Dictionary< int, KeyCode > intToKey
 Maps the ints 0 - 3 to the keyboard keys 1 - 4.
 
Dictionary< KeyCode, bool > AbilityInputs
 Map of all 4 ability keys, and if they’re being pressed or not.
 
Dictionary< KeyCode, AbilityOwnerStoredAbilityOwners
 Maps each ability key to an AbilityOwner, which contains some information about ability and handles charge ups/cooldowns.
 
List< KeyCode > keyList
 List of each of the 4 ability keybinds (1, 2, 3, and 4).
 

Static Private Attributes

const int MAX_ABILITIES = 4
 Maximum number of active ability slots.
 

Member Function Documentation

◆ Awake()

void PlayerAbilityController.Awake ( )
private

Initializes AbilityInputs and keyList. Initializes StoredAbilities and adds a new AbilityOwner for each keycode. Also sets a reference.

◆ RefreshSlots()

void PlayerAbilityController.RefreshSlots ( int[] slotNumbers)
private

Refreshes the AbilityOwner.abilityInfo for all slots at the defined positions to match up with the active abilities. Also runs OnEquipped() and OnUnequipped, and activates or disables the passive ability in the last slot.

◆ SubscribeToAbility()

void PlayerAbilityController.SubscribeToAbility ( AbilityOwner someAbility)
private

Subscribes a function to each event in AbilityOwner to run a corresponding conroutine in AbilityOwner.

◆ TryChangeAbility()

void PlayerAbilityController.TryChangeAbility ( KeyCode key,
AbilityOwner newAbility )
private

Attempts to change the AbilityOwner for the given key. Also runs OnEquipped(), and activates the passive ability in the last slot.

◆ UnsubscribeFromAbility()

void PlayerAbilityController.UnsubscribeFromAbility ( AbilityOwner someAbility)
private

Unsubscribes from each event in AbilityOwner.

◆ Update()

void PlayerAbilityController.Update ( )
private

Check if any of the ability keybinds are pressed. If so, activate the corresponding ability. Check if a change to ActiveAbilityData was made. If so, refresh the AbilityOwners that were affected. Update the cooldown visuals based on the remaining cooldown time.

◆ UseAbilityChargingUp()

void PlayerAbilityController.UseAbilityChargingUp ( AbilityOwner abilityOwner)

This ability is subscribed to the AbilityOwner.ChargeUp event, and triggers the AbilityOwner.ChargingUp() coroutine. See more information in Events in AbilityOwner.cs.

◆ UseAbilityCoolingDown()

void PlayerAbilityController.UseAbilityCoolingDown ( AbilityOwner abilityOwner)

This ability is subscribed to the AbilityOwner.CoolDown event, and triggers the AbilityOwner.CoolingDown() coroutine. See more information in Events in AbilityOwner.cs.

◆ UseAbilityUpdate()

void PlayerAbilityController.UseAbilityUpdate ( AbilityOwner abilityOwner)

This ability is subscribed to the AbilityOwner.AbilityUpdate event, and triggers the AbilityOwner.UpdateWithinDuration() coroutine. See more information in Events in AbilityOwner.cs.

Member Data Documentation

◆ abilityEvents

List<UnityEvent> PlayerAbilityController.abilityEvents

Runs the [i]th event when the [i]th ability is activated. Max size of 4 (0 - 3).

◆ AbilityInputs

Dictionary<KeyCode, bool> PlayerAbilityController.AbilityInputs
private

Map of all 4 ability keys, and if they’re being pressed or not.

◆ activeAbilities

ActiveAbilityData PlayerAbilityController.activeAbilities

Reference to the ActiveAbilityData object.

◆ dataManager

DataManager PlayerAbilityController.dataManager
private

Reference to the data manager.

◆ intToKey

Dictionary<int, KeyCode> PlayerAbilityController.intToKey
private
Initial value:
= new Dictionary<int, KeyCode>()
{
{ 0, KeyCode.Alpha1 },
{ 1, KeyCode.Alpha2 },
{ 2, KeyCode.Alpha3 },
{ 3, KeyCode.Alpha4 }
}

Maps the ints 0 - 3 to the keyboard keys 1 - 4.

◆ keyList

List<KeyCode> PlayerAbilityController.keyList
private

List of each of the 4 ability keybinds (1, 2, 3, and 4).

◆ MAX_ABILITIES

const int PlayerAbilityController.MAX_ABILITIES = 4
staticprivate

Maximum number of active ability slots.

◆ StoredAbilityOwners

Dictionary<KeyCode, AbilityOwner> PlayerAbilityController.StoredAbilityOwners
private

Maps each ability key to an AbilityOwner, which contains some information about ability and handles charge ups/cooldowns.

◆ totalAbilityUI

TotalAbilityUI PlayerAbilityController.totalAbilityUI
private

Reference to the TotalAbilityUI.


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