Beispiel #1
0
    private void CreateStartNode(Vector3 position)
    {
        Cluster startCluster = map.ClusterFromPosition(position);
        Tile startTile = startCluster.TileFromPosition(position);
        if (startTile.cost == 255){
            this.startPortal = null;
            return;
        }

        Portal start = new Portal ();
        start.SetCluster(startCluster);
        start.AddTile (startTile);
        FindConnections (start, startCluster, true);

        this.startPortal = start;
    }
Beispiel #2
0
    private void FindPortalsVertical(Cluster c1, Cluster c2)
    {
        if (c1 == null || c2 == null)
            return;
        if (!c1.updated && !c2.updated)
            return;
        Tile[,] g1 = c1.GetGrid ();
        Tile[,] g2 = c2.GetGrid ();
        int max = Cluster.size - 1;
        Portal currentPort1 = null;
        Portal currentPort2 = null;
        bool isTracking = false;

        for (int i = 0; i < Cluster.size; i++) {
            if (g1 [max, i].cost < 255 && g2 [0, i].cost < 255) {
                if (isTracking) {
                    currentPort1.AddTile (g1 [max, i]);
                    currentPort2.AddTile (g2 [0, i]);
                } else {
                    isTracking = true;
                    currentPort1 = new Portal (c1);
                    currentPort2 = new Portal (c2);
                    currentPort1.AddTile (g1 [max, i]);
                    currentPort2.AddTile (g2 [0, i]);
                }
            } else {
                if (isTracking) {
                    Portal.Connect (currentPort1, currentPort2, 1);
                    AddPortal (currentPort1);
                    AddPortal (currentPort2);
                    isTracking = false;
                }
            }
        }
        if (isTracking) {
            Portal.Connect (currentPort1, currentPort2, 1);
            AddPortal (currentPort1);
            AddPortal (currentPort2);
            isTracking = false;
        }
    }
Beispiel #3
0
    private void CreateEndNode(Vector3 position)
    {
        RemoveTargetPortal();
        Cluster endCluster = map.ClusterFromPosition(position);
        Tile endTile = endCluster.TileFromPosition(position);
        if (endTile.cost == 255){
            endPortal = null;
            return;
        }

        Portal end = new Portal(endCluster);
        end.AddTile(endTile);
        FindConnections(end, endCluster, false);

        this.endPortal = end;
    }