Skip to content

Instantly share code, notes, and snippets.

@todorok1
Created August 15, 2025 09:59
Show Gist options
  • Select an option

  • Save todorok1/6567e333a86cca7fae6ed9ae82621550 to your computer and use it in GitHub Desktop.

Select an option

Save todorok1/6567e333a86cca7fae6ed9ae82621550 to your computer and use it in GitHub Desktop.
シンプルRPGチュートリアル第119回 戦闘中のアイテムアクションを処理するクラス
/// <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