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

Detailed Description

Remembers the amount of health potions the player has, and uses the potions when potionHotkey is pressed.

Documentation updated 3/5/2024

Author
Stephen Nuttall

Events

static Action< int > potionCountChanged
 Triggers when the amount of potions changes.
 
static Action< int > potionUsed
 Triggers when a potion is used.
 

Private Member Functions

void Awake ()
 On Awake, get the potion count from the DataManager.
 
void OnEnable ()
 Subscribes to the PotionPickedUp event.
 
void OnDisable ()
 Unsubscribes from the PotionPickedUp event.
 
void AddPotion ()
 Adds a potion unless the player currently has the maximum amount.
 
void Update ()
 Every frame, use a potion if the user can and wants to.
 
IEnumerator Cooldown ()
 Set onCooldown to true, wait cooldownLength, then set onCooldown to false.
 

Private Attributes

KeyCode potionHotkey
 The hot key for using a potion.
 
int potionHealAmount = 20
 The amount a potion should heal.
 
int maxPotionCount = 6
 The maximum amount of potions the player can have.
 
float cooldownLength = 3f
 The length of the cooldown after using a potion.
 
int potionCount = 0
 The amount of potions the player currently has.
 
bool onCooldown = false
 Whether or not using the potion is on cooldown.
 

Member Function Documentation

◆ AddPotion()

void PlayerItemHolder.AddPotion ( )
private

Adds a potion unless the player currently has the maximum amount.

◆ Awake()

void PlayerItemHolder.Awake ( )
private

On Awake, get the potion count from the DataManager.

◆ Cooldown()

IEnumerator PlayerItemHolder.Cooldown ( )
private

Set onCooldown to true, wait cooldownLength, then set onCooldown to false.

◆ OnDisable()

void PlayerItemHolder.OnDisable ( )
private

Unsubscribes from the PotionPickedUp event.

◆ OnEnable()

void PlayerItemHolder.OnEnable ( )
private

Subscribes to the PotionPickedUp event.

◆ Update()

void PlayerItemHolder.Update ( )
private

Every frame, use a potion if the user can and wants to.

Member Data Documentation

◆ cooldownLength

float PlayerItemHolder.cooldownLength = 3f
private

The length of the cooldown after using a potion.

◆ maxPotionCount

int PlayerItemHolder.maxPotionCount = 6
private

The maximum amount of potions the player can have.

◆ onCooldown

bool PlayerItemHolder.onCooldown = false
private

Whether or not using the potion is on cooldown.

◆ potionCount

int PlayerItemHolder.potionCount = 0
private

The amount of potions the player currently has.

◆ potionHealAmount

int PlayerItemHolder.potionHealAmount = 20
private

The amount a potion should heal.

◆ potionHotkey

KeyCode PlayerItemHolder.potionHotkey
private

The hot key for using a potion.

Event Documentation

◆ potionCountChanged

Action<int> PlayerItemHolder.potionCountChanged
static

Triggers when the amount of potions changes.

◆ potionUsed

Action<int> PlayerItemHolder.potionUsed
static

Triggers when a potion is used.


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