Skip to content
Snippets Groups Projects
Commit b1bafae1 authored by Robin Halseth Sandvik's avatar Robin Halseth Sandvik
Browse files

Made the player ability code update the ability ui.

- Also reset charge on fire.
parent 75d9081a
No related branches found
No related tags found
1 merge request!84Merge, ability cluster
...@@ -20,6 +20,7 @@ namespace BigSock { ...@@ -20,6 +20,7 @@ namespace BigSock {
public const int SKILL_POINTS_START = 0; // Skill points to start with. public const int SKILL_POINTS_START = 0; // Skill points to start with.
public const float XP_SCALE_RATE = 3.0f; // Multiplier for xp gain, helps test system while game is tiny. public const float XP_SCALE_RATE = 3.0f; // Multiplier for xp gain, helps test system while game is tiny.
public const int ABILITY_COUNT = 4; // Number of abilities.
public UtilBar utilBar; public UtilBar utilBar;
...@@ -37,6 +38,9 @@ namespace BigSock { ...@@ -37,6 +38,9 @@ namespace BigSock {
bool canMove = true; bool canMove = true;
// The UI component for displaying abilities.
private AbilityCluster AbilityUI;
// The abilities of the player. // The abilities of the player.
private List<AbilityEntity> _abilities = new List<AbilityEntity>(); private List<AbilityEntity> _abilities = new List<AbilityEntity>();
...@@ -94,6 +98,7 @@ namespace BigSock { ...@@ -94,6 +98,7 @@ namespace BigSock {
animator = GetComponent<Animator>(); animator = GetComponent<Animator>();
spriteRenderer = GetComponent<SpriteRenderer>(); spriteRenderer = GetComponent<SpriteRenderer>();
AbilityUI = GameObject.Find("AbilityCluster")?.GetComponent<AbilityCluster>();
//!! DEBUG: Add item to player at start to test if it works. //!! DEBUG: Add item to player at start to test if it works.
...@@ -106,7 +111,6 @@ namespace BigSock { ...@@ -106,7 +111,6 @@ namespace BigSock {
//var tmp = PrefabService.SINGLETON; //var tmp = PrefabService.SINGLETON;
//var tmp = SpriteService.SINGLETON; //var tmp = SpriteService.SINGLETON;
// Get the abilities and set them up. // Get the abilities and set them up.
var aService = AbilityService.SINGLETON; var aService = AbilityService.SINGLETON;
var abilities = new List<IAbility> { var abilities = new List<IAbility> {
...@@ -115,6 +119,7 @@ namespace BigSock { ...@@ -115,6 +119,7 @@ namespace BigSock {
aService.Get(101), aService.Get(101),
aService.Get(201), aService.Get(201),
}; };
AbilityUI?.SetElements(ABILITY_COUNT);
SetAbilities(abilities); SetAbilities(abilities);
//_testAttack = (IAttack)AbilityService.SINGLETON.Get(104); //_testAttack = (IAttack)AbilityService.SINGLETON.Get(104);
...@@ -181,8 +186,8 @@ namespace BigSock { ...@@ -181,8 +186,8 @@ namespace BigSock {
if(CheckAbilityInput(key, ability)) break; if(CheckAbilityInput(key, ability)) break;
// Update the UI. // Update the UI.
//> AbilityUI?.UpdateCharge(ability.Index, ability.ChargePercent); AbilityUI?.SetCharge(ability.Index, ability.ChargePercent);
//> AbilityUI?.UpdateCooldown(ability.Index, ability.CooldownPercent); AbilityUI?.SetCooldown(ability.Index, ability.CooldownPercent);
} }
...@@ -219,6 +224,7 @@ namespace BigSock { ...@@ -219,6 +224,7 @@ namespace BigSock {
if (par.ChargeTime < ability.Ability.MinCharge) if (par.ChargeTime < ability.Ability.MinCharge)
Debug.Log($"[PlayerController.CheckAbilityInput({key})] {ability.Ability.Name} not fired ({par.ChargeTime:N3} < {ability.Ability.MinCharge:N3})"); Debug.Log($"[PlayerController.CheckAbilityInput({key})] {ability.Ability.Name} not fired ({par.ChargeTime:N3} < {ability.Ability.MinCharge:N3})");
} }
ability.ChargeStarted = 0f; // Reset charge time when we release the key.
return true; return true;
} }
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment