/// <summary>
    /// Updates the item data by data.LocationID
    /// </summary>
    /// <param name='type'>
    /// Type.
    /// </param>
    /// <param name='data'>
    /// Data with right locatioID
    /// </param>
    public void UpdateItemData(ItemSlotType type, ItemSlotData data)
    {
        List <ItemSlotData> tList = GetItemDataList(type);

        bool t_found = false;

        for (int i = 0; i < tList.Count; i++)
        {
            ItemSlotData item = tList[i];

            if (item.LocationID == data.LocationID)
            {
                tList[i] = data;
                t_found  = true;
                break;
            }
        }

        if (!t_found)
        {
            tList.Add(data);
        }

        PackageUnit.UpdatePackageList(type);
    }
    /// <summary>
    /// Adds the item data.
    /// </summary>
    /// <param name='type'>
    /// Type.
    /// </param>
    /// <param name='data'>
    /// Data.
    /// </param>
    public void AddItemData(ItemSlotType type, ItemSlotData data)
    {
        List <ItemSlotData> tList = GetItemDataList(type);

        tList.Add(data);

        PackageUnit.UpdatePackageList(data.SlotType);
    }
Ejemplo n.º 3
0
    // refresh the package item
    public void UpdatePackageItem(ItemSlotType _type)
    {
        mCurrPackageType = _type;

        // clear the former selected item
        if (mCurrSelectedIconData != null)
        {
            mCurrSelectedIconData.checkButton.isChecked = false;
        }
        mCurrSelectedIconData = null;

        ItemTipsName.transform.localScale  = Vector3.one;
        ItemTipsMoney.transform.localScale = Vector3.one;
        ItemTipsDesc.transform.localScale  = Vector3.one;

        // foreach(AttributeIcon icon in ItemAttributeIcon){
        //  icon.transform.localScale = Vector3.one;
        // }

        // hide the operation button
        ShowOpBtn(null);

        List <ItemSlotData> tDataList = ItemDataManager.Instance.GetItemDataList(_type);

        for (int i = 0; i < mCurrIconItemList.Count; i++)
        {
            IconData t_iconData = mCurrIconItemList[i];

            t_iconData.checkButton.isChecked = false;

            bool t_setIcon = false;

            // add Dictionary.Values to List for iterating
            foreach (ItemSlotData data in tDataList)
            {
                if (data.LocationID == i)
                {
                    t_setIcon           = true;
                    t_iconData.itemData = data;
                    HelpUtil.SetItemIcon(t_iconData.checkButton.transform, t_iconData.itemData, !ShopSellItemPackage);
                    break;
                }
            }

            if (!t_setIcon)
            {
                t_iconData.itemData            = new ItemSlotData();
                t_iconData.itemData.LocationID = i;
                t_iconData.itemData.SlotType   = _type;
                t_iconData.itemData.SlotState  = ItemSlotState.LOCK;
                HelpUtil.SetItemIcon(t_iconData.checkButton.transform, null, !ShopSellItemPackage);
            }
        }

        mCurrSelPageIndicatorIdx = 0;

        // SetPackageHighLight(HighLightRule.HIGHLIGHT_NONE);
    }
    public ItemSlotData GetItemDataByGUID(ItemSlotType type, long guiID)
    {
        List <ItemSlotData> tList = GetItemDataList(type);

        foreach (ItemSlotData item in tList)
        {
            if (item.MItemData != null && item.MItemData.ItemID == guiID)
            {
                return(item);
            }
        }

        return(null);
    }
    /// <summary>
    /// Gets the item data.
    /// </summary>
    /// <returns>
    /// The item data.
    /// </returns>
    /// <param name='iType'>
    /// type of
    /// </param>
    /// <param name='iLocationID'>
    /// I location I.
    /// </param>
    public ItemSlotData GetItemData(ItemSlotType type, int locationID)
    {
        List <ItemSlotData> tList = GetItemDataList(type);

        foreach (ItemSlotData item in tList)
        {
            if (item.LocationID == locationID)
            {
                return(item);
            }
        }

        return(null);
    }
    /// <summary>
    /// Removes the item data.
    /// </summary>
    /// <param name='type'>
    /// Type.
    /// </param>
    /// <param name='locationID'>
    /// Location ID
    /// </param>
    public void RemoveItemData(ItemSlotType type, int locationID)
    {
        List <ItemSlotData> tList = GetItemDataList(type);

        foreach (ItemSlotData item in tList)
        {
            if (item.LocationID == locationID)
            {
                tList.Remove(item);
                PackageUnit.UpdatePackageList(type);
                break;
            }
        }
    }
        private void ItemSlotOnClickDelegateFunction(int index, ItemSlotType itemSlotType)
        {
            ItemSlotDTO itemSlotDTO = this.itemSlotCollectionDTOs[itemSlotType].ItemSlotDTOs[index];

            if (itemSlotDTO.HasItem && itemSlotDTO.ItemSlotRawImage.texture != null)
            {
                //The cursor has no texture yet, but the source has it
                if (CursorInputWrapper.CursorItemTexture == null)
                {
                    CursorInputWrapper.CursorItemTexture     = itemSlotDTO.ItemSlotRawImage.texture;
                    CursorInputWrapper.OriginalInventoryItem = itemSlotDTO.OriginalInventoryItem;

                    //Clear out the item slot texture after it was clicked
                    itemSlotDTO.ItemSlotRawImage.texture = null;
                    itemSlotDTO.HasItem = false;
                    itemSlotDTO.OriginalInventoryItem = default;
                }
                //The source and destination both have a texture
                else if (CanBePlacedInSlot(itemSlotType))
                {
                    //Swap the textures if target has a texture (target is itemSlotDto in this case)
                    Texture       tempTexture       = itemSlotDTO.ItemSlotRawImage.texture;
                    InventoryItem tempInventoryItem = itemSlotDTO.OriginalInventoryItem;

                    itemSlotDTO.ItemSlotRawImage.texture = CursorInputWrapper.CursorItemTexture;
                    itemSlotDTO.OriginalInventoryItem    = CursorInputWrapper.OriginalInventoryItem;
                    itemSlotDTO.HasItem = true;

                    CursorInputWrapper.CursorItemTexture     = tempTexture;
                    CursorInputWrapper.OriginalInventoryItem = tempInventoryItem;
                }
            }
            //Destination has no item yet (cursor already has a texture)
            else if (CursorInputWrapper.CursorItemTexture != null && CanBePlacedInSlot(itemSlotType))
            {
                //Target item slot has no texture so set it and then "remove" the cursor item texture (set to null)
                itemSlotDTO.ItemSlotRawImage.texture = CursorInputWrapper.CursorItemTexture;
                itemSlotDTO.OriginalInventoryItem    = CursorInputWrapper.OriginalInventoryItem;
                itemSlotDTO.HasItem = true;
                CursorInputWrapper.CursorItemTexture = null;
            }

            //Force the player equip system to re-evaluate the item slot dto
            itemSlotDTO.IsEquippedToPlayer = false;

            this.itemSlotCollectionDTOs[itemSlotType].ItemSlotDTOs[index] = itemSlotDTO;
        }
    /// <summary>
    /// Gets the item data list.
    /// </summary>
    /// <returns>
    /// The item data list.
    /// </returns>
    /// <param name='type'>
    /// Type. item solt type
    /// </param>
    public List <ItemSlotData> GetItemDataList(ItemSlotType iType)
    {
        List <ItemSlotData> tList;

        if (!mItemDataListArray.ContainsKey(iType))
        {
            // new a list
            //
            tList = new List <ItemSlotData>();
            mItemDataListArray.Add(iType, tList);
        }
        else
        {
            tList = mItemDataListArray[iType];
        }

        return(tList);
    }
Ejemplo n.º 9
0
    /// <summary>
    /// Updates the package list if some item of this type was changed

    /// </summary>
    /// <param name='type'>
    /// Type.
    /// </param>
    public static void UpdatePackageList(ItemSlotType type)
    {
        for (int i = 0; i < smPackageUnitList.Count; i++)
        {
            if (smPackageUnitList[i].mCurrPackageType == type)
            {
                smPackageUnitList[i].UpdatePackageItem(type);

                if (smPackageUnitList[i].mPackageItemDataDelegate != null)
                {
                    try{
                        smPackageUnitList[i].mPackageItemDataDelegate(smPackageUnitList[i]);
                    }catch (System.Exception ex) {
                        Debug.LogError(ex.Message);
                    }
                }
            }
        }
    }
        private bool CanBePlacedInSlot(ItemSlotType destinationType)
        {
            switch (destinationType)
            {
            //Every item can be placed in the item slot
            case ItemSlotType.Item:
                return(true);

            case ItemSlotType.Weapon:
                return(CursorInputWrapper.OriginalInventoryItem.ItemInfo.IsWeapon);

            case ItemSlotType.Shield:
                return(CursorInputWrapper.OriginalInventoryItem.ItemInfo.IsShield);
                //No default case because we compare against a enum
                //TODO: Add cases
            }

            //TODO: Remove
            return(false);
        }
 /// <summary>
 /// Removes the item data list.
 /// </summary>
 /// <param name='type'>
 /// Type.
 /// </param>
 public void RemoveItemDataList(ItemSlotType type)
 {
     GetItemDataList(type).Clear();
     PackageUnit.UpdatePackageList(type);
 }
 public void RegisterItemSlotCollectionDTO(ItemSlotType itemSlotType, ItemSlotCollectionDTO itemSlotCollectionDTO)
 {
     this.itemSlotCollectionDTOs.Add(itemSlotType, itemSlotCollectionDTO);
     itemSlotCollectionDTO.ItemSlotDTOs.ForEach(itemSlotDTO => this.AddOnClickDelegateFunction(itemSlotDTO, itemSlotType));
 }
Ejemplo n.º 13
0
 public ItemData(ItemData Clone)
 {
     this.Name = Clone.Name;
     this.Location = Clone.Location;
     this.Type = Clone.Type;
     this.Attribute.ADK = Clone.Attribute.ADK;
     this.Attribute.ATK = Clone.Attribute.ATK;
     this.Attribute.CRI = Clone.Attribute.CRI;
     this.Attribute.DEF = Clone.Attribute.DEF;
     this.Attribute.HP = Clone.Attribute.HP;
     this.Attribute.MP = Clone.Attribute.MP;
     this.Attribute.HpReply = Clone.Attribute.HpReply;
     this.Attribute.MpReply = Clone.Attribute.MpReply;
     this.Amount = Clone.Amount;
     this.Description = Clone.Description;
 }
Ejemplo n.º 14
0
    /// <summary>
    /// Set Some of ItemList to HighLight by a Rule. by hxl 20121214
    /// Sets the package high light.
    /// </summary>
    /// <param name='rule'>
    /// Rule. Set HighLight by Item Lock UnLock ...
    /// </param>
    /// <param name='logicID'>
    /// Logic I.Set HighLight by a Special Item's logicIDID
    /// </param>
    /// <param name='type'>
    /// Type. Set HighLight by a Special Item's type
    /// </param>
    public void SetPackageHighLight(HighLightRule rule, int logicID = 0, ItemSlotType type = ItemSlotType.NUM)
    {
        for (int i = 0; i < mCurrIconItemList.Count; i++)
        {
            IconData t_iconData = mCurrIconItemList[i];

            t_iconData.itemIcon.SetItemHighLight(false);

            //
            if (t_iconData.checkButton.isChecked)
            {
                continue;
            }

            // Logic by logicID
            if (logicID != 0 && t_iconData.itemData.MItemData != null && t_iconData.itemData.MItemData.BasicData.LogicID != logicID)
            {
                continue;
            }

            // Logic by type
            if (type != ItemSlotType.NUM && t_iconData.itemData.SlotType != type)
            {
                continue;
            }

            // Logic by rule
            if (rule == HighLightRule.HIGHLIGHT_LOCK)
            {
                if (t_iconData.itemData.IsUnLock())
                {
                    continue;
                }
            }
            else if (rule == HighLightRule.HIGHLIGHT_UNLOCK)
            {
                if (!t_iconData.itemData.IsUnLock())
                {
                    continue;
                }
            }
            else if (rule == HighLightRule.HIGHLIGHT_NULL)
            {
                if (t_iconData.itemData.MItemData != null || !t_iconData.itemData.IsUnLock())
                {
                    continue;
                }
            }
            else if (rule == HighLightRule.HIGHLIGHT_NOTNULL)
            {
                if (t_iconData.itemData.MItemData == null)
                {
                    continue;
                }
            }
            else if (rule == HighLightRule.HIGHLIGHT_NONE)
            {
                continue;
            }

            t_iconData.itemIcon.SetItemHighLight(true);
        }
    }
Ejemplo n.º 15
0
 public void Hightlight(ItemSlotType type)
 {
 }
 private void RemoveOnClickDelegateFunction(ItemSlotDTO itemSlotDTO, ItemSlotType itemSlotType)
 {
     itemSlotDTO.ItemSlotButton.onClick.RemoveListener(delegate { ItemSlotOnClickDelegateFunction(itemSlotDTO.Index, itemSlotType); });
 }
Ejemplo n.º 17
0
 public void Hightlight(ItemSlotType type)
 {
 }
 /// <summary>
 /// Removes the item data by the type and data LocationID
 /// </summary>
 /// <param name='type'>
 /// Type.
 /// </param>
 /// <param name='data'>
 /// Data.
 /// </param>
 public void RemoveItemData(ItemSlotType type, ItemSlotData data)
 {
     RemoveItemData(type, data.LocationID);
     PackageUnit.UpdatePackageList(data.SlotType);
 }
Ejemplo n.º 19
0
 public void UpdateSlot(Int32 cid, ItemSlotType slot, Int32 itemid)
 {
     Execute(string.Format("UPDATE `character` SET {0}={1} WHERE CID={2}", slot, itemid, cid));
 }
Ejemplo n.º 20
0
 public ItemComponent(Atom atom, ItemSlotType slotType = ItemSlotType.None)
 {
     SlotType = slotType;
 }