private void SetupUIElements() { //Setup all available abilities for (int i = 0; i < allAbilities.Count; i++) { Transform slot = availableAbilitiesContainer.GetChild(i); AbilityUIElement element = slot.GetComponentInChildren <AbilityUIElement>(); element.Setup(allAbilities[i]); } }
private void CancelDrag(AbilityUIElement abilityUIElement) { int index = tempUISlot.transform.GetSiblingIndex(); Transform parent = tempUISlot.transform.parent; abilityUIElement.transform.SetParent(parent, false); abilityUIElement.transform.SetSiblingIndex(index); tempUISlot.transform.SetParent(transform); tempUISlot.SetActive(false); }
public void BeginDrag(AbilityUIElement abilityUIElement) { int index = abilityUIElement.transform.GetSiblingIndex(); Transform parent = abilityUIElement.transform.parent; abilityUIElement.transform.SetParent(transform, false); tempUISlot.transform.SetParent(parent, false); tempUISlot.transform.SetSiblingIndex(index); tempUISlot.SetActive(true); }
private AbilityUIElement GetEmptySlot(Transform parent) { for (int i = 0; i < parent.childCount; i++) { AbilityUIElement ui = parent.GetChild(i).GetComponent <AbilityUIElement>(); if (ui.IsEmpty) { return(ui); } } Debug.LogError("There is no empty slot"); return(null); }
public void EndDrag(AbilityUIElement abilityUIElement, GameObject onto) { if (onto == null) { //Debug.Log("EndDrag onto nothing"); CancelDrag(abilityUIElement); return; } if (onto.GetComponent <AbilityUIElement>() != null) { if (onto == tempUISlot) { //Debug.Log("Same object"); CancelDrag(abilityUIElement); return; } //Debug.Log("EndDrag onto another element"); AbilityUIElement other = onto.GetComponent <AbilityUIElement>(); CancelDrag(abilityUIElement); if (other.IsEmpty) { other.Setup(abilityUIElement.ability); abilityUIElement.Reset(); } else { SpecialAttack temp = other.ability; other.Setup(abilityUIElement.ability); abilityUIElement.Setup(temp); } } else if (onto.transform == availableAbilitiesContainer || onto.transform == selectedAbilitiesContainer) { Debug.Log("EndDrag onto container"); CancelDrag(abilityUIElement); GetEmptySlot(onto.transform).Setup(abilityUIElement.ability); abilityUIElement.Reset(); } else { CancelDrag(abilityUIElement); } ShowHideStartButton(); }
public void Move(AbilityUIElement abilityUI) { AbilityUIElement newSlot = null; if (abilityUI.transform.parent == availableAbilitiesContainer && NotEmptyAmount(selectedAbilitiesContainer) < amountToSelect) { newSlot = GetEmptySlot(selectedAbilitiesContainer); } else if (abilityUI.transform.parent == selectedAbilitiesContainer) { newSlot = GetEmptySlot(availableAbilitiesContainer); } if (newSlot == null) { Debug.Log("Can't find empty slot"); } newSlot.Setup(abilityUI.ability); abilityUI.Reset(); ShowHideStartButton(); }