Ejemplo n.º 1
0
    Vector2 getGoalCell()
    {
        Vector2 goalpos = new Vector2();

        for (int y = 0; y < mapchip.chip_num_y; y++)
        {
            for (int x = 0; x < mapchip.chip_num_x; x++)
            {
                if (roots[rootnum][y][x] == RootType.START)
                {
                    goalpos = new Vector2(x, y);
                }
            }
        }

        return(goalpos);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// A*準備
    /// </summary>
    void astarSetup()
    {
        rootRandomDecide();
        astarstate = AstarState.SEARCH;

        int x        = (int)retCell().x;
        int y        = (int)retCell().y;
        var startpos = new AStar.RootPosition(x, y);

        Vector2 tempgoalpos;

        tempgoalpos = getGoalCell();
        goalpos     = new AStar.RootPosition((int)tempgoalpos.x, (int)tempgoalpos.y);

        nodemanager = new AStar.NodeManager(goalpos.x, goalpos.y, mapchip);
        node        = nodemanager.openNode(startpos.x, startpos.y, 0, null);
        nodemanager.addOpenNode(node);

        rootlist = new List <AStar.RootPosition>();

        astar_trycount = 0;
        astarmovecount = 0;
    }