コード例 #1
0
ファイル: InventoryScript.cs プロジェクト: wndtanaka/DIP_SQL
        private void Awake()
        {
            Bag bag = (Bag)Instantiate(items[0]);

            bag.Initialize(16);
            bag.Use();
        }
コード例 #2
0
ファイル: InventoryScript.cs プロジェクト: wndtanaka/DIP_SQL
 private void LateUpdate()
 {
     if (Input.GetKeyDown(KeyCode.I))
     {
         Bag bag = (Bag)Instantiate(items[0]);
         bag.Initialize(16);
         bag.Use();
     }
     if (Input.GetKeyDown(KeyCode.J))
     {
         Bag bag = (Bag)Instantiate(items[0]);
         bag.Initialize(8);
         AddItem(bag);
     }
     if (Input.GetKeyDown(KeyCode.K))
     {
         Bag bag = (Bag)Instantiate(items[0]);
         bag.Initialize(16);
         AddItem(bag);
     }
     if (Input.GetKeyDown(KeyCode.L))
     {
         HealthPotion potion = (HealthPotion)Instantiate(items[1]);
         AddItem(potion);
     }
     if (Input.GetKeyDown(KeyCode.V))
     {
         Apple apple = (Apple)Instantiate(items[2]);
         AddItem(apple);
     }
 }
コード例 #3
0
ファイル: InventoryScript.cs プロジェクト: wndtanaka/DIP_SQL
        public void SwapBags(Bag oldBag, Bag newBag)
        {
            int newSlotCount = (MyTotalSlotCount - oldBag.Slots) + newBag.Slots;

            if (newSlotCount - MyFullSlotCount >= 0)
            {
                //do swap
                List <Item> bagItems = oldBag.MyBagScript.GetItems();
                RemoveBag(oldBag);
                newBag.MyBagButton = oldBag.MyBagButton;
                newBag.Use();
                foreach (Item item in bagItems)
                {
                    if (item != newBag) // no duplicates
                    {
                        AddItem(item);
                    }
                }
                AddItem(oldBag);
                HandScript.MyInstance.Drop();
                Instance.fromSlot = null;
            }
        }