/// <summary> /// Метод изменения матрицы игрового поля /// </summary> /// <param name="Model"></param> private void ChangeMatrix(FieldPoint Model) { FieldMatrix[(int)Model.Position.x, (int)Model.Position.z] = Model; }
public RemoveLaneStepOperation(FieldPoint fp, AVLTree <FieldPoint> collection) : base(fp) { Collection = collection; }
/// <summary> /// Запускает волну для поиска пути /// </summary> private void Wave() { if (deadEnd) { return; } switch (Roam) { case true: wayPoints = WaveAlgorithm.ShortWay(fieldMatrix, currentCell, UnitState.Roam); break; case false: if (markedCells.Count == 0) { RandomMove = true; wayPoints = WaveAlgorithm.ShortWay(fieldMatrix, currentCell, UnitState.FirstFree); break; } if (RandomMove) { wayPoints = WaveAlgorithm.ShortWay(fieldMatrix, currentCell, UnitState.FirstFree); break; } wayPoints = WaveAlgorithm.ShortWay(fieldMatrix, currentCell, UnitState.Follow, markedCells); break; } if (wayPoints == null) { deadEnd = WaveAlgorithm.NoWay(fieldMatrix, currentCell); if (deadEnd) { return; } RandomMove = true; return; } else { switch (Roam) { case true: targetCell = wayPoints[wayPoints.Length - 1]; cellToMove = false; counter = 0; CanMove = true; GetNextCellToMove(); break; case false: targetCell = wayPoints[wayPoints.Length - 1]; MarkedCell = targetCell; cellToMove = false; counter = 0; CanMove = true; GetNextCellToMove(); break; } } }
protected LaneStepOperationBase(FieldPoint point) { FieldPoint = point; }
/// <summary> /// Change main field , build ways to point /// </summary> /// <param name="from">Point way to which isn't exist</param> /// <param name="tmpField">Field after wawe alchoritm change </param> /// <returns></returns> private FieldPoint ClearWayTo(FieldPoint from, int[,] tmpField) { try { FieldPoint PointToChange = new FieldPoint(); tmpField[from.X, from.Y] = 100; bool fl = true; int i, j, temp = 100; while (fl) { fl = false; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { if (tmpField[i, j] == temp) { if (j > 0) { fl = true; if (tmpField[i, j - 1] >= 1000) { PointToChange.New(i, j); fl = false; i = j = n; continue; } else { tmpField[i, j - 1] = temp + 1; } } if (i > 0) { fl = true; if (tmpField[i - 1, j] >= 1000) { PointToChange.New(i, j); fl = false; i = j = n; continue; } else { tmpField[i - 1, j] = temp + 1; } } if (j < n - 1) { fl = true; if (tmpField[i, j + 1] >= 1000) { PointToChange.New(i, j); fl = false; i = j = n; continue; } else { tmpField[i, j + 1] = temp + 1; } } if (i < n - 1) { fl = true; if (tmpField[i + 1, j] >= 1000) { PointToChange.New(i, j); fl = false; i = j = n; continue; } else { tmpField[i + 1, j] = temp + 1; } } } } } temp++; } return(PointToChange); } catch (Exception ex) { Logger.Add(new Log(this.GetType().Name, MethodBase.GetCurrentMethod().Name, $"Error", ex)); } return(null); }