Esempio n. 1
0
 public void Awake()
 {
     for (int i = 0; i < 6; ++i)
     {
         smallItems[i] = new SmallItemSlot();
     }
     for (int i = 0; i < 2; ++i)
     {
         bigItems[i] = new BigItemSlot();
     }
 }
Esempio n. 2
0
        // Drops all the items straight at the characters foot
        public void Drop(ItemSlot itemSlot)
        {
            if (itemSlot is SmallItemSlot)
            {
                SmallItemSlot smallItemSlot = (SmallItemSlot)itemSlot;
                Debug.Assert(smallItemSlot.count != 0);

                foreach (PixelItem item in smallItemSlot.items)
                {
                    if (item == null)
                    {
                        continue;
                    }
                    item.transform.parent = transform.parent.parent;
                    Vector2 position = (Vector2)transform.parent.position;
                    position += Random.insideUnitCircle * 2;
                    item.transform.position = position;
                    item.gameObject.SetActive(true);
                }

                for (int i = 0; i < 4; ++i)
                {
                    smallItemSlot.items[i] = null;
                }
            }
            else
            {
                BigItemSlot bigItemSlot = (BigItemSlot)itemSlot;
                Debug.Assert(bigItemSlot.item != null);

                PixelItem item = bigItemSlot.item;
                item.transform.parent = transform.parent.parent;
                Vector2 position = transform.parent.position;
                position += Random.insideUnitCircle * 2;
                item.transform.position = position;
                item.gameObject.SetActive(true);
                bigItemSlot.item = null;
            }

            Character character = transform.parent.GetComponent <Character>();

            if (character != null)
            {
                character.UpdateSortingLayer();
            }
        }