Exemplo n.º 1
0
    private void PlaceItem(GridItem item)
    {
        if (item.Orientation == GridItemOrient.Landscape)
        {
            item.Sprite.pivot = UIWidget.Pivot.BottomLeft;
        }
        else
        {
            item.Sprite.pivot = UIWidget.Pivot.TopLeft;
        }

        item.Sprite.transform.parent = item.Boundary.transform.parent;
        item.Sprite.depth            = (int)InventoryItemDepth.Normal;

        item.transform.localPosition = item.Boundary.transform.localPosition;
        InventoryGrid grid = item.transform.parent.GetComponent <InventoryGrid>();

        grid.GetColumnRowFromLocalPos(item.transform.localPosition, out item.ColumnPos, out item.RowPos);

        item.Quantity.transform.parent        = item.Sprite.transform.parent;
        item.Quantity.transform.localPosition = item.Sprite.transform.localPosition + new Vector3(4, 4, 0);

        NGUITools.AddWidgetCollider(item.gameObject);
        NGUITools.MarkParentAsChanged(_windowPanel.gameObject);
        //item.State = GridItemState.None;
        item.Initialize(FocusedGrid);
        FocusedGrid.Items.Add(item);

        SelectedItem    = null;
        FocusedBodySlot = null;

        GameManager.Inst.SoundManager.UI.PlayOneShot(GameManager.Inst.SoundManager.GetClip("PlaceItemBackpack"), 0.2f);
    }