コード例 #1
0
ファイル: TestAstar.cs プロジェクト: wcraigjones/GGJ20-IBKK
    void TestPath()
    {
        Path p = Astar.CalculatePath(start, end, grid);

        foreach (Node n in p.nodes)
        {
            var mesh = n.GetComponent <MeshRenderer>();
            mesh.material.color = Color.green;
        }
    }
コード例 #2
0
ファイル: Pather.cs プロジェクト: Googlproxer/SmartBot
 public static void ComputePath()
 {
     if (m_start != null && m_end != null)
     {
         m_finalPath = m_astar.CalculatePath(m_start, m_end);
     }
 }
コード例 #3
0
ファイル: Node.cs プロジェクト: wcraigjones/GGJ20-IBKK
    private void OnMouseEnter()
    {
        var grid = FindObjectOfType <GridSystem>();

        Path p = Astar.CalculatePath(grid.gridNodes[0], this, grid);

        foreach (Node n in grid.gridNodes)
        {
            if (n.walkable)
            {
                n.GetComponent <MeshRenderer>().material.SetColor("_BaseColor", Color.white);
            }
        }
        foreach (Node n in p.nodes)
        {
            var mesh = n.GetComponent <MeshRenderer>();
            mesh.material.SetColor("_BaseColor", Color.green);
        }
        //p.nodes[0].GetComponent<MeshRenderer>().material.color = Color.green;
    }
コード例 #4
0
    private void Update()
    {
        if (movingInitiatedUnit == false)
        {
            return;
        }

        Node startingNode    = currentlyInitiatedUnit.GetMyGridNode();
        Node destinationNode = GetMousedOverNode();

        if (GetMousedOverNode() == null)
        {
            return;
        }

        //Will calculate path AND show the path in-game
        Path movementPath = Astar.CalculatePath(startingNode, destinationNode, generatedGrid);

        if (InputListener.Instance.PressedDown_Mouse_LeftClick)
        {
            OrderUnitMovement(currentlyInitiatedUnit, movementPath);
        }
    }