Ejemplo n.º 1
0
        private void InitializeSlots()
        {
            var startX = -90;
            var startY = 185;
            var gap    = 85;

            for (var y = 0; y < 5; y++)
            {
                for (var x = 0; x < 6; x++)
                {
                    var i              = y * 6 + x;
                    var slotObject     = Instantiate(slot, transform);
                    var slotController = slotObject.GetComponent <UISlot>();
                    slotController.Inventory     = _inventory;
                    slotController.InventorySlot = i;

                    var position = slotObject.transform.localPosition;
                    position.x = startX + gap * x;
                    position.y = startY - gap * y;

                    slotObject.transform.localPosition = position;
                    _slots.SetValue(slotController, i);

                    var currentItem = _inventory.Get(i);
                    if (currentItem != null)
                    {
                        _slots[i].SetItem(currentItem);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void InitializeSlots()
        {
            var x = -250;
            var y = -30;

            for (var i = 0; i < 6; i++)
            {
                var slotObject     = Instantiate(slot, transform);
                var slotController = slotObject.GetComponent <UISlot>();
                slotController.Inventory     = _inventory;
                slotController.InventorySlot = i;

                var slotKeyController = slotObject.GetComponent <UIHudSlot>();
                slotKeyController.SetShortcut(_shortcutNames[i]);

                var position = slotObject.transform.localPosition;
                position.x = x;
                position.y = y;

                slotObject.transform.localPosition = position;
                _slots.SetValue(slotController, i);

                var currentItem = _inventory.Get(i);
                if (currentItem != null)
                {
                    _slots[i].SetItem(currentItem);
                }

                x += 100;
            }
        }