diff --git a/MrBigsock/Assets/Code/PlayerController.cs b/MrBigsock/Assets/Code/PlayerController.cs index 124cabcd1b378141e9ade41bd5b055095a4ce207..8678df36f42d0f8fa049c41ab23088bd3a39c5b3 100644 --- a/MrBigsock/Assets/Code/PlayerController.cs +++ b/MrBigsock/Assets/Code/PlayerController.cs @@ -20,6 +20,7 @@ namespace BigSock { 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 int ABILITY_COUNT = 4; // Number of abilities. public UtilBar utilBar; @@ -37,6 +38,9 @@ namespace BigSock { bool canMove = true; + // The UI component for displaying abilities. + private AbilityCluster AbilityUI; + // The abilities of the player. private List<AbilityEntity> _abilities = new List<AbilityEntity>(); @@ -94,6 +98,7 @@ namespace BigSock { animator = GetComponent<Animator>(); spriteRenderer = GetComponent<SpriteRenderer>(); + AbilityUI = GameObject.Find("AbilityCluster")?.GetComponent<AbilityCluster>(); //!! DEBUG: Add item to player at start to test if it works. @@ -106,7 +111,6 @@ namespace BigSock { //var tmp = PrefabService.SINGLETON; //var tmp = SpriteService.SINGLETON; - // Get the abilities and set them up. var aService = AbilityService.SINGLETON; var abilities = new List<IAbility> { @@ -115,6 +119,7 @@ namespace BigSock { aService.Get(101), aService.Get(201), }; + AbilityUI?.SetElements(ABILITY_COUNT); SetAbilities(abilities); //_testAttack = (IAttack)AbilityService.SINGLETON.Get(104); @@ -181,8 +186,8 @@ namespace BigSock { if(CheckAbilityInput(key, ability)) break; // Update the UI. - //> AbilityUI?.UpdateCharge(ability.Index, ability.ChargePercent); - //> AbilityUI?.UpdateCooldown(ability.Index, ability.CooldownPercent); + AbilityUI?.SetCharge(ability.Index, ability.ChargePercent); + AbilityUI?.SetCooldown(ability.Index, ability.CooldownPercent); } @@ -219,6 +224,7 @@ namespace BigSock { if (par.ChargeTime < ability.Ability.MinCharge) 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; } break;