public void ClearSelection()
 {
     if (null != _lastSelectSlot)
     {
         _lastSelectSlot.GodIgnoreMe();
     }
     _lastSelectSlot = null;
 }
Example #2
0
    public void Refresh(ItemInventory selectedItem, List <ItemInventory> itemsList)
    {
        //if not in active. do nothing!(fix it sooner or later by caizilong)
        if (!_pageDirty || !gameObject.activeInHierarchy)//need not refresh
        {
            return;
        }
        int fromIndex = PageIndex * ItemsSlots.Length;
        List <FCUIInventorySlot> noIconSlots = new List <FCUIInventorySlot>();

        for (int i = 0, count = SlotsCount; i < count; ++i)
        {
            FCUIInventorySlot slot = ItemsSlots[i];
            if (itemsList.Count > i + fromIndex && fromIndex + i >= 0)
            {
                ItemInventory item = itemsList[fromIndex + i];
                slot.Item = item;
                if (!slot.RefreshComplete)
                {
                    noIconSlots.Add(slot);
                }
                slot.gameObject.SetActive(true);
                if (item == selectedItem)
                {
                    slot.GodSelectedMe();
                }
                else
                {
                    slot.GodIgnoreMe();
                }
            }
            else
            {
                slot.gameObject.SetActive(false);
                slot.Item = null;
                slot.GodIgnoreMe();
            }
        }
        StartCoroutine(StepRefreshIcons(noIconSlots));
        //Debug.Log(gameObject.name + ":refreshed!");
        _pageDirty = false;
    }
    void OnClickEquipmentOnBody(GameObject go)
    {
        FCUIInventorySlot slot = go.GetComponent <FCUIInventorySlot>();
        ItemInventory     item = slot.Item;

        if (null != item)
        {
            if (FCUIInventory.Instance.CurrentSelectionItem != item)
            {
                FCUIInventory.Instance.CurrentSelectionItem = item;
                FCUIInventory.Instance.OnSwithToItemInfo();
                if (null != _lastSelectSlot)
                {
                    _lastSelectSlot.GodIgnoreMe();
                }
                slot.GodSelectedMe();
            }
            else
            {
                FCUIInventory.Instance.CurrentSelectionItem = null;
                FCUIInventory.Instance.OnResumeDefaultLayout();
                if (null != _lastSelectSlot)
                {
                    _lastSelectSlot.GodIgnoreMe();
                }
            }
        }
        else
        {
            FCUIInventory.Instance.CurrentSelectionItem = null;
            FCUIInventory.Instance.OnResumeDefaultLayout();
            if (null != _lastSelectSlot)
            {
                _lastSelectSlot.GodIgnoreMe();
            }
        }
        _lastSelectSlot = slot;
    }