Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Compositeパターン アイテムディレクトリを表すクラス
using UnityEngine;
using System.Collections.Generic;
public class GameItemDirectory : Entry
{
// 要素のリスト
private List<Entry> directory = new List<Entry>();
// コンストラクタ
public GameItemDirectory(string name)
{
this.name = name;
}
// このディレクトリに新しい要素を追加
public Entry Add(Entry entry)
{
this.directory.Add(entry);
return this;
}
public override void PrintListLog(string prefix)
{
Debug.Log(prefix + "/" + this);
foreach (var element in this.directory)
{
Entry entry = (Entry)element;
entry.PrintListLog(prefix + "/" + this);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment