-
-
Save todorok1/37f0e058180aa10b56a53ca3373f2aa7 to your computer and use it in GitHub Desktop.
シンプルRPGチュートリアル第34回 キャラクターのステータスを管理するクラス
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// 引数のアイテムを使用します。 | |
/// </summary> | |
/// <param name="itemId">アイテムのID</param> | |
public static void UseItem(int itemId) | |
{ | |
var partyItemInfo = partyItemInfoList.Find(info => info.itemId == itemId); | |
if (partyItemInfo == null) | |
{ | |
Debug.LogWarning($"対象のアイテムを所持していません。 ID : {itemId}"); | |
return; | |
} | |
partyItemInfo.usedNum++; | |
var itemData = ItemDataManager.GetItemDataById(itemId); | |
if (partyItemInfo.usedNum >= itemData.numberOfUse && itemData.numberOfUse > 0) | |
{ | |
partyItemInfo.itemNum--; | |
} | |
if (partyItemInfo.itemNum <= 0) | |
{ | |
partyItemInfoList.Remove(partyItemInfo); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment