Esempio n. 1
0
    private bool diagonalRoomConnected(RoomNodes nextNode)
    {
        RoomNodes badConnector;

        // current node above next node, could lead to possible conflict from node below this one.
        if (ID / RoomPathGenerator.LEVELS > nextNode.getID() / RoomPathGenerator.LEVELS)
        {
            if ((badConnector = map.getNeighbors(nextNode.getID() + RoomPathGenerator.LEVELS)) != null)
            {
                if (badConnector.isNodeConnected(map.getNeighbors(ID - RoomPathGenerator.LEVELS)))
                {
                    return(true);
                }
            }
        }         // current node below next node, could lead to possible conflict from node above this one.
        else if (ID / RoomPathGenerator.LEVELS < nextNode.getID() / RoomPathGenerator.LEVELS)
        {
            if ((badConnector = map.getNeighbors(nextNode.getID() - RoomPathGenerator.LEVELS)) != null)
            {
                if (badConnector.isNodeConnected(map.getNeighbors(ID + RoomPathGenerator.LEVELS)))
                {
                    return(true);
                }
            }
        }

        // straight corridor, no problems. (due to corridor generation, if that changes this will too)
        // also if diagonals dont interfer with each other.
        return(false);
    }
Esempio n. 2
0
    private void createDungeonPath()
    {
        // begin algorithm get first node of graph
        current = (RoomNodes)notInPath [Random.Range(0, notInPath.Count)];
        notInPath.Remove(current);
        inPath.Add(current);

        // keep connecting nodes -- ends when reaches node with no unconnected neighbors that are not already in the path
        RoomNodes previous = current;

        previousNodeID = previous.getID();
        while ((current = current.getRandomUnconnectedNeighbor(previousNodeID)) != null)
        {
            previousNodeID = previous.getID();

            if (previous.connectTwoNeighbors(current))
            {
                current.connectTwoNeighbors(previous);

                notInPath.Remove(current);
                inPath.Add(current);

                previous = current;
            }
            else
            {
                break;
            }
        }


        // some nodes may still be unconnected, the next stage is to connect them to a neighbor whom is attached until all remaining nodes are connected.
        connectUnconnectedNodes(2);
    }
Esempio n. 3
0
 public EntranceEdges(OverworldNodes overworldNodes, RoomNodes roomNodes, RawEntranceCollection rawEntranceCollection, RawItemLocationCollection itemLocations)
 {
     this._overworldNodes        = overworldNodes;
     this._roomNodes             = roomNodes;
     this._rawEntranceCollection = rawEntranceCollection;
     this._itemLocations         = itemLocations;
     FillEntranceEdges();
 }
Esempio n. 4
0
        public ExitEdges(OverworldNodes overworldNodes, RoomNodes roomNodes, RawExitCollection rawExitCollection)
        {
            this._overworldNodes    = overworldNodes;
            this._roomNodes         = roomNodes;
            this._rawExitCollection = rawExitCollection;

            FillExitEdges();
        }
Esempio n. 5
0
 public RoomEdges(RoomNodes roomNodes, OverworldNodes overworldNodes, BossNodes bossNodes, RawRoomEdgeCollection rawRoomEdges)
 {
     this._roomNodes      = roomNodes;
     this._overworldNodes = overworldNodes;
     this._bossNodes      = bossNodes;
     this._rawRoomEdges   = rawRoomEdges;
     this.Edges           = new List <Edge>();
     FillRoomEdges();
 }
Esempio n. 6
0
    // to use in hash table, one must override hash code method as well
    public override bool Equals(object other)
    {
        if (other is RoomNodes)
        {
            RoomNodes r = (RoomNodes)other;
            return(this.ID == r.getID());
        }

        return(false);
    }
Esempio n. 7
0
 public bool isNodeConnected(RoomNodes nodeToTest)
 {
     foreach (RoomNodes RN in connectedNeighbors)
     {
         if (RN == nodeToTest)
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 8
0
    // checks if this node is connected to nextNode's verticle neighbors
    public bool notConnectedToVerticleNodes(RoomNodes nextNode)
    {
        int verticleID = nextNode.getID() % RoomPathGenerator.LEVELS;          // gives 0 - 8.

        for (int i = 0; i < 3; ++i)
        {
            if (this.isNodeConnected(map.getNeighbors(verticleID + (RoomPathGenerator.LEVELS * i))))
            {
                return(false);
            }
        }

        return(true);
    }
Esempio n. 9
0
        void FillNodesAndEdges(RawEntranceCollection rawEntranceCollection, RawExitCollection rawExitCollection, RawItemLocationCollection rawItemLocationCollection, RawItemEdgeCollection rawItemEdges, RawRoomEdgeCollection rawRoomEdges)
        {
            _overworldNodes = new Data.OverworldNodes();
            _roomNodes      = new Data.RoomNodes();
            _bossNodes      = new Data.BossNodes();
            _itemNodes      = new Data.ItemLocations(rawItemLocationCollection);
            FillAllNodes();

            _areaEdges = new Data.AreaEdges(_overworldNodes);
            _roomEdges = new Data.RoomEdges(_roomNodes, _overworldNodes, _bossNodes, rawRoomEdges);
            _itemEdges = new ItemEdges(this, rawItemEdges);

            _entranceEdges = new EntranceEdges(_overworldNodes, _roomNodes, rawEntranceCollection, rawItemLocationCollection);
            _exitEdges     = new ExitEdges(_overworldNodes, _roomNodes, rawExitCollection);

            FillAllEdges();
        }
Esempio n. 10
0
    // newConnect must be in the unconnected list
    // also connects given neighbor to this
    public bool connectTwoNeighbors(RoomNodes newConnect)
    {
        int count = unconnectedNeighbors.Count;

        unconnectedNeighbors.Remove(newConnect);

        if (count > unconnectedNeighbors.Count)
        {
            connectedNeighbors.Add(newConnect);
            enableCorridor(newConnect.getID());               // activates gameobject
            inPath = true;
            newConnect.setInPath();
            return(true);
        }

        return(false);
    }