/// <summary> /// Updates the slot if another slot with a different action is dropped on it /// </summary> public void OnDrop(PointerEventData eventData) { if (!GUIManager.Instance.Hotbar) { Debug.Log("No Hotbar GUI!"); return; } HotbarSlotGUI recieverSlot = eventData.pointerEnter.GetComponentInParent <HotbarSlotGUI>(); HotbarSlotGUI senderSlot = eventData.pointerDrag.GetComponentInParent <HotbarSlotGUI>(); if (!recieverSlot) { return; } if (recieverSlot == senderSlot) { return; } if (!recieverSlot.GetComponentInParent <Hotbar>()) { return; } // Save old action of slot reciever in case we are swapping action IHotbarAction auxAction = senderSlot.HotbarAction; // Check if we are swapping slots if (GUIManager.Instance.Hotbar.IsActionInHotbar(senderSlot.HotbarAction)) { GUIManager.Instance.Hotbar.InitializeSlot( GUIManager.Instance.Hotbar.indexOfAction(auxAction), recieverSlot.HotbarAction ); } recieverSlot.Initialize(auxAction); }
/// <summary> /// Given a hotbarAction, returns a dummy hotbarSlot to use for draggin visualization purposes. /// </summary> /// <param name="hAction">Hotbar action to be held by the dummy.</param> /// <returns>HotbarSlotGUI to be dragged around.</returns> public HotbarSlotGUI GetDummySlot(IHotbarAction hAction) { _dummySlot.Initialize(hAction); return(_dummySlot); }