如何減少此_tile賦值,以便我可以進行單一賦值?用文本指向某個類的類填充列表
x是一個匿名列表。
x => List {String name, int x, int y}
和列表_tiles
_tiles.AddRange(from tile in x
where tile.Type.ToLower() == "start".ToLower()
select new Start(this)
{
Position = new Vector2(tile.X, tile.Y),
Texture = _texture2D
});
_tiles.AddRange(from tile in x
where tile.Type.ToLower() == "One".ToLower()
select new OneTouch(this)
{
Position = new Vector2(tile.X, tile.Y),
Texture = _texture2D
});
...
_tiles.AddRange(from tile in x
where tile.Type.ToLower() == "Two".ToLower()
select new ReverseTouch(this)
{
Position = new Vector2(tile.X, tile.Y),
Texture = _texture2D
開始,OneTouch和ReverseTouch從共同的祖先繼承嗎? –
是的,他們都繼承了瓷磚類 –