Skip to content

Instantly share code, notes, and snippets.

@dskjal
Last active June 19, 2017 01:38
Show Gist options
  • Save dskjal/22bc749c33b784df6c1f26117fc3a952 to your computer and use it in GitHub Desktop.
Save dskjal/22bc749c33b784df6c1f26117fc3a952 to your computer and use it in GitHub Desktop.
アイテムデータベースの例
struct ItemData{
int ItemID;
// その他のフィールド変数
}
class ItemDB{
private ItemData items[];
public ItemData this[int i]{
get{
return items[i]
}
}
public void LoadFromFile(string filePath){}
}
// プレイヤーの手持ちのアイテム
struct Stock{
int ItemID;
int Quantity;
}
// プレイヤーのインベントリを管理するクラス
class ActorInventory{
List<Stock> items;
// Update が肥大化する
void Update(){
usedItemID = playerUseItem();
switch(usedItemID){
case 0: // 回復薬
break;
case 1: // 攻撃バフ
break;
// ...
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment