diff --git a/MrBigsock/Assets/Code/UI/AbilityCluster.cs b/MrBigsock/Assets/Code/UI/AbilityCluster.cs index 63fde66fb70be46ab6c128de88e47caf42962617..44832dbb266aafa942b8210d3656274a6e44c36f 100644 --- a/MrBigsock/Assets/Code/UI/AbilityCluster.cs +++ b/MrBigsock/Assets/Code/UI/AbilityCluster.cs @@ -1,13 +1,33 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +using UnityEngine.UI; +using BigSock.Service; namespace BigSock.UI { public class AbilityCluster : MonoBehaviour { + private const string ABILITYELEMENT = "UI/Ability"; + private List<AbilityElement> abilityList; + public void SetElements(int elementAmount) + { + for (int i = 0; i < elementAmount; ++i) + { + abilityList.Add(PrefabService.SINGLETON.Instance(ABILITYELEMENT, transform).GetComponent<AbilityElement>()); + } + } + public void SetCooldown(int index, float amount) + { + abilityList[index].WithCooldown(amount); + } + + public void SetCharge(int index, float amount) + { + abilityList[index].WithCharge(amount); + } } diff --git a/MrBigsock/Assets/Code/UI/AbilityElement.cs b/MrBigsock/Assets/Code/UI/AbilityElement.cs index f82a1b2d373e18e17f4c7616665bc37a56a08276..21307ed2c9ed44d88bc3c5a4d486a6e68af46b3d 100644 --- a/MrBigsock/Assets/Code/UI/AbilityElement.cs +++ b/MrBigsock/Assets/Code/UI/AbilityElement.cs @@ -8,31 +8,31 @@ namespace BigSock.UI { public class AbilityElement : MonoBehaviour { - private Slider ChargeSlider, ReloadSlider; + private Slider chargeSlider, cooldownSlider; - public AbilityElement WithCharge(int? value = null, int? maxValue = null) + public AbilityElement WithCharge(float? value = null, float? maxValue = null) { - if (value != null) ChargeSlider.value = value.Value; + if (value != null) chargeSlider.value = value.Value; - if (maxValue != null) ChargeSlider.maxValue = maxValue.Value; + if (maxValue != null) chargeSlider.maxValue = maxValue.Value; return this; } - - public AbilityElement WithReload(int? value = null, int? maxValue = null) + + public AbilityElement WithCooldown(float? value = null, float? maxValue = null) { - if (value != null) ReloadSlider.value = value.Value; + if (value != null) cooldownSlider.value = value.Value; - if (maxValue != null) ReloadSlider.maxValue = maxValue.Value; + if (maxValue != null) cooldownSlider.maxValue = maxValue.Value; return this; - } + } // Start is called before the first frame update void Start() { - ChargeSlider = transform.Find("ChargeSlider").GetComponent<Slider>(); - ReloadSlider = transform.Find("ReloadSlider").GetComponent<Slider>(); + chargeSlider = transform.Find("ChargeSlider").GetComponent<Slider>(); + cooldownSlider = transform.Find("ReloadSlider").GetComponent<Slider>(); } // Update is called once per frame