Skip to content

Instantly share code, notes, and snippets.

@Krita3
Created September 7, 2016 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Krita3/46eb0a9703c7878d1384978d20c26d13 to your computer and use it in GitHub Desktop.
Save Krita3/46eb0a9703c7878d1384978d20c26d13 to your computer and use it in GitHub Desktop.
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