Exemplo n.º 1
0
    protected void OnClickView(int index)
    {
        if (selectedViewIndex != index)
        {
            selectedViewIndex = index;
        }
        viewGroup.ClearChosen();
        viewGroup.views[index].chosen.SetActive(true);
        title.SetText("");
        content.SetText("");

        switch ((TabSelection)currentTab)
        {
        case TabSelection.Weapon:
            SelectWeapon(index);
            break;

        case TabSelection.Wearable:
            SelectWearable(index);
            break;

        case TabSelection.Consumable:
            SelectConsumable(index);
            break;

        case TabSelection.KeyItem:
            SelectKeyItem(index);
            break;

        default:
            break;
        }
    }
    protected void OnClickView(int index, bool isInit = false)
    {
        if (!isInit && selectedViewIndex == index)
        {
            // Debug.Log("click the same item");
            if (currentTab == TabSelection.Consumable)
            {
                // Debug.Log("Use consumable item");
                UseCurrentSelectedConsumable();
                DisplayConsumable();
            }
        }
        if (selectedViewIndex != index)
        {
            selectedViewIndex = index;
        }
        viewGroup.ClearChosen();
        viewGroup.views[index].chosen.SetActive(true);
        title.SetText("");
        content.SetText("");

        switch ((TabSelection)currentTab)
        {
        case TabSelection.Weapon:
            SelectWeapon(index);
            break;

        case TabSelection.Wearable:
            SelectWearable(index);
            break;

        case TabSelection.Consumable:
            SelectConsumable(index);
            break;

        case TabSelection.KeyItem:
            SelectKeyItem(index);
            break;

        default:
            break;
        }
    }
    protected void OnClickSelectionItem(int index, bool isInit = false)
    {
        if (currentSelection == index && !isInit)
        {
            ConfirmItemSelection();
            return;
        }

        selectionViews.ClearChosen();
        currentSelection = index;
        selectionViews.views[currentSelection].Choose();
        int offset = currentPage * itemsPerPage;

        if (currentSlot == 0)
        {
            if (index + offset >= playerStock.weaponStock.Count)
            {
                title.SetText("");
                content.SetText("");
            }
            else
            {
                ItemData.Weapon item = playerStock.weaponStock[index + offset].weapon;
                title.SetText(UIInventoryState.ParsingTitle(item.ToString()));
                content.SetText(ItemData.WeaponDescription[(int)item]);
            }
        }
        else if (currentSlot == 1 || currentSlot == 2)
        {
            if (index + offset >= playerStock.wearableStock.Count)
            {
                title.SetText("");
                content.SetText("");
            }
            else
            {
                ItemData.Wearable item = playerStock.wearableStock[index + offset].wearable;
                title.SetText(UIInventoryState.ParsingTitle(item.ToString()));
                content.SetText(ItemData.WearableDescription[(int)item]);
            }
        }
    }
    protected void OnClickSlotItem(int index, bool isInit = false)
    {
        if (index == currentSlot && !isInit)
        {
            // repeate click, confirm selection
            ConfirmSlotSelection();
            return;
        }

        // select represented slot
        currentPage = 0;
        DisplaySelectionView(index);
        currentSlot = index;
        slotViews.ClearChosen();
        slotViews.views[currentSlot].Choose();

        // display info
        if (currentSlot == 0)
        {
            ItemData.Weapon item = playerStock.weaponStock[playerSlot.weaponIndex].weapon;
            title.SetText(UIInventoryState.ParsingTitle(item.ToString()));
            content.SetText(ItemData.WeaponDescription[(int)item]);
        }
        else if (currentSlot == 1 && playerSlot.IsWearableInUse(playerStock, playerSlot.wearableOneIndex))
        {
            ItemData.Wearable item = playerStock.wearableStock[playerSlot.wearableOneIndex].wearable;
            title.SetText(UIInventoryState.ParsingTitle(item.ToString()));
            content.SetText(ItemData.WearableDescription[(int)item]);
        }
        else if (currentSlot == 2 && playerSlot.IsWearableInUse(playerStock, playerSlot.wearableTwoIndex))
        {
            ItemData.Wearable item = playerStock.wearableStock[playerSlot.wearableTwoIndex].wearable;
            title.SetText(UIInventoryState.ParsingTitle(item.ToString()));
            content.SetText(ItemData.WearableDescription[(int)item]);
        }
        else
        {
            title.SetText("");
            content.SetText("");
        }
    }