Пример #1
0
        public Room CreateRoom(int exits)
        {
            //temp room variable
            Room temp = new Room();

            //Array of 1's and 0's to determine where exits and maybe the type of the room eventually
            int[] bin = ToBinary(exits);

            //Compare binary to specific tests
            //1st bit = east
            //2nd = west
            //3rd = south
            //4th = north
            // 5th = up
            // 6th = down
            //7th and 8th may mean type eventually.

            if (bin[0] == 1)
            {
                temp.AddExit("east");
            }
            if (bin[1] == 1)
            {
                temp.AddExit("west");
            }
            if (bin[2] == 1)
            {
                temp.AddExit("south");
            }
            if (bin[3] == 1)
            {
                temp.AddExit("north");
            }
            if (bin[4] == 1)
            {
                temp.AddExit("up");
            }
            if (bin[5] == 1)
            {
                temp.AddExit("down");
            }
            if (bin[6] == 0 && bin[7] == 0)
            {
                temp.changeType("Special");
            }
            if (bin[6] == 0 && bin[7] == 1)
            {
                temp.changeType("Treasures");
            }
            if (bin[6] == 1 && bin[7] == 0)
            {
                temp.changeType("Enemies");
            }
            if (bin[6] == 1 && bin[7] == 1)
            {
                temp.changeType("Boss");
            }

            return new Room();
        }
Пример #2
0
        public void CreateRooms(int[,,] exits, char[,,] type)
        {
            for (int i = 0; i < WorldMap.GetLength(0); i++)
            {
                for (int j = 0; j < WorldMap.GetLength(1); j++)
                {
                    for (int k = 0; k < WorldMap.GetLength(2); k++)
                    {
                        WorldMap[i, j, k] = new Room();
                    }
                }
            }

            for (int i = 0; i < WorldMap.GetLength(0); i++)
            {
                for (int j = 0; j < WorldMap.GetLength(1); j++)
                {
                    for (int k = 0; k < WorldMap.GetLength(2); k++)
                    {
                        if (exits[i, j, k] != 0)
                        {
                            WorldMap[i, j, k] = CreateRoom(exits[i, j, k]);

                        }
                    }
                }
            }
        }