Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save todorok1/d5eecb1a5ab750bdcc31daf6ae22133b to your computer and use it in GitHub Desktop.
シンプルRPGチュートリアル第119回 選択ウィンドウにてアイテムに関する処理を制御するクラス
/// <summary>
/// 選択中の項目が実行できるか確認します。
/// 魔法の場合は消費MPを確認、アイテムの場合は所持数を確認します。
/// </summary>
/// <param name="selectedIndex">選択中のインデックス</param>
public bool IsValidSelection(int selectedIndex)
{
bool isValid = false;
int indexInPage = selectedIndex % 4;
if (!_itemIdDictionary.ContainsKey(indexInPage))
{
return isValid;
}
var itemId = _itemIdDictionary[indexInPage];
isValid = CanSelectItem(itemId);
return isValid;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment