基本クラスが1つあります。
class Tile{}
そして、タイルを拡張する他のいくつか
class Free : Tile{}
class Wall : Tile{}
各タイルには独自のテクスチャがあり、文字列ではなく、初期化時にロードする必要があるTexture2Dです。コードはこれに似ていると思いますが、これを適切に作成する方法がわかりません。
class Tile{
static Texture2D texture; //Static will use less ram because it will be same for inherited class?
static string texture_path; //This is set by inherited class
public Tile(){
if(texture==null)
texture = LoadTexture(texture_path);
}
}
class Free : Tile{
static string texture_path = "Content/wall.png";
}
言い換えれば、すべてのフリータイルは同じテクスチャを持ち、すべてのウォールタイルは同じテクスチャを持っています。そのため、私の意見では静的を使用する必要があります。
これを正しく行う方法は?