void Update() { if (!_setSlot) { _slot = GetObject.PlayerCharacter.SkillHandler.Slots[SkillSlot]; _setSlot = true; } bool hasCd = false; if (_slot.InUse) { var cooldownPercent = 0f; if (_slot.IsItem) { var consum = _slot.Item as Consumable; if (consum != null && consum.CurrentCooldown > 0) { cooldownPercent = consum.CurrentCooldown / consum.Cooldown; hasCd = true; } } else { var skill = _slot.Skill; if (skill.CurrentCoolDownTime > 0) { cooldownPercent = skill.CurrentCoolDownTime / skill.CoolDownTime; hasCd = true; } } if (hasCd) { CooldownOverlay.color = CooldownColor; CooldownOverlay.fillAmount = cooldownPercent; } } if (!hasCd) { if (CooldownOverlay != null) { CooldownOverlay.color = Color.clear; } } if (_pointerDown) { _slot.Use(); } }
private void Start() { foreach (var item in GetComponentsInChildren <DraggableButton>()) { item.OnDrop.AddListener((ev) => { SkillBarSlot slot = item.GetComponentInParent <SkillBarSlot>(); DraggableButton dragged = ev.pointerDrag.GetComponent <DraggableButton>(); slot.Fill(dragged.GetComponentInParent <SkillButton>().skillId); }); } slots = GetComponentsInChildren <SkillBarSlot>().ToList(); for (int i = 0; i < slots.Count; i++) { slots[i].SetHotkey((i + 1).ToString()); } }
void Update() { if (Input.GetKeyDown(KeyCode.Alpha1)) { SkillBarSlot slot = skillBarSlot[0]; if (slot.GetComponentInChildren <Button>().interactable == true) { playerAttacks.Invoke(slot.Use(), 0); StartCoroutine(slot.Countdown()); } } if (Input.GetKeyDown(KeyCode.Alpha2)) { SkillBarSlot slot = skillBarSlot[1]; if (slot.GetComponentInChildren <Button>().interactable == true) { playerAttacks.Invoke(slot.Use(), 0); StartCoroutine(slot.Countdown()); } } if (Input.GetKeyDown(KeyCode.Alpha3)) { SkillBarSlot slot = skillBarSlot[2]; if (slot.GetComponentInChildren <Button>().interactable == true) { playerAttacks.Invoke(slot.Use(), 0); StartCoroutine(slot.Countdown()); } } if (Input.GetKeyDown(KeyCode.Alpha4)) { SkillBarSlot slot = skillBarSlot[3]; if (slot.GetComponentInChildren <Button>().interactable == true) { playerAttacks.Invoke(slot.Use(), 0); StartCoroutine(slot.Countdown()); } } if (Input.GetKeyDown(KeyCode.Alpha5)) { SkillBarSlot slot = skillBarSlot[4]; if (slot.GetComponentInChildren <Button>().interactable == true) { playerAttacks.Invoke(slot.Use(), 0); StartCoroutine(slot.Countdown()); } } if (Input.GetKeyDown(KeyCode.Alpha6)) { SkillBarSlot slot = skillBarSlot[5]; if (slot.GetComponentInChildren <Button>().interactable == true) { playerAttacks.Invoke(slot.Use(), 0); StartCoroutine(slot.Countdown()); } } if (Input.GetKeyDown(KeyCode.Alpha7)) { SkillBarSlot slot = skillBarSlot[6]; if (slot.GetComponentInChildren <Button>().interactable == true) { playerAttacks.Invoke(slot.Use(), 0); StartCoroutine(slot.Countdown()); } } if (Input.GetKeyDown(KeyCode.Alpha8)) { SkillBarSlot slot = skillBarSlot[7]; if (slot.GetComponentInChildren <Button>().interactable == true) { playerAttacks.Invoke(slot.Use(), 0); StartCoroutine(slot.Countdown()); } } if (Input.GetKeyDown(KeyCode.Alpha9)) { SkillBarSlot slot = skillBarSlot[8]; if (slot.GetComponentInChildren <Button>().interactable == true) { playerAttacks.Invoke(slot.Use(), 0); StartCoroutine(slot.Countdown()); } } if (Input.GetKeyDown(KeyCode.Alpha0)) { SkillBarSlot slot = skillBarSlot[9]; if (slot.GetComponentInChildren <Button>().interactable == true) { playerAttacks.Invoke(slot.Use(), 0); StartCoroutine(slot.Countdown()); } } }