internal static (bool startMovement, PointI hexToMoveTo) CheckForUnitMovementFromMouseInitiation(Stack stack, object args) { var(cellGrid, mouseLocation, camera) = (ValueTuple <CellGrid, Point, Camera>)args; if (!camera.GetViewport.Contains(mouseLocation)) { return(false, new PointI(0, 0)); } var screenPixelToWorldHex = camera.ScreenPixelToWorldHex(mouseLocation); var hexToMoveTo = new PointI(screenPixelToWorldHex.Col, screenPixelToWorldHex.Row); if (hexToMoveTo.Equals(stack.LocationHex)) { return(false, new PointI(0, 0)); } var cellToMoveTo = cellGrid.GetCell(hexToMoveTo); if (cellToMoveTo.SeenState == SeenState.NeverSeen) { return(false, new PointI(0, 0)); } var costToMoveIntoResult = MovementCosts.GetCostToMoveInto(cellToMoveTo, stack.MovementTypes, stack.MovementPoints); return(costToMoveIntoResult.CanMoveInto ? (true, hexToMoveTo) : (false, new PointI(0, 0))); }
internal static List <PointI> DetermineMovementPath(HexLibrary hexLibrary, Stack stack, PointI from, PointI to, CellGrid cellGrid) { if (from.Equals(to)) { return(new List <PointI>()); } _hexLibrary = hexLibrary; AStarSearch <PointI, Cost> mapSolver = new MapSolver(); mapSolver.GetAllNeighbors = GetAllNeighbors; mapSolver.GetDistance = GetDistance; var openList = new PriorityQueue <AStarSearch <PointI, Cost> .Node>(); var closedList = new Dictionary <PointI, Cost>(); mapSolver.Solve(GetCostToMoveIntoFunc, new PointI(cellGrid.NumberOfColumns, cellGrid.NumberOfRows), from, to, openList, closedList); var path = mapSolver.Solution; return(path); GetCostToMoveIntoResult GetCostToMoveIntoFunc(PointI point) { return(MovementCosts.GetCostToMoveInto(point, stack.MovementTypes, stack.MovementPoints)); } }