개인적인 오락을 위해 나중에 나올 게임의 기초가되기를 희망합니다. 현재, 나는 게임 "보드"에서 일하고 있습니다. 다음 사항을 고려하십시오 :LINQ를 사용하여 다차원 배열에서 알 수없는 항목 선택
class Board
{
private Cube[,,] gameBoard;
public Cube[, ,] GameBoard { get; }
private Random rnd;
private Person person;
public Person _Person { get; }
//default constructor
public Board()
{
person = new Person(this);
rnd = new Random();
gameBoard = new Cube[10, 10, 10];
gameBoard.Initialize();
int xAxis = rnd.Next(11);
int yAxis = rnd.Next(11);
int zAxis = rnd.Next(11);
gameBoard[xAxis, yAxis, zAxis].AddContents(person);
}
}
그리고이 :
class Person : IObject
{
public Board GameBoard {get; set;}
public int Size { get; set; }
public void Move()
{
throw new NotImplementedException();
}
public void Move(Cube startLocation, Cube endLocation)
{
startLocation.RemoveContents(this);
endLocation.AddContents(this);
}
public Person(Board gameBoard)
{
Size = 1;
GameBoard = gameBoard;
}
public int[] GetLocation()
{
int[] currentLocation;
var location =
from cubes in GameBoard.GameBoard
where cubes.GetContents.Contains(this)
select cubes;
}
}
나는 이것이 아마도 재미 없어 그렇게 잘못 알고 있지만,이 거친 컷의 거친입니다.
나는 Person
이있는 Cube
의 특정 색인을 반환하기 위해 GetLocation
을 얻으려고합니다. 그 사람이 Board.GameBoard[1, 2, 10]
에있는 경우 해당 위치를 검색 할 수 있습니다 (위에 나열된대로 int[]
일 수 있음).
Could not find an implementation of the query pattern for source type 'Cubes.Cube[*,*,*]'. 'Where' not found.'
내가 LINQ는 다차원 배열을 조회 할 수 있어야한다고 확신했다, 그러나 나는 방법에 대한 문서를 발견하지 않았습니다 그러나, 현재에, 나는 다음 오류로 인해 컴파일 할 수 없어요 그것을하기 위해.
제안 사항이 있습니까? 아니면 완전히 잘못된 트랙에 있습니까?
감사합니다 ... 나는 두려웠습니다. 그리고 나서 나는 그 질문의 일부분에 내가 필요한 대답을 물었습니다. 오케이. – AllenG