public void TestMidpoint() { Position pos = UtilsAlgorithm.SurroundSearch(new Position(0, 0), 5, this); /*List<Position> list1 = Midpoint.MidpointCircle(1); * List<Position> list2 = Midpoint.MidpointCircle(2); * List<Position> list3 = Midpoint.MidpointCircle(3);*/ }
public virtual bool MoveTo(Position destination) { InfoLog.WriteInfo(InfoPrefix() + "Counting path...", EPrefix.AStar); _tmpGoal = Position.Invalid; //czy cel jest zajety if (!IsMoveable(destination.X, destination.Y, _map)) { InfoLog.WriteInfo(InfoPrefix() + "Destination is occupied", EPrefix.AStar); //cel zajety - poszukiwanie celu zastepczego _tmpGoal = UtilsAlgorithm.SurroundSearch(destination, this.MaxTmpDestinationRange, this); //czy znaleziono cel zastepczy if (_tmpGoal.Equals(destination)) { //nie znaleziono InfoLog.WriteInfo(InfoPrefix() + "Subsittute destination not found", EPrefix.AStar); _tmpGoal = Position.Invalid; _goal = Position.Invalid; this._currentPath.Clear(); return(false); } //znaleziono cel zastpeczy szukana jest sciezka do celu zastepszego this._currentPath = FindPath(this.Position, _tmpGoal, this._map, this._canCrossMountain, this._canCrossBuildings, this._canCrossRock, this._canCrossTrooper, this._canCrossRock); //czy znaleziono sciezke if (this._currentPath.Count == 0) { InfoLog.WriteInfo(InfoPrefix() + "Path to subsittute destination not found", EPrefix.AStar); //nie znaleziono sciezki _tmpGoal = Position.Invalid; _goal = Position.Invalid; return(false); } //znaleziono sciezke - w _tmpGoal cel posredni w _goal bezposredni InfoLog.WriteInfo(InfoPrefix() + "Counted path to substitute goal: (" + _tmpGoal.X + " , " + _tmpGoal.Y + ")", EPrefix.AStar); _goal = destination; state = UnitState.moving; printCurrentPath(); return(true); } //cel nie jest zajety, szukana jest bezposrednia sciezka do celu this._currentPath = FindPath(this.Position, destination, this._map, this._canCrossMountain, this._canCrossBuildings, this._canCrossRock, this._canCrossTrooper, this._canCrossRock); if (this._currentPath.Count == 0) { //nie znaleziono sciezki _tmpGoal = Position.Invalid; _goal = Position.Invalid; InfoLog.WriteInfo(InfoPrefix() + "Path not found", EPrefix.AStar); return(false); } state = UnitState.moving; _goal = destination; InfoLog.WriteInfo(InfoPrefix() + "Counted path to goal: (" + _goal.X + " , " + _goal.Y + ")", EPrefix.AStar); printCurrentPath(); return(true); //this._remainingTurnsInMove = this.speed; }