이 할당을 줄일 수있어서 단일 할당을 할 수 있습니까?텍스트가 클래스를 가리키는 클래스로 목록 채우기
x는 익명 목록입니다. 당신이 tiles.ToList()
를 사용하여 목록을 작성하거나 기존 사용 채울 수 거기에서
x => List {String name, int x, int y}
하고 목록
_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 ...
_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
시작, 원터치 및 리버스 터치는 공통 조상으로부터 상속합니까? –
그래, 모두 Tile 클래스에서 상속 받았다. –