Esempio n. 1
0
    private void actuallyCreateRoute(int roomIndex, Vector3 startPos, Vector3 endPos)
    {
        List <Vector3> tempRoute = new List <Vector3>();

        //pathFinder.logThis("start = " + startPos + ", and end = " + endPos);

        grid.CreateGrid(rooms[roomIndex]);
        tempRoute = pathFinder.FindPathForOther(startPos - rooms[roomIndex].mapOffSet, endPos - rooms[roomIndex].mapOffSet, rooms[roomIndex].mapOffSet, false, -1);

        AddToRoute(tempRoute);
    }
Esempio n. 2
0
    public void CreatePaths(PathFinding pathFinder, Grid grid)
    {
        if (activeEntrances.Count == 0)
        {
            return;
        }

        while (pathsToFind.Count > 0)
        {
            Vector3 startPos, endPos;
            int     path = pathsToFind.Dequeue();
            int     side;

            switch (path)
            {
            case 1:
                startPos = GetEntranceForSide(0).location;
                endPos   = GetEntranceForSide(1).location;
                side     = 0;
                break;

            case 4:
                startPos = GetEntranceForSide(0).location;
                endPos   = GetEntranceForSide(2).location;
                side     = 0;
                break;

            case 5:
                startPos = GetEntranceForSide(2).location;
                endPos   = GetEntranceForSide(1).location;
                side     = 2;
                break;

            case 9:
                startPos = GetEntranceForSide(0).location;
                endPos   = GetEntranceForSide(3).location;
                side     = 0;
                break;

            case 10:
                startPos = GetEntranceForSide(3).location;
                endPos   = GetEntranceForSide(1).location;
                side     = 3;
                break;

            case 13:
                startPos = GetEntranceForSide(2).location;
                endPos   = GetEntranceForSide(3).location;
                side     = 2;
                break;

            default:
                Debug.Log("errer, path# is unsupported");
                startPos = new Vector3(0, 0, 0);
                endPos   = new Vector3(0, 0, 0);
                side     = 0;
                break;
            }

            grid.CreateGrid(this);
            Paths.Add(new Path(path, pathFinder.FindPathForOther(startPos, endPos, mapOffSet, false, side)));
        }
    }