public void OnPointerClick(PointerEventData eventData) { //Debug.Log("slot clicked"); hotbarGUI.exitToolTip(); if (player.InCombat && isSlotted) //in combat, do combat things { AttackDetails details = new AttackDetails(skill.GetComponent <AttackDetailsInstance>()); manager.AttackHelper(details); } else //not in combat, customization of hotbar { if (slotNumber < 10) //can only use slots 0-9 { //Equipping from skill manager, not in bar already if (eventData.pointerId == -1 && skillManager.IsBeingDragged) { if (ActiveOrPassive(skillManager.getDraggedItem().GetComponent <AttackDetailsInstance>().Type)) { skill = skillManager.getDraggedItem(); int id = skill.GetComponent <AttackDetailsInstance>().ID; //If this skill is already equipped, unequip it int currentSlot = hotbarGUI.GetSlot(id, slotNumber); if (currentSlot >= 0) { var hbs = hotbarGUI.HotbarSlots[currentSlot].GetComponent <HotBarSlot>(); hbs.skill = null; hbs.GetComponent <Image>().sprite = defaultIcon; hbs.isSlotted = false; } //Equip this skill in the specified slot GetComponent <Image>().sprite = skill.GetComponent <AttackDetailsInstance>().Icon; isSlotted = true; db.UpdateSkill(id, slotNumber, ActiveSkillbar); skillManager.DeleteDraggedItem(); } } //Equipping from hot bar to... else { //Empty space (unequip) if (eventData.pointerId == -1 && isSlotted && !hotbarGUI.isBeingDragged) { hotbarGUI.showDraggedItem(skill, slotNumber); int skillId = skill.GetComponent <AttackDetailsInstance>().ID; skill = null; GetComponent <Image>().sprite = defaultIcon; isSlotted = false; db.UpdateSkill(skillId, -1, ActiveSkillbar); } //To empty hotbar slot else if (eventData.pointerId == -1 && !isSlotted && hotbarGUI.isBeingDragged) { if (ActiveOrPassive(hotbarGUI.DraggedItem.GetComponent <AttackDetailsInstance>().Type)) { skill = hotbarGUI.DraggedItem; GetComponent <Image>().sprite = skill.GetComponent <AttackDetailsInstance>().Icon; hotbarGUI.deleteDraggedItem(); isSlotted = true; db.UpdateSkill(skill.GetComponent <AttackDetailsInstance>().ID, slotNumber, ActiveSkillbar); } } //To occupied hotbar slot (swap the skills) else if (eventData.pointerId == -1 && isSlotted && hotbarGUI.isBeingDragged) { if (ActiveOrPassive(hotbarGUI.DraggedItem.GetComponent <AttackDetailsInstance>().Type)) { hotbarGUI.HotbarSlots[hotbarGUI.slotnumber].GetComponent <HotBarSlot>().skill = skill; hotbarGUI.HotbarSlots[hotbarGUI.slotnumber].GetComponent <Image>().sprite = skill.GetComponent <AttackDetailsInstance>().Icon; hotbarGUI.HotbarSlots[hotbarGUI.slotnumber].GetComponent <HotBarSlot>().isSlotted = true; skill = hotbarGUI.DraggedItem; isSlotted = true; GetComponent <Image>().sprite = skill.GetComponent <AttackDetailsInstance>().Icon; hotbarGUI.deleteDraggedItem(); db.UpdateSkill(hotbarGUI.HotbarSlots[hotbarGUI.slotnumber].GetComponent <HotBarSlot>().skill.GetComponent <AttackDetailsInstance>().ID, hotbarGUI.slotnumber, ActiveSkillbar); db.UpdateSkill(skill.GetComponent <AttackDetailsInstance>().ID, slotNumber, ActiveSkillbar); } } } } } }