#pragma warning restore 0649 void Awake() { if (this.slot == null) { this.slot = this.GetComponent <UIEquipSlot>(); } }
/// <summary> /// Assign the slot by the passed source slot. /// </summary> /// <param name="source">Source.</param> public override bool Assign(Object source) { if (source is UIItemSlot) { UIItemSlot sourceSlot = source as UIItemSlot; // Check if the equipment type matches the target slot if (!this.CheckEquipType(sourceSlot.GetItemInfo())) { return(false); } return(this.Assign(sourceSlot.GetItemInfo())); } else if (source is UIEquipSlot) { UIEquipSlot sourceSlot = source as UIEquipSlot; // Check if the equipment type matches the target slot if (!this.CheckEquipType(sourceSlot.GetItemInfo())) { return(false); } return(this.Assign(sourceSlot.GetItemInfo())); } // Default return(false); }
/// <summary> /// Raises the drop event. /// </summary> /// <param name="eventData">Event data.</param> public void OnDrop(PointerEventData eventData) { if (eventData.pointerPress == null) { return; } // Try getting slot base component from the selected object UISlotBase slotBase = this.ExtractSlot(eventData); // Check if we have a slot if (slotBase == null) { return; } // Determine the type of slot we are dropping here if (slotBase is UIItemSlot) { UIItemSlot itemSlot = (slotBase as UIItemSlot); // Make sure the slot we are dropping is valid and assigned if (itemSlot != null && itemSlot.IsAssigned()) { // Try finding a suitable slot to equip UIEquipSlot equipSlot = this.GetSlotByType(itemSlot.GetItemInfo().EquipType); if (equipSlot != null) { // Use the drop event to handle equip equipSlot.OnDrop(eventData); // Hide the hint this.HideHint(); // Break out of the method return; } } } }
/// <summary> /// Raises the tooltip event. /// </summary> /// <param name="show">If set to <c>true</c> show.</param> public override void OnTooltip(bool show) { UITooltip.InstantiateIfNecessary(this.gameObject); // Handle unassigned if (!this.IsAssigned()) { // If we are showing the tooltip if (show) { UITooltip.AddTitle(UIEquipSlot.EquipTypeToString(this.m_EquipType)); UITooltip.SetHorizontalFitMode(ContentSizeFitter.FitMode.PreferredSize); UITooltip.AnchorToRect(this.transform as RectTransform); UITooltip.Show(); } else { UITooltip.Hide(); } } else { // Make sure we have spell info, otherwise game might crash if (this.m_ItemInfo == null) { return; } // If we are showing the tooltip if (show) { UIItemSlot.PrepareTooltip(this.m_ItemInfo); UITooltip.AnchorToRect(this.transform as RectTransform); UITooltip.Show(); } else { UITooltip.Hide(); } } }
/// <summary> /// Assign the slot by the passed source slot. /// </summary> /// <param name="source">Source.</param> public override bool Assign(Object source) { if (source is UIItemSlot) { UIItemSlot sourceSlot = source as UIItemSlot; if (sourceSlot != null) { return(this.Assign(sourceSlot.GetItemInfo())); } } else if (source is UIEquipSlot) { UIEquipSlot sourceSlot = source as UIEquipSlot; if (sourceSlot != null) { return(this.Assign(sourceSlot.GetItemInfo())); } } // Default return(false); }