示例#1
0
    internal void UpdateToThisInv(Inventory inventory)
    {
        Inv = inventory;
        Inv.OrderItemsAlpha();

        var iForSpwItem = 0;//so ReturnIniPos works nicely

        for (int i = 0; i < _inv.InventItems.Count; i++)
        {
            //> 0 for main so only show items tht have some
            if (_inv.InventItems[i] != null && _inv.InventItems[i].Amount > 0)
            {
                //is a brand new item
                if (_allItems.Count <= i && !DoWeHaveThatKeyAlready(_inv.InventItems[i].Key))
                {
                    _allItems.Add(ShowInvetoryItem.Create(_containr.transform, _inv.InventItems[i], ReturnIniPos(iForSpwItem),
                                                          this, _invType));
                }
                else if (_allItems[i].InvItem1.Key != _inv.InventItems[i].Key)
                {
                    //updates the item
                    _allItems[i].UpdateToThis(_inv.InventItems[i], ReturnIniPos(iForSpwItem));
                }

                iForSpwItem++;
            }
        }
        FinalReposition();
    }
示例#2
0
    static public ShowInvetoryItem Create(Transform container, InvItem invItem, Vector3 iniPos, ShowAInventory parent,
                                          string invType = "")
    {
        ShowInvetoryItem obj = null;
        var root             = "";

        if (string.IsNullOrEmpty(invType))
        {
            root = Root.show_Invent_Item_Small_3_Text + " 2";
        }
        else if (invType == "Bulletin.Prod.Report")
        {
            root = Root.show_Invent_Item_Small_3_Text + " 4";
        }
        else
        {
            //for
            root = Root.show_Invent_Item_Small_Med + " 2";
        }

        obj = (ShowInvetoryItem)Resources.Load(root, typeof(ShowInvetoryItem));
        obj = Instantiate(obj, container.transform);

        if (obj.InitialPositionPoint != null && obj.InitialPositionPoint.position != new Vector3())
        {
            obj.transform.SetParent(container);
            obj.transform.localPosition = obj.InitialPositionPoint.localPosition;
        }

        obj.Parent   = parent;
        obj.InvItem1 = invItem;
        obj.InvType  = invType;

        return(obj);
    }
示例#3
0
    internal void Destroy(ShowInvetoryItem showInvetoryItem)
    {
        _allItems.Remove(showInvetoryItem);
        showInvetoryItem.Destroy();

        //if a tile is destroyed needs to update
        UpdateToThisInv(Inv);
    }
示例#4
0
    private void ShowAllItems( )
    {
        //bridge for ex
        if (Inv == null)
        {
            return;
        }

        _oldVolumeOccupied = Inv.CurrentVolumeOcuppied();
        var iForSpwItem = 0;//so ReturnIniPos works nicely

        for (int i = 0; i < _inv.InventItems.Count; i++)
        {
            //> 0 for main so only show items tht have some
            if (_inv.InventItems[i] != null && _inv.InventItems[i].Amount > 0)
            {
                _allItems.Add(ShowInvetoryItem.Create(_containr.transform, _inv.InventItems[i], ReturnIniPos(iForSpwItem),
                                                      this, _invType));

                iForSpwItem++;
            }
        }
    }
示例#5
0
    static public ShowInvetoryItem Create(Transform container, InvItem invItem, Vector3 iniPos, ShowAInventory parent,
                                          string invType = "")
    {
        ShowInvetoryItem obj = null;
        var root             = "";

        if (string.IsNullOrEmpty(invType))
        {
            root = Root.show_Invent_Item_Small_3_Text + " 2";
        }
        else
        {
            //for main
            root = Root.show_Invent_Item_Small_Med + " 2";
        }
        obj = (ShowInvetoryItem)Resources.Load(root, typeof(ShowInvetoryItem));
        obj = (ShowInvetoryItem)Instantiate(obj, new Vector3(), Quaternion.identity);


        //var iniScale = obj.transform.localScale;
        //obj.transform.SetParent(container);
        //obj.transform.localPosition = iniPos;
        //obj.transform.localScale = iniScale;

        obj.transform.SetParent(container);

        //CorrectLocalScaleBasedOnScreenSize(obj.transform);

        obj.transform.localPosition = iniPos;

        obj.Parent   = parent;
        obj.InvItem1 = invItem;
        obj.InvType  = invType;

        return(obj);
    }