Esempio n. 1
0
    void Start()
    {
        if (this.slot == null)
        {
            this.slot = this.GetComponent <RnMUI_EquipSlot>();
        }

        if (this.slot == null || this.itemDatabase == null)
        {
            this.Destruct();
            return;
        }

        this.slot.Assign(this.itemDatabase.GetByID(this.assignItem));
        this.Destruct();
    }
Esempio n. 2
0
    public override void OnInspectorGUI()
    {
        EditorGUIUtility.labelWidth = 120f;
        EditorGUILayout.Space();

        RnMUI_EquipSlot slot = target as RnMUI_EquipSlot;

        UIEquipmentType eType = (UIEquipmentType)EditorGUILayout.EnumPopup("Equip Type", slot.equipType);

        if (eType != slot.equipType)
        {
            slot.equipType = eType;
        }

        DrawTargetSprite();
        //DrawDragAndDrop();
        DrawBehaviour();
    }
Esempio n. 3
0
    /// <summary>
    /// Handles the drop on custom surface.
    /// </summary>
    /// <returns><c>true</c>, if custom surface was handled, <c>false</c> otherwise.</returns>
    /// <param name="surface">Surface.</param>
    protected override bool HandleCustomSurface(GameObject surface)
    {
        // Get the quip receiver
        RnMUI_EquipReceiver EquipReceiver = surface.GetComponent <RnMUI_EquipReceiver>();

        if (EquipReceiver != null)
        {
            // Try finding a suitable slot for the quip
            RnMUI_EquipSlot targetSlot = EquipReceiver.GetSlotByType(this.GetItemInfo().EquipType);

            // Check if the slot was found
            if (targetSlot != null)
            {
                // Normal empty slot assignment
                if (!targetSlot.IsAssigned())
                {
                    // Assign the target slot with the info from this one
                    if (targetSlot.Assign(this))
                    {
                        this.Unassign();
                    }
                }
                // The target slot is assigned
                else
                {
                    // Check if we can swap
                    if (this.CanSwapWith(targetSlot))
                    {
                        // Swap the slots
                        this.PerformSlotSwap(targetSlot);
                    }
                }
            }

            // Return custom surface handled
            return(true);
        }

        // No custom surface was handled
        return(false);
    }
Esempio n. 4
0
    /// <summary>
    /// Assign the slot by the passed source slot.
    /// </summary>
    /// <param name="source">Source.</param>
    public override bool Assign(Object source)
    {
        if (source is RnMUI_ItemSlot)
        {
            RnMUI_ItemSlot sourceSlot = source as RnMUI_ItemSlot;

            if (sourceSlot != null)
            {
                // 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 RnMUI_EquipSlot)
        {
            RnMUI_EquipSlot sourceSlot = source as RnMUI_EquipSlot;

            if (sourceSlot != null)
            {
                // Check if the equipment type matches the target slot
                if (!this.CheckEquipType(sourceSlot.GetItemInfo()))
                {
                    return(false);
                }

                // Type matches
                return(this.Assign(sourceSlot.GetItemInfo()));
            }
        }

        // Default
        return(false);
    }
Esempio n. 5
0
    /// <summary>
    /// Assign the slot by the passed source slot.
    /// </summary>
    /// <param name="source">Source.</param>
    public override bool Assign(Object source)
    {
        if (source is RnMUI_ItemSlot)
        {
            RnMUI_ItemSlot sourceSlot = source as RnMUI_ItemSlot;

            if (sourceSlot != null)
            {
                return(this.Assign(sourceSlot.GetItemInfo()));
            }
        }
        else if (source is RnMUI_EquipSlot)
        {
            RnMUI_EquipSlot sourceSlot = source as RnMUI_EquipSlot;

            if (sourceSlot != null)
            {
                return(this.Assign(sourceSlot.GetItemInfo()));
            }
        }

        // Default
        return(false);
    }