Exemple #1
0
            static void OrganicMethod()

            {
                int          MapSize = 5;
                int          maxroomscurrentlevel = 1;
                int          maxroomsofnextlevel  = 1;
                int          CurrentLevel         = 0;
                int          nextlevelroom        = 1;
                bool         maxreached           = false;
                bool         tooclosetoMax        = false;
                List <Level> MapList = new List <Level>();

                // grow =========================================================
                while (maxreached == false) // num levels
                {
                    CurrentLevel++;
                    Level List = new Level(CurrentLevel);
                    maxroomscurrentlevel = maxroomsofnextlevel;
                    nextlevelroom        = 1;
                    if (maxreached == true) // break if 5 or 6
                    {
                        System.Console.WriteLine("break");
                        break;
                    }
                    for (int CurrentRoom = 1; CurrentRoom <= maxroomscurrentlevel; CurrentRoom++) // num rooms
                    {
                        if (nextlevelroom >= MapSize)                                             // check if 5 or 6
                        {
                            maxreached = true;
                            System.Console.WriteLine("maxreached");
                        }
                        int thisrandom = GetRandom(CurrentLevel);
                        if (thisrandom >= 2 && nextlevelroom < MapSize - 1 && tooclosetoMax == false) // add a room that joins onto 2 of next level. increase next level room count by 1.
                        {
                            room rm = new room(CurrentLevel, CurrentRoom, nextlevelroom, (nextlevelroom + 1));
                            maxroomsofnextlevel++;
                            nextlevelroom = nextlevelroom + 2;
                            List.add(rm);
                            System.Console.WriteLine($"nextlevelroom: {nextlevelroom}");
                            if (maxroomscurrentlevel >= MapSize - 1)
                            {
                                tooclosetoMax = true;
                                System.Console.WriteLine($"tooclosetoMax {tooclosetoMax}");
                            }
                        }
                        else
                        {
                            room rm = new room(CurrentLevel, CurrentRoom, nextlevelroom, (nextlevelroom));
                            nextlevelroom = nextlevelroom + 1;
                            List.add(rm);
                            System.Console.WriteLine($"nextlevelroom: {nextlevelroom}");
                        }
                    }
                    MapList.Add(List);
                }

                //stay===========================================================
                for (int x = 1; x <= 1; x++) // num levels
                {
                    CurrentLevel++;
                    Level List = new Level(CurrentLevel);
                    maxroomscurrentlevel = maxroomsofnextlevel;
                    nextlevelroom        = 1;

                    for (int CurrentRoom = 1; CurrentRoom <= maxroomscurrentlevel; CurrentRoom++) // num rooms
                    {
                        room rm = new room(CurrentLevel, CurrentRoom, nextlevelroom, (nextlevelroom));
                        nextlevelroom = nextlevelroom + 1;
                        List.add(rm);
                    }
                    MapList.Add(List);
                }

                //shrink========================================================
                while (maxroomscurrentlevel > 1)
                {
                    CurrentLevel++;
                    Level List = new Level(CurrentLevel);
                    maxroomscurrentlevel = maxroomsofnextlevel;

                    System.Console.WriteLine(maxroomscurrentlevel);

                    for (int CurrentRoom = 1; CurrentRoom <= maxroomscurrentlevel; CurrentRoom++) // num rooms
                    {
                        int thisrandom = GetRandom(CurrentLevel);
                        if (thisrandom >= 3 && CurrentRoom > 1) // add a room that joins onto 2 of next level. increase next level room count by 1.
                        {
                            room rm = new room(CurrentLevel, CurrentRoom, CurrentRoom - 1, (CurrentRoom - 1));
                            maxroomsofnextlevel = CurrentRoom - 1;
                            List.add(rm);
                        }
                        else
                        {
                            room rm = new room(CurrentLevel, CurrentRoom, CurrentRoom, (CurrentRoom));
                            maxroomsofnextlevel = CurrentRoom;
                            List.add(rm);
                        }
                    }
                    MapList.Add(List);
                }
                System.Console.WriteLine("end");
Exemple #2
0
 //methods
 public void add(room newroom)
 {
     this.RoomList.Add(newroom);
 }