Untitled
unknown
plain_text
3 years ago
2.1 kB
12
Indexable
while (true)
{
//if (!movement.isMoving)
{
parentTransform = transform.parent;
if (parentTransform != null)
{
parentObject = parentTransform.gameObject;
}
Cell parentCell = parentObject.GetComponent<Cell>();
currentIndex = gridManager.cells.IndexOf(parentCell);
Debug.Log("current Index is" + currentIndex);
currentAvialablePath = pathfinding.FindPath(parentCell, gridManager.cells[Player.playerCellIndex], gridManager.cells);
foreach (var item in currentAvialablePath)
{
item.setColor(Color.cyan);
}
currentNeighbours = pathfinding.GetNeighbors(parentCell);
if (currentNeighbours != null && currentAvialablePath != null)
{
cellsToMove = currentNeighbours.Intersect(currentAvialablePath).ToList();
}
if (cellsToMove != null && cellsToMove.Count > 0)
{
foreach (Cell item in cellsToMove)
{
item.setColor(Color.yellow);
}
if (!movement.isMoving)
{
StartCoroutine(movement.MoveToNExtCell(moveTime, this.gameObject, cellsToMove[0]));
//foreach (var item in cellsToMove)
//{
// StartCoroutine(movement.MoveToNExtCell(moveTime, this.gameObject, item));
// yield return new WaitForSeconds(moveTime);
//}
currentAvialablePath.Clear();
currentNeighbours.Clear();
cellsToMove.Clear();
parentCell = null;
}
}
}
yield return null;
}Editor is loading...