//---------------------------------------------------------------------------------------------- public static void IssueSelectedUnitMoveOrder(Tile destination) { UiController.HideAbilityFrameHighlights(); bool stomp = SelectedUnit.UnitData.Owner == Player.CpuPlayer; List <Tile> bestPath = Pathfinder.GetBestRoute(SelectedUnit, destination, stomp); // show route debug info, if it is enabled UiController.ClearDebugText(); for (int i = 0; i < bestPath.Count; i++) { UiController.CreateDebugText((i).ToString(), bestPath[i].transform.position); } // if we ran over someone, move them out of the way if (stomp) { // assemble a path for each tile the unit occupies - really only useful if larger than 1x1 List <BoardDirection> stepDirs = new List <BoardDirection>(); List <List <Tile> > allPaths = new List <List <Tile> >(); for (int i = 1; i < bestPath.Count; i++) { stepDirs.Add(GameBoard.GetDirectionTowardTile(bestPath[i - 1], bestPath[i])); } foreach (Tile startTile in SelectedUnit.Position) { List <Tile> newPath = new List <Tile> { startTile }; foreach (BoardDirection dir in stepDirs) { newPath.Add(newPath.Last().GetNeighborInDirection(dir)); } allPaths.Add(newPath); } for (int i = 0; i < bestPath.Count; i++) { foreach (List <Tile> nextPath in allPaths) { Unit occupyingUnit = nextPath[i].GetOccupyingUnit(); if (occupyingUnit != null && occupyingUnit != SelectedUnit) { PushUnit(occupyingUnit, GameBoard.GetDirectionTowardTile(nextPath[i - 1], nextPath[i])); } } } } // set our unit's new position if (SelectedUnit.UnitData.TileDiameter == 1) { SelectedUnit.SetPosition(destination); } else { Vector3 startOffsetFromUnit = SelectedUnit.transform.position - bestPath.First().transform.position; Vector3 tileScanPos = bestPath.Last().transform.position + startOffsetFromUnit; SelectedUnit.SetPosition(GameBoard.GetTilesClosetToPoint(tileScanPos, 4)); } SelectedUnit.HasMoved = true; }