Ejemplo n.º 1
0
    private void FindAllPathsToLeaveMap()
    {
        MapUtil mapUtil = GameObject.Find("MapUtil").GetComponent <MapUtil>();

        Node startNode = mapUtil.FindNearestNode(ship.Ship.X, ship.Ship.Y);

        List <Node> exitNodes = mapUtil.ExitNodes();

        foreach (Node exitNode in exitNodes)
        {
            List <ShipPath> pathsToExit = mapUtil.FindPath(startNode, exitNode);
            paths.AddRange(pathsToExit);
        }
    }
Ejemplo n.º 2
0
    private void FindAllPathsToUnloadAndLeaveMap()
    {
        MapUtil mapUtil = GameObject.Find("MapUtil").GetComponent <MapUtil>();

        Node        startNode     = mapUtil.FindNearestNode(ship.Ship.X, ship.Ship.Y);
        List <Node> exitNodes     = mapUtil.ExitNodes();
        List <Dock> docksToUnload = mapUtil.GetAllDocksOfType(ship.Ship.Industry);

        if (docksToUnload.Count == 0)
        {
            Debug.LogError("No dock found!");
        }

        foreach (Dock dock in docksToUnload)
        {
            List <ShipPath> pathsToDock;
            List <ShipPath> pathsToExit;

            pathsToDock = mapUtil.FindPath(startNode, dock.node);
            if (pathsToDock.Count == 0)
            {
                return;
            }
            foreach (Node exitNode in exitNodes)
            {
                pathsToExit = mapUtil.FindPath(dock.node, exitNode);
                if (pathsToExit.Count == 0)
                {
                    foreach (ShipPath pathToDock in pathsToDock)
                    {
                        paths.Add(pathToDock);
                    }
                }
                foreach (ShipPath pathToDock in pathsToDock)
                {
                    foreach (ShipPath pathToExit in pathsToExit)
                    {
                        paths.Add(pathToDock.ConcatenatePath(pathToExit));
                    }
                }
            }
        }
    }