Created
September 7, 2016 15:54
-
-
Save Krita3/3cd120cefb19db0267bf1ecdbf9fec3f to your computer and use it in GitHub Desktop.
Compositeパターン 動作確認用クラス
This file contains 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
using UnityEngine; | |
public class CompositeTest : MonoBehaviour | |
{ | |
private GameItemDirectory itemDirectory = new GameItemDirectory("アイテム"); | |
private GameItemDirectory consumptionItemDirectory = new GameItemDirectory("消費アイテム"); | |
private GameItemDirectory equippedItemDirectory = new GameItemDirectory("装備アイテム"); | |
void Start () { | |
setupDirectories(); | |
// 消費アイテムを消費アイテムディレクトリに生成 | |
createConsumptionItemFilesTo(this.consumptionItemDirectory); | |
// 装備アイテムを装備アイテムディレクトリに生成 | |
createEquippedItemFilesTo(this.equippedItemDirectory); | |
this.itemDirectory.PrintListLog(); | |
} | |
// 各ディレクトリの階層構造を準備 | |
private void setupDirectories() | |
{ | |
this.itemDirectory.Add(this.consumptionItemDirectory); | |
this.itemDirectory.Add(this.equippedItemDirectory); | |
} | |
// 消費アイテムを指定ディレクトリに生成 | |
private void createConsumptionItemFilesTo(GameItemDirectory directory) | |
{ | |
int fileNumber = 1; | |
for (int i = 0; i < fileNumber; ++i) | |
{ | |
int id = i + 1; | |
string itemName = "消費アイテム" + id; | |
directory.Add(new GameItemFile(itemName)); | |
} | |
} | |
// 装備アイテムを指定ディレクトリに生成 | |
private void createEquippedItemFilesTo(GameItemDirectory directory) | |
{ | |
int fileNumber = 2; | |
for (int i = 0; i < fileNumber; ++i) | |
{ | |
int id = i + 1; | |
string itemName = "装備アイテム" + id; | |
directory.Add(new GameItemFile(itemName)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment