Beispiel #1
0
 void AddItemDto(List <InventoryGridUi> list, InventoryItemDTO itemDto, InventoryGridUi gridUi)
 {
     for (int i = 0; i < list.Count; i++)
     {
         if (list[i].num == 0 || list[i].inventoryItemDto == null)
         {
             gridUi = list[i];
             break;
         }
     }
     if (gridUi != null)
     {
         GameObject prefab;
         if (ItemprefabPool.Count > 0)
         {
             prefab = ItemprefabPool.Pop();
             prefab.gameObject.SetActive(true);
         }
         else
         {
             prefab = Instantiate(itemprefab);
         }
         prefab.transform.SetParent(gridUi.gameObject.transform, false);
         prefab.transform.localScale    = Vector3.one;
         prefab.transform.localPosition = Vector3.zero;
         gridUi.SetInfo(itemDto);
     }
     else
     {
         WarrningManager.warringList.Add(new WarringModel("背包已满!", null, 2));
     }
 }
Beispiel #2
0
    public void SetInfo(InventoryItemDTO itemDto, InventoryGridUi gridUi, EquipGrid equipGrid, bool isEquip = false)
    {
        gameObject.SetActive(true);
        InventoryInfo._instance.gameObject.SetActive(false);
        transform.SetAsLastSibling();
        this.itemDto = itemDto;
        image.sprite = Resources.Load <Sprite>("Ui/Inventory/" + itemDto.inventory.icon);
        _name.text   = itemDto.inventory.name;
        if (isEquip)
        {
            this.equipGrid  = equipGrid;
            state.text      = "【已装备】";
            buttonText.text = "卸下";
        }
        else
        {
            this.gridUi     = gridUi;
            state.text      = "【未装备】";
            buttonText.text = "装备";
        }
        att.text = "攻击+" + itemDto.attack;
        def.text = "防御+" + itemDto.def;

        arm.text = "穿甲+" + itemDto.armour;

        exeCrit.text = "免暴+" + itemDto.exemptCrit;

        crit.text = "暴击+" + itemDto.crit;

        speed.text     = "速度+" + itemDto.speed;
        sell.text      = "出售 " + itemDto.inventory.sell;
        quality.text   = "品质 " + itemDto.quality;
        starLevel.text = "星级 " + itemDto.starLevel;
        info.text      = itemDto.inventory.info;
    }
Beispiel #3
0
 // Use this for initialization
 void Awake()
 {
     _instance = this;
     numText   = GetComponentInChildren <Text>();
     button    = GetComponent <Button>();
     button.onClick.AddListener(OnThisClick);
 }
Beispiel #4
0
    /// <summary>
    /// 服务器返回增加物品信息
    /// </summary>
    /// <param name="itemDto"></param>
    public void AddInventory(InventoryItemDTO itemDto)//增加物品
    {
        InventoryGridUi gridUi = null;

        if (itemDto.inventory.inventoryType == InventoryType.Equip)
        {
            AddItemDto(equipinventoryGridUis, itemDto, gridUi);
        }
        else if (itemDto.inventory.inventoryType == InventoryType.Drug)
        {
            for (int i = 0; i < druginventoryGridUis.Count; i++)
            {
                if (druginventoryGridUis[i].inventoryItemDto.id == itemDto.id)
                {
                    gridUi = druginventoryGridUis[i];
                    break;
                }
            }
            if (gridUi != null)
            {
                gridUi.UpdateNum(itemDto.count);
            }
            else
            {
                AddItemDto(druginventoryGridUis, itemDto, gridUi);
            }
        }
        else
        {
            for (int i = 0; i < restinventoryGridUis.Count; i++)
            {
                if (restinventoryGridUis[i].inventoryItemDto.id == itemDto.id)
                {
                    gridUi = restinventoryGridUis[i];
                    break;
                }
            }
            if (gridUi != null)
            {
                gridUi.UpdateNum(itemDto.count);
            }
            else
            {
                AddItemDto(restinventoryGridUis, itemDto, gridUi);
            }
        }
    }
Beispiel #5
0
    public void OnEndDrag(PointerEventData eventData)
    {
        //销毁图标
        if (dragedIcon != null)
        {
            Destroy(dragedIcon.gameObject);
        }

        GameObject go = eventData.pointerEnter;

        if (go != null)
        {
            if (go.tag == TAGS.ItemGrid)//拖到格子上
            {
                InventoryGridUi oldGrid = transform.parent.GetComponent <InventoryGridUi>();
                InventoryGridUi newGrid = go.GetComponent <InventoryGridUi>();
                transform.SetParent(go.transform, false);
                newGrid.SetInfo(oldGrid.inventoryItemDto);
                oldGrid.CleraInfo();
            }
            else if (go.tag == TAGS.Item && go != transform.gameObject)//拖到物品上且不是自己
            {
                InventoryItemDTO _itemDto;
                InventoryGridUi  oldGrid = transform.parent.GetComponent <InventoryGridUi>();
                InventoryGridUi  newGrid = go.transform.parent.GetComponent <InventoryGridUi>();
                _itemDto = oldGrid.inventoryItemDto;
                oldGrid.SetInfo(newGrid.inventoryItemDto);
                newGrid.SetInfo(_itemDto);
            }
            else if (go.tag == TAGS.Shortcut)//快捷栏
            {
                if (ItemDto.inventory.inventoryType == InventoryType.Drug)
                {
                    go.GetComponent <Shortcut>().SetInfo(ItemDto);
                }
            }
        }
        else
        {
        }
    }