Exemple #1
0
        public void GenFromBSP(BSP bsp)
        {
            RoomGraph next;

            while (!bsp.Leaf)
            {
                next = new RoomGraph();
                if (bsp.Horizontal)
                {
                    if (neighbourg.ContainsKey(NeighbourgPos.Right))
                    {
                        next.addNeighbourg(neighbourg[NeighbourgPos.Right], NeighbourgPos.Right);
                        neighbourg[NeighbourgPos.Right].changeNeighbourg(next, NeighbourgPos.Left);
                        this.changeNeighbourg(next, NeighbourgPos.Right);
                    }
                    else
                    {
                        this.addNeighbourg(next, NeighbourgPos.Right);
                    }
                    next.addNeighbourg(this, NeighbourgPos.Left);
                }
                else
                {
                    if (neighbourg.ContainsKey(NeighbourgPos.Down))
                    {
                        next.addNeighbourg(neighbourg[NeighbourgPos.Down], NeighbourgPos.Down);
                        neighbourg[NeighbourgPos.Down].changeNeighbourg(next, NeighbourgPos.Up);
                        this.changeNeighbourg(next, NeighbourgPos.Down);
                    }
                    else
                    {
                        this.addNeighbourg(next, NeighbourgPos.Down);
                    }
                    next.addNeighbourg(this, NeighbourgPos.Up);
                }
                next.GenFromBSP(bsp.Right);
                bsp = bsp.Left;
            }
            pos = bsp;

            room = new DungeonRoom(new Vector3(bsp.Width, 1, bsp.Height), new Vector3(bsp.X, 0, bsp.Y));
            room.LoadRoom();
        }