-
-
Save todorok1/6567e333a86cca7fae6ed9ae82621550 to your computer and use it in GitHub Desktop.
シンプルRPGチュートリアル第119回 戦闘中のアイテムアクションを処理するクラス
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> | |
| public void ProcessAction(BattleAction action) | |
| { | |
| var itemData = ItemDataManager.GetItemDataById(action.itemId); | |
| if (itemData == null) | |
| { | |
| SimpleLogger.Instance.LogWarning($"アイテムデータが見つかりませんでした。 ID: {action.itemId}"); | |
| return; | |
| } | |
| // 消費アイテムの場合、所持数を減らします。 | |
| if (action.isActorFriend && itemData.itemCategory == ItemCategory.ConsumableItem) | |
| { | |
| CharacterStatusManager.UseItem(action.itemId); | |
| } | |
| _actionProcessor.SetPauseProcess(true); | |
| if (itemData.itemEffect.itemEffectCategory == ItemEffectCategory.Recovery) | |
| { | |
| int hpDelta = BattleCalculator.CalculateHealValue(itemData.itemEffect.value); | |
| int mpDelta = 0; | |
| if (action.isActorFriend) | |
| { | |
| CharacterStatusManager.ChangeCharacterStatus(action.targetId, hpDelta, mpDelta); | |
| } | |
| else | |
| { | |
| _enemyStatusManager.ChangeEnemyStatus(action.targetId, hpDelta, mpDelta); | |
| } | |
| StartCoroutine(ShowItemHealMessage(action, itemData.itemName, hpDelta)); | |
| } | |
| else if (itemData.itemEffect.itemEffectCategory == ItemEffectCategory.None) | |
| { | |
| StartCoroutine(ShowNoEffectItemMessage(action, itemData.itemName)); | |
| } | |
| else | |
| { | |
| SimpleLogger.Instance.LogWarning($"未定義のアイテム効果です。 ID: {itemData.itemId}"); | |
| StartCoroutine(ShowNoEffectItemMessage(action, itemData.itemName)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment