예제 #1
0
    public void AddSlots(TRAYS tray, int count)
    {
        if (IsInitialized) // Avoid the NPEs
        {
            switch (tray)
            {
            case TRAYS.functions:
                for (int f = 0; f < count; f++)
                {
                    GameObject functionSlotProp = Instantiate(functionSlotObject);
                    functionSlotProp.transform.SetParent(functionTray.transform, false);
                    functionSlots.Add(functionSlotProp);
                }
                break;

            case TRAYS.inventory:
                for (int i = 0; i < count; i++)
                {
                    GameObject inventorySlotProp = Instantiate(inventorySlotObject);
                    inventorySlotProp.transform.SetParent(inventoryTray.transform, false);
                    inventorySlots.Add(inventorySlotProp);
                }
                break;

            default:
                break;
            }
        }
    }
예제 #2
0
    public void SelectSlot(TRAYS tray, int slot)
    {
        switch (tray)
        {
        case (TRAYS.inventory):
            if (slot < 0 || slot > inventorySlots.Count)
            {
                throw new System.Exception("Selected slot does not exist in the HUD: " + slot);
            }
            else
            {
                selectedInventorySlot = slot;
                UpdateSelectedSlots(TRAYS.inventory);
            }
            break;

        case (TRAYS.functions):
            if (slot < 0 || slot > functionSlots.Count)
            {
                throw new System.Exception("Selected slot does not exist in the HUD: " + slot);
            }
            else
            {
                selectedFunctionSlot = slot;
                UpdateSelectedSlots(TRAYS.functions);
            }
            break;

        default:
            break;
        }
    }
예제 #3
0
    private void UpdateSelectedSlots(TRAYS tray)
    {
        switch (tray)
        {
        case (TRAYS.inventory):
            // check for active inventory slot and change the decoration for it
            foreach (GameObject invSlotProp in inventorySlots)
            {
                invSlotProp.GetComponent <InventorySlot>().DeselectSlot();
            }

            inventorySlots[selectedInventorySlot].GetComponent <InventorySlot>().SelectSlot();
            break;

        case (TRAYS.functions):
            // check for active function slot and change the decoration for it
            foreach (GameObject functionSlotProp in functionSlots)
            {
                functionSlotProp.GetComponent <FunctionSlot>().DeselectSlot();
            }

            functionSlots[selectedFunctionSlot].GetComponent <FunctionSlot>().SelectSlot();
            break;

        default:
            break;
        }
    }