Beispiel #1
0
        public void AddExtraConnectionBetweenChildren(Map baseMap)
        {
            //Wander down the tree to a leaf, keeping track of the number of nodes with 2 children (that could be possible connections)
            //When we come back down the tree, try to get one of the 2 children nodes to draw a connection

            if (childLeft != null && childRight != null)
            {
                treeDepth++;

                //Pick one node at random
                if (MapGeneratorBSP.rand.Next(2) < 1)
                {
                    childLeft.AddExtraConnectionBetweenChildren(baseMap);
                }
                else
                {
                    childRight.AddExtraConnectionBetweenChildren(baseMap);
                }

                //We reach here after we have hit the leaf
                //If we haven't made a connection yet there's a chance we will connect our children

                if (newConnectionMade == false &&
                    MapGeneratorBSP.rand.Next(treeDepth) < 1)
                {
                    newConnectionMade = true;

                    //Draw a connecting corridor between our two children
                    DrawConnectingCorriderBetweenChildren(baseMap);
                }
            }
            else if (childLeft != null)
            {
                childLeft.AddExtraConnectionBetweenChildren(baseMap);
            }
            else if (childRight != null)
            {
                childRight.AddExtraConnectionBetweenChildren(baseMap);
            }
        }