Skip to content
Snippets Groups Projects
Commit 257cdc83 authored by Julius Fredrik Einum's avatar Julius Fredrik Einum
Browse files

Added ability cluster full charge and cooldown func

parent 22197bd1
No related branches found
No related tags found
2 merge requests!81Main,!80Juliuses nye super branch
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);
}
}
......
......@@ -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
......
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