diff --git a/MrBigsock/Assets/Code/PlayerController.cs b/MrBigsock/Assets/Code/PlayerController.cs index 1d26c4c885e87adfa699c556bcb948ae57bd59b4..7b2540a0ce17707b59a68482b6baccd4235694e6 100644 --- a/MrBigsock/Assets/Code/PlayerController.cs +++ b/MrBigsock/Assets/Code/PlayerController.cs @@ -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(); + } + */ } /* diff --git a/MrBigsock/Assets/Code/UI/AbilityCluster.cs b/MrBigsock/Assets/Code/UI/AbilityCluster.cs index c34be5240385018a250325951385b45222398dd2..bda6f286c2bab56cac5f2af0474e2b4685ba0d1d 100644 --- a/MrBigsock/Assets/Code/UI/AbilityCluster.cs +++ b/MrBigsock/Assets/Code/UI/AbilityCluster.cs @@ -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); + } - } + } } diff --git a/MrBigsock/Assets/Prefabs/MapObjects/ClosedChest.prefab b/MrBigsock/Assets/Prefabs/MapObjects/ClosedChest.prefab index 273c687c80ae7a78c3f5739ac35259042aef0091..29f16eade20fc8fe6c7c517da7c15c17a514bcb9 100644 --- a/MrBigsock/Assets/Prefabs/MapObjects/ClosedChest.prefab +++ b/MrBigsock/Assets/Prefabs/MapObjects/ClosedChest.prefab @@ -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