Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected bool Wave(ESubject subject)
- {
- int countRow = WorldModel.countRow;
- int countColumn = WorldModel.countColumn;
- int[,] grid = new int[countRow, countColumn];
- Queue<Indices> queue = new Queue<Indices>();
- queue.Enqueue(new Indices(model.Y, model.X));
- bool found = false;
- int step = 1;
- Indices end = new Indices();
- while (queue.Count > 0 && !found)
- {
- Indices i = queue.Dequeue();
- grid[i.I, i.J] = step;
- for (int j = 0; j < 4; j++)
- {
- i.I += dy[j];
- i.J += dx[j];
- if (i.I < 0 || i.I >= countRow || i.J < 0 || i.J >= countColumn || grid[i.I,i.J] > 0)
- continue;
- if (WorldModel.world[i.I, i.J].IsPassable)
- {
- queue.Enqueue(i);
- grid[i.I, i.J] = step + 1;
- }
- else
- {
- found = WorldModel.world[i.I, i.J].GetTile == subject;
- if (found)
- {
- end.I = i.I;
- end.J = i.J;
- grid[i.I, i.J] = step + 1;
- break;
- }
- }
- }
- step++;
- }
- return found;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement