Exemple #1
0
        /// <summary>
        /// Calculates asynchronously the unit's pathfinding data for all its moves
        /// </summary>
        public static async Task <List <TilePathfindingData> > CalculateUnitAvailablePathsAsync(Vector3 unitPosition, GridTile[,] tileGrid)
        {
            var selectedTile = tileGrid[(int)unitPosition.x, (int)unitPosition.y];

            #if UNITY_WEBGL && !UNITY_EDITOR
            var unitPathfindingData = PathfindingHelper.CalculatePathfindingForAvailableMoves(tileGrid, selectedTile, selectedTile.CurrentUnit.Movement);
            #else
            var unitPathfindingData = await Task.Run(() => CalculatePathfindingForAvailableMoves(tileGrid, selectedTile, selectedTile.CurrentUnit.Movement));
            #endif
            return(unitPathfindingData);
        }
Exemple #2
0
        /// <summary>
        /// Renders a path from the unit to the selected tile with active tile sprites
        /// </summary>
        public static void RenderPathToTile(TilePathfindingData selectedTilePathfindingData, IEnumerable <TilePathfindingData> unitPathfindingData)
        {
            var tilePathfindingData = unitPathfindingData.ToList();

            ChangeTileSprites(tilePathfindingData.Select(x => x.DestinationGridTile), TileState.Selected);
            if (selectedTilePathfindingData == null)
            {
                return;
            }
            var pathfindingDataList = PathfindingHelper.GetPathToTile(tilePathfindingData, selectedTilePathfindingData.DestinationGridTile);

            ChangeTileSprites(pathfindingDataList, TileState.Active);
        }