コード例 #1
0
    //Give item associated with button clicked to player and charge gold
    public void PurchaseItem()
    {
        //index associated with position of shop slot
        int index = EventSystem.current.currentSelectedGameObject.transform.GetSiblingIndex();

        if (!playerStats.ChargeGold(ItemCost[index]))
        {
            return;
        }

        //Gives item to player
        switch (ItemList[index])
        {
        case ItemName.HPotion:
            Instantiate(Resources.Load <GameObject>("Items/Health Potion (Large)"), playerReference.transform.position, Quaternion.identity);
            break;

        case ItemName.MPotion:
            Instantiate(Resources.Load <GameObject>("Items/Magic Potion (Large)"), playerReference.transform.position, Quaternion.identity);
            break;

        case ItemName.Inn:
            playerStats.HealPlayer(99999);
            break;
        }
    }
コード例 #2
0
ファイル: Item.cs プロジェクト: Philopalope/Lost
    //Do something based on item used
    public void UseItem()
    {
        switch (type)
        {
        case ItemName.HPotion:
            PSM.HealPlayer(restorePointsAmount);
            break;

        case ItemName.MPotion:
            PSM.HealMagic(restorePointsAmount);
            break;

        case ItemName.Backpack:
            IM.IncreaseRows(restorePointsAmount);
            break;

        case ItemName.Food:
            PSM.HealPlayer(restorePointsAmount);
            break;
        }
    }