void Start()
    {
        if (mapData != null && grid != null)
        {
            int[,] mapDesign = mapData.MakeMap();
            grid.CreateGrid(mapDesign);

            gridVisualisation = grid.gameObject.GetComponent <GridVisualisation>();

            if (gridVisualisation != null)
            {
                gridVisualisation.CreateGridVisualisation(grid);
            }

            //if our goal is not in the map range it will throw.
            if (grid.IsWithinBounds(xGoal, yGoal) && grid.IsWithinBounds(xStart, yStart))
            {
                startNode       = gridVisualisation.nodesVisualisationData[xStart, yStart];
                goalNode        = gridVisualisation.nodesVisualisationData[xGoal, yGoal];
                xGoalInput.text = xGoal.ToString();
                yGoalInput.text = yGoal.ToString();
                xUnitInput.text = xStart.ToString();
                yUnitInput.text = yStart.ToString();
                InstantiateUnit(startNode);
            }
        }
    }
    void Start()
    {
        if (mapData != null && grid != null)
        {
            int[,] mapinstance = mapData.MakeMap();
            grid.CreateGrid(mapinstance);

            gridVisualisation = grid.gameObject.GetComponent <GridVisualisation>();

            if (gridVisualisation != null)
            {
                gridVisualisation.CreateGridVisualisation(grid);
            }

            //if our goal is not in the map range it will throw.
            if (grid.IsWithinBounds(xGoal, yGoal) && grid.IsWithinBounds(xStart, yStart))
            {
                startNode = gridVisualisation.nodesVisualisationData[xStart, yStart];
                goalNode  = gridVisualisation.nodesVisualisationData[xGoal, yGoal];

                xGoalInput.text = xGoal.ToString();
                yGoalInput.text = yGoal.ToString();
                xUnitInput.text = xStart.ToString();
                yUnitInput.text = yStart.ToString();
                ChangeTileToGoalNode(goalNode);
                InstantiateUnit(startNode);
            }

            flowfieldPathfinding.CreatePathfinding(grid, gridVisualisation);
            flowfieldPathfinding.FlowfieldPath(goalNode.transform.position, PathfindingVisualisationAid, heuristicIndex);
        }
    }
Пример #3
0
    void ShowPathColors(GridVisualisation gridvisualisation)
    {
        if (gridvisualisation == null)
        {
            return;
        }

        if (pathList != null && pathList.Count > 0)
        {
            gridvisualisation.ColorNodes(pathList, pathListColor);
        }
    }
Пример #4
0
    public void CreatePathfinding(GridManager gridnodes, GridVisualisation gridvisualisation)
    {
        if (gridvisualisation == null || gridnodes == null)
        {
            UnityEngine.Debug.Log("Pathfinder Init error: missing component(s)!");
            return;
        }

        grid = gridnodes;
        gridVisualisation = gridvisualisation;

        ClearLists();
        ResetNodeParentgCostAndhCost();
    }
Пример #5
0
    void ShowSearchColors(GridVisualisation gridvisualisation)
    {
        if (gridvisualisation == null)
        {
            return;
        }

        if (openList != null)
        {
            gridvisualisation.ColorNodes(openList.ToList(), openListColor);
        }

        if (closedList != null)
        {
            gridvisualisation.ColorNodes(closedList, closedListColor);
        }
    }
 public void InitiatePathfinding(GridManager grid, GridVisualisation gridvisualisation)
  {
      pathFinding.CreatePathfinding(grid, gridvisualisation);
  }