コード例 #1
0
ファイル: InventoryUIManager.cs プロジェクト: sdasd30/TSSG
    public static bool AttemptSwap(ItemUIElement item1, ItemUIElement item2)
    {
        InventorySlotUI slot1 = item1.ItemInfo.CurrentSlot;
        InventorySlotUI slot2 = item2.ItemInfo.CurrentSlot;

        if (slot1.CanFitItem(item2.ItemInfo) && slot2.CanFitItem(item1.ItemInfo) &&
            item1.ItemInfo.CanEnterInventory(slot2.m_container, slot2) &&
            item2.ItemInfo.CanEnterInventory(slot1.m_container, slot1))
        {
            Debug.Log("Moving item 1");
            GameObject      newSlot  = Instantiate(m_instance.SlotPrefab, m_instance.transform);
            InventorySlotUI tempSlot = newSlot.GetComponent <InventorySlotUI>();
            tempSlot.m_container = m_instance.m_Container;
            m_instance.MoveItemTo(item1, tempSlot);

            Debug.Log("Moving item 2");
            m_instance.MoveItemTo(item2, slot1);
            m_instance.MoveItemTo(item1, slot2);
            Destroy(newSlot);
            return(true);
        }
        item1.ReturnPos();
        item2.ReturnPos();
        return(false);
    }
コード例 #2
0
ファイル: InventoryUIManager.cs プロジェクト: sdasd30/TSSG
 public static void ClearHighlightedItem(ItemUIElement item)
 {
     if (m_instance.m_highlightedItem == item)
     {
         m_instance.m_highlightedItem = null;
     }
 }
コード例 #3
0
ファイル: InventoryUIManager.cs プロジェクト: sdasd30/TSSG
    public static void CreateItemMenu(ItemUIElement iue)
    {
        if (iue.transform.Find("ItemMenu(Clone)") != null)
        {
            return;
        }
        GameObject newMenu = Instantiate(m_instance.ItemMenuPrefab, iue.transform);

        newMenu.GetComponent <ItemMenu>().HighlightedItem = iue.ItemInfo;
    }
コード例 #4
0
ファイル: InventoryUIManager.cs プロジェクト: sdasd30/TSSG
    private void MoveItemTo(ItemUIElement iue, InventorySlotUI slot)
    {
        iue.UpdateReturnPos(slot.ItemOffsetPos);
        if (slot.transform.parent.parent != null)
        {
            iue.transform.SetParent(slot.transform.parent.parent.Find("Items"));
            iue.ReturnPos();
        }

        iue.ItemInfo.CurrentSlot.m_container.ClearItem(iue.ItemInfo.CurrentSlot.Coordinate);
        slot.AddItem(iue.ItemInfo);
        iue.ItemInfo.CurrentSlot = slot;
    }
コード例 #5
0
    public override void Init()
    {
        ReisenGameProgress gameProgress      = ReisenGameManager.instance.gameProgress;
        List <KeyItem>     inventoryKeyItems = gameProgress.Player.GetKeyItemsInInventory();

        foreach (MenuUIElement oldElement in group.menuElements)
        {
            Destroy(oldElement.gameObject);
        }
        group.menuElements.Clear();

        emptyText.gameObject.SetActive(inventoryKeyItems.Count == 0);

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

            ItemUIElement element = Instantiate(ItemMenuElement).GetComponent <ItemUIElement>();
            element.transform.SetParent(group.transform, false);
            element.transform.position     = initialPosition.position + i * Vector3.down * spacing;
            element.parentMenu             = this;
            element.parentGroup            = group;
            element.pauseMenuUI            = pauseMenuUI;
            element.parentMenuOnSelectMode = ParentMenuStatusPostSelect.none;
            element.itemData = item;

            //Initialize the appearance here
            element.InitAppearance();

            group.menuElements.Add(element);
        }


        //if (group.menuElements.Count == 0)
        //{
        //    KeyItem fillerItem = new KeyItem("", "Gah where did all of my inventory go!");
        //    ItemUIElement element = Instantiate(ItemMenuElement).GetComponent<ItemUIElement>();
        //    element.transform.parent = group.transform;
        //    element.transform.position = initialPosition.position;
        //    element.parentMenu = this;
        //    element.parentGroup = group;
        //    element.pauseMenuUI = pauseMenuUI;
        //    element.itemData = fillerItem;
        //    group.menuElements.Add(element);
        //}

        base.Init();
    }
コード例 #6
0
 public void OnPointerEnter(PointerEventData eventData)
 {
     if (InventoryManager.GetCurrentItem() == null)
     {
         m_slotBackground.color = new Color(0.5f, 0.5f, 0.5f);
     }
     else
     {
         ItemUIElement iui = InventoryManager.GetCurrentItem();
         if (CanFitItem(iui.ItemInfo))
         {
             m_slotBackground.color = new Color(0.5f, 1.0f, 0.5f);
         }
         else
         {
             m_slotBackground.color = new Color(1.0f, 0.5f, 0.5f);
         }
     }
     InventoryManager.SetHighlightedCell(this);
 }
コード例 #7
0
ファイル: InventoryUIManager.cs プロジェクト: sdasd30/TSSG
 public static bool AttemptMoveItem(ItemUIElement iue)
 {
     if (m_instance.m_highlightedSlot.CanFitItem(iue.ItemInfo))
     {
         if (!iue.ItemInfo.CanEnterInventory(iue.ItemInfo.CurrentSlot.m_container, m_instance.m_highlightedSlot))
         {
             return(false);
         }
         iue.UpdateReturnPos(m_instance.m_highlightedSlot.ItemOffsetPos);
         iue.transform.SetParent(m_instance.m_highlightedSlot.transform.parent.parent.Find("Items"));
         iue.ReturnPos();
         iue.ItemInfo.CurrentSlot.m_container.ClearItem(iue.ItemInfo.CurrentSlot.Coordinate);
         m_instance.m_highlightedSlot.AddItem(iue.ItemInfo);
         iue.ItemInfo.CurrentSlot = m_instance.m_highlightedSlot;
         iue.ItemInfo.CurrentSlot = m_instance.m_highlightedSlot;
         return(true);
     }
     iue.ReturnPos();
     return(false);
 }
コード例 #8
0
 public void AddItem(Item i, ItemUIElement iue)
 {
     m_container.AddItem(i, Coordinate);
 }
コード例 #9
0
ファイル: InventoryUIManager.cs プロジェクト: sdasd30/TSSG
 public static void SetHeldItem(ItemUIElement item)
 {
     m_instance.m_currentItem = item;
 }
コード例 #10
0
ファイル: InventoryUIManager.cs プロジェクト: sdasd30/TSSG
 public static void SetHighlightedItem(ItemUIElement item)
 {
     m_instance.m_highlightedItem = item;
 }
コード例 #11
0
ファイル: InventoryUIManager.cs プロジェクト: sdasd30/TSSG
 public static void DropItem(ItemUIElement item)
 {
     item.ItemInfo.CurrentSlot.m_container.DropItem(item.ItemInfo.CurrentSlot.Coordinate);
 }