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

Added clear function to ability cluster

parent 4a455249
No related branches found
No related tags found
1 merge request!84Merge, ability cluster
......@@ -320,6 +320,15 @@ namespace BigSock {
var controlScheme = PrefabService.SINGLETON.Instance("UI/ControlScheme", canvas.transform);
}
}
/* for testing ui
if (Input.GetKeyDown(KeyCode.P))
{
GameObject abil = GameObject.Find("AbilityCluster");
var abilScript = abil.GetComponent<AbilityCluster>();
abilScript.ResetElements();
}
*/
}
/*
......
......@@ -6,32 +6,44 @@ using BigSock.Service;
namespace BigSock.UI
{
public class AbilityCluster : MonoBehaviour
{
private const string ABILITYELEMENT = "UI/Ability";
private List<AbilityElement> abilityList;
public class AbilityCluster : MonoBehaviour
{
private const string ABILITYELEMENT = "UI/Ability";
private List<AbilityElement> abilityList;
public void SetElements(int elementAmount)
{
abilityList = new List<AbilityElement>();
ResetElements();
for (int i = 0; i < elementAmount; ++i)
{
abilityList.Add(PrefabService.SINGLETON.Instance(ABILITYELEMENT, transform).GetComponent<AbilityElement>());
}
}
public void SetElements(int elementAmount)
//Clears all elements in ability cluster.
public void ResetElements()
{
abilityList = new List<AbilityElement>();
for (int i = 0; i < elementAmount; ++i)
{
abilityList.Add(PrefabService.SINGLETON.Instance(ABILITYELEMENT, transform).GetComponent<AbilityElement>());
}
}
abilityList.Clear();
var layout = this.GetComponent<HorizontalLayoutGroup>();
for (int i = 0; i < layout.transform.childCount; i++)
{
Destroy(layout.transform.GetChild(i).gameObject);
}
}
public void SetCooldown(int index, float amount)
{
abilityList[index].WithCooldown(amount);
}
public void SetCooldown(int index, float amount)
{
abilityList[index].WithCooldown(amount);
}
public void SetCharge(int index, float amount)
{
abilityList[index].WithCharge(amount);
}
public void SetAbility(int index, AbilityEntity ability) {
abilityList[index].WithAbility(ability);
}
public void SetCharge(int index, float amount)
{
abilityList[index].WithCharge(amount);
}
public void SetAbility(int index, AbilityEntity ability) {
abilityList[index].WithAbility(ability);
}
}
}
}
......@@ -15,7 +15,7 @@ GameObject:
- component: {fileID: 532417261}
m_Layer: 11
m_Name: ClosedChest
m_TagString: Untagged
m_TagString: Chest
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
......
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