Example #1
0
 public void TestGeneration(int iWidth, int iHeight, GameSessionData.RogueLikeSession xSession)
 {
     this.enRegion = xSession.enCurrentRegion;
     RogueLikeMode.Room.iLocalIDPool = 0;
     this.iFloorHeight = iHeight;
     this.iFloorWidth = iWidth;
     this.lxRooms.Clear();
     RogueLikeMode.Room xStart = new RogueLikeMode.Room(this.rand);
     xStart.enRoomType = RogueLikeMode.Room.RoomTypes.StartingRoom;
     xStart.bCompleted = true;
     if (this.enRegion == Level.WorldRegion.FlyingFortress)
     {
         xStart.enPropertyFlags |= RogueLikeMode.Room.RoomProperties.RoomVarianceA;
         if (xSession.iCurrentFloor == 7)
         {
             while (xStart.iRandSeed % 8 != 0)
             {
                 xStart.iRandSeed++;
             }
         }
     }
     this.lxRooms.Add(xStart);
     RogueLikeMode.Room[,] aiFloor = new RogueLikeMode.Room[this.iFloorWidth, this.iFloorHeight];
     int iX = this.iFloorWidth / 2;
     int iY = 7;
     aiFloor[iX, iY] = xStart;
     xStart.v2Pos = new Point(iX, iY);
     int iRoomsToGenerate = 2 + xSession.iCurrentFloor;
     if (xSession.iCurrentFloor > 2)
     {
         iRoomsToGenerate = 4 + (xSession.iCurrentFloor - 2) / 2;
     }
     int iRoomsGenerated = 0;
     Point pos = new Point(iX, iY);
     this.iHeadDir = 0;
     int iBranches = 0;
     List<int> liTried = new List<int>();
     bool bAddEventRoom = false;
     bool bAddChallengeRoom = false;
     bool bAddBossRoom = true;
     bool bAddTreasureRoom = false;
     int iAllowedDifficultEncounters = 0;
     if (xSession.enCurrentRegion == Level.WorldRegion.EvergrindEast)
     {
         iAllowedDifficultEncounters = 2 + Program.game.dixPlayers.Count - 1;
     }
     else if (xSession.enCurrentRegion == Level.WorldRegion.HalloweenForest)
     {
         iAllowedDifficultEncounters = 2 + Program.game.dixPlayers.Count - 1;
     }
     else if (xSession.enCurrentRegion == Level.WorldRegion.FlyingFortress)
     {
         iAllowedDifficultEncounters = 2 + Program.game.dixPlayers.Count - 1;
     }
     bool bAddShopRoom = xSession.iFloorsWithoutShop >= 3 || this.rand.Next(3 - xSession.iFloorsWithoutShop) == 0;
     if (xSession.iCurrentFloor == 1)
     {
         bAddTreasureRoom = true;
         bAddChallengeRoom = false;
         bAddShopRoom = false;
     }
     if (Program.game.xGlobalData.WorldRelevantData.enActiveQuest == QuestCodex.QuestID._RogueLikeQuest_HaddockRedFishQuest && xSession.iCurrentFloor == 4)
     {
         bAddEventRoom = true;
     }
     else if ((xSession.iCurrentFloor >= 3 && xSession.iCurrentFloor <= 6) || xSession.iCurrentFloor >= 9)
     {
         bAddEventRoom = (xSession.iFloorsWithoutEvents >= 5 || this.rand.Next(5 - xSession.iFloorsWithoutEvents) == 0);
         if (!bAddEventRoom)
         {
             xSession.iFloorsWithoutEvents++;
         }
     }
     if (bAddShopRoom)
     {
         xSession.iFloorsWithoutShop = 0;
     }
     if (xSession.iCurrentFloor > 1)
     {
         bAddChallengeRoom = true;
         bAddTreasureRoom = (this.rand.Next(3) == 0);
     }
     while (iRoomsGenerated < iRoomsToGenerate)
     {
         liTried.Clear();
         int iTurn = this.rand.Next(3) - 1;
         liTried.Add(iTurn);
         bool bCreate = true;
         while (!this.ValidNewPosition(this.AddPoint(pos, this.DirToPoint((this.iHeadDir + iTurn + 4) % 4)), pos, aiFloor))
         {
             if (!liTried.Contains(0))
             {
                 iTurn = 0;
                 liTried.Add(0);
             }
             else if (!liTried.Contains(1))
             {
                 iTurn = 1;
                 liTried.Add(1);
             }
             else if (!liTried.Contains(-1))
             {
                 iTurn = -1;
                 liTried.Add(-1);
             }
             else
             {
                 RogueLikeMode.Room mossa = this.lxRooms[this.rand.Next(this.lxRooms.Count)];
                 while (mossa.enRoomType != RogueLikeMode.Room.RoomTypes.Normal)
                 {
                     mossa = this.lxRooms[this.rand.Next(this.lxRooms.Count)];
                 }
                 pos = mossa.v2Pos;
                 iBranches++;
                 bCreate = false;
                 if (iBranches >= 100)
                 {
                     this.TestGeneration(iWidth, iHeight, xSession);
                     return;
                 }
                 break;
             }
         }
         if (bCreate)
         {
             this.iHeadDir = (this.iHeadDir + iTurn + 4) % 4;
             RogueLikeMode.Room xPrev = aiFloor[pos.X, pos.Y];
             pos = this.AddPoint(pos, this.DirToPoint(this.iHeadDir));
             RogueLikeMode.Room xMos = new RogueLikeMode.Room(this.rand, pos.X, pos.Y);
             if (this.enRegion == Level.WorldRegion.FlyingFortress && RogueLikeMode.randLevelLoadStuff.Next(2) == 0)
             {
                 xMos.enPropertyFlags |= RogueLikeMode.Room.RoomProperties.RoomVarianceA;
             }
             xMos.iDistanceFromStartRoom = xPrev.iDistanceFromStartRoom + 1;
             if (iAllowedDifficultEncounters > 0 && RogueLikeMode.randLevelLoadStuff.Next(4) == 0)
             {
                 xMos.enPropertyFlags |= RogueLikeMode.Room.RoomProperties.AllowDifficultEnemy;
                 iAllowedDifficultEncounters--;
             }
             this.lxRooms.Add(xMos);
             aiFloor[pos.X, pos.Y] = xMos;
             iRoomsGenerated++;
             if (this.PositionAtEdge(pos) || (iBranches == 0 && iRoomsGenerated > (int)((float)iRoomsToGenerate * 0.65f)))
             {
                 this.iHeadDir = this.rand.Next(4);
                 RogueLikeMode.Room xContinueRoom = null;
                 while (xContinueRoom == null)
                 {
                     xContinueRoom = this.lxRooms[this.rand.Next(this.lxRooms.Count)];
                     if (xContinueRoom.enRoomType != RogueLikeMode.Room.RoomTypes.Normal)
                     {
                         xContinueRoom = null;
                     }
                 }
                 pos = xContinueRoom.v2Pos;
                 iBranches++;
             }
         }
     }
     int iImpossible = 0;
     RogueLikeMode.Room.BossEncounters enUsedBoss = RogueLikeMode.Room.BossEncounters.None;
     while (bAddBossRoom)
     {
         iImpossible++;
         if (iImpossible >= 100)
         {
             this.TestGeneration(iWidth, iHeight, xSession);
             return;
         }
         RogueLikeMode.Room xAdd = this.lxRooms[this.rand.Next(this.lxRooms.Count)];
         pos = xAdd.v2Pos;
         if (pos.Y != 0 && aiFloor[pos.X, pos.Y - 1] == null && xAdd.enRoomType == RogueLikeMode.Room.RoomTypes.Normal && xAdd.iDistanceFromStartRoom >= Math.Min(1 + xSession.iCurrentFloor, 5) && this.ValidNewPosition(this.AddPoint(pos, this.DirToPoint(0)), pos, aiFloor))
         {
             RogueLikeMode.Room xBossRoom = new RogueLikeMode.Room(this.rand, pos.X, pos.Y - 1);
             xBossRoom.iDistanceFromStartRoom = xAdd.iDistanceFromStartRoom + 1;
             xBossRoom.enRoomType = RogueLikeMode.Room.RoomTypes.Boss;
             enUsedBoss = this.GetBossEncounter(xSession);
             if (xSession.iCurrentFloor == 1 && Program.game.xGlobalData.WorldRelevantData.enActiveQuest == QuestCodex.QuestID._RogueLikeQuest_FindCarpenterHammer)
             {
                 enUsedBoss = RogueLikeMode.Room.BossEncounters.VilyaSolo;
             }
             if (xSession.iCurrentFloor == 1 && Program.game.xGlobalData.WorldRelevantData.enActiveQuest == QuestCodex.QuestID._RogueLikeQuest_HalloweedPollenForGardener)
             {
                 enUsedBoss = RogueLikeMode.Room.BossEncounters.Halloweed;
             }
             if (xSession.iCurrentFloor == 3 && Program.game.xGlobalData.WorldRelevantData.enActiveQuest == QuestCodex.QuestID._RogueLikeQuest_FindStonecutterMaterials)
             {
                 enUsedBoss = RogueLikeMode.Room.BossEncounters.VilyaElite;
             }
             if (xSession.iCurrentFloor == 3 && Program.game.xGlobalData.WorldRelevantData.enActiveQuest == QuestCodex.QuestID._RogueLikeQuest_GiantsEssenceForPlott)
             {
                 enUsedBoss = RogueLikeMode.Room.BossEncounters.RegularGigaSlime;
             }
             if (Program.game.xGlobalData.WorldRelevantData.enActiveQuest == QuestCodex.QuestID._RogueLikeQuest_OldmanRedGigaSlime)
             {
                 if (xSession.iCurrentFloor == 3 && enUsedBoss == RogueLikeMode.Room.BossEncounters.RegularGigaSlime)
                 {
                     enUsedBoss = RogueLikeMode.Room.BossEncounters.WhiteRabbyAndFriends;
                 }
                 else if (xSession.iCurrentFloor == 4)
                 {
                     enUsedBoss = RogueLikeMode.Room.BossEncounters.RegularGigaSlime;
                 }
             }
             if (this.enRegion == Level.WorldRegion.FlyingFortress)
             {
                 xBossRoom.enPropertyFlags |= RogueLikeMode.Room.RoomProperties.RoomVarianceA;
                 if (xSession.iCurrentFloor == 8)
                 {
                     enUsedBoss = RogueLikeMode.Room.BossEncounters.Gund4m;
                 }
             }
             xBossRoom.enBossEncounter = enUsedBoss;
             if (enUsedBoss == RogueLikeMode.Room.BossEncounters.RegularGigaSlime)
             {
                 xBossRoom.iRoomHeight = 200;
                 xBossRoom.iRoomWidth = 400;
             }
             else if (enUsedBoss == RogueLikeMode.Room.BossEncounters.VilyaElite)
             {
                 xBossRoom.iRoomHeight = 160;
                 xBossRoom.iRoomWidth = 360;
             }
             else if (enUsedBoss == RogueLikeMode.Room.BossEncounters.WhiteRabbyAndFriends)
             {
                 xBossRoom.iRoomHeight = 180;
                 xBossRoom.iRoomWidth = 360;
             }
             else if (enUsedBoss == RogueLikeMode.Room.BossEncounters.TerrorWeed)
             {
                 xBossRoom.iRoomHeight = 200;
                 xBossRoom.iRoomWidth = 400;
             }
             else if (enUsedBoss == RogueLikeMode.Room.BossEncounters.Halloweed)
             {
                 while (xBossRoom.iRandSeed % 4 != 0)
                 {
                     xBossRoom.iRandSeed++;
                 }
             }
             else if (enUsedBoss == RogueLikeMode.Room.BossEncounters.VilyaSolo)
             {
                 while (xBossRoom.iRandSeed % 4 != 2)
                 {
                     xBossRoom.iRandSeed++;
                 }
             }
             else if (enUsedBoss == RogueLikeMode.Room.BossEncounters.BeeHive)
             {
                 while (xBossRoom.iRandSeed % 4 != 1)
                 {
                     xBossRoom.iRandSeed++;
                 }
             }
             this.lxRooms.Add(xBossRoom);
             aiFloor[xBossRoom.v2Pos.X, xBossRoom.v2Pos.Y] = xBossRoom;
             break;
         }
     }
     iImpossible = 0;
     RogueLikeMode.Room.ChallengeRooms enUsedChallenge = RogueLikeMode.Room.ChallengeRooms.FishingChallenge01;
     while (bAddChallengeRoom)
     {
         iImpossible++;
         if (iImpossible >= 100)
         {
             this.TestGeneration(iWidth, iHeight, xSession);
             return;
         }
         RogueLikeMode.Room xAdd2 = this.lxRooms[this.rand.Next(this.lxRooms.Count)];
         pos = xAdd2.v2Pos;
         Point newPos = this.AddPoint(pos, this.RanDir());
         if (xSession.enCurrentRegion == Level.WorldRegion.FlyingFortress)
         {
             newPos = this.AddPoint(pos, this.RanDir(new int[]
             {
                 0,
                 1,
                 3
             }));
         }
         if (this.ValidNewPosition(newPos, pos, aiFloor) && aiFloor[newPos.X, newPos.Y] == null && xAdd2.enRoomType == RogueLikeMode.Room.RoomTypes.Normal)
         {
             RogueLikeMode.Room xChallengeRoom = new RogueLikeMode.Room(this.rand, newPos.X, newPos.Y);
             xChallengeRoom.iDistanceFromStartRoom = xAdd2.iDistanceFromStartRoom + 1;
             xChallengeRoom.enRoomType = RogueLikeMode.Room.RoomTypes.Challenge;
             enUsedChallenge = this.GetChallengeEncounter(xSession);
             xChallengeRoom.enChallengeEncounter = enUsedChallenge;
             if (enUsedChallenge == RogueLikeMode.Room.ChallengeRooms.ChickenChasePillar01)
             {
                 while (xChallengeRoom.iRandSeed % 4 != 0)
                 {
                     xChallengeRoom.iRandSeed++;
                 }
             }
             else if (enUsedChallenge == RogueLikeMode.Room.ChallengeRooms.ChickenChasePillar02)
             {
                 while (xChallengeRoom.iRandSeed % 4 != 1)
                 {
                     xChallengeRoom.iRandSeed++;
                 }
             }
             else if (enUsedChallenge == RogueLikeMode.Room.ChallengeRooms.ChickenChasePillar03)
             {
                 while (xChallengeRoom.iRandSeed % 4 != 2)
                 {
                     xChallengeRoom.iRandSeed++;
                 }
             }
             else if (enUsedChallenge == RogueLikeMode.Room.ChallengeRooms.ChickenChasePillar04)
             {
                 while (xChallengeRoom.iRandSeed % 4 != 0)
                 {
                     xChallengeRoom.iRandSeed++;
                 }
             }
             else if (enUsedChallenge == RogueLikeMode.Room.ChallengeRooms.ChickenChasePillar05)
             {
                 while (xChallengeRoom.iRandSeed % 4 != 1)
                 {
                     xChallengeRoom.iRandSeed++;
                 }
             }
             else if (enUsedChallenge == RogueLikeMode.Room.ChallengeRooms.KillInOrderPillar01)
             {
                 while (xChallengeRoom.iRandSeed % 4 != 2)
                 {
                     xChallengeRoom.iRandSeed++;
                 }
             }
             else if (enUsedChallenge == RogueLikeMode.Room.ChallengeRooms.KillInOrderPillar02)
             {
                 while (xChallengeRoom.iRandSeed % 4 != 3)
                 {
                     xChallengeRoom.iRandSeed++;
                 }
             }
             else if (enUsedChallenge == RogueLikeMode.Room.ChallengeRooms.BlockPuzzle01)
             {
                 while (xChallengeRoom.iRandSeed % 4 != 0)
                 {
                     xChallengeRoom.iRandSeed++;
                 }
                 if (this.enRegion == Level.WorldRegion.EvergrindEast)
                 {
                     xChallengeRoom.iRoomHeight = 200;
                     xChallengeRoom.iRoomWidth = 400;
                 }
             }
             else if (enUsedChallenge == RogueLikeMode.Room.ChallengeRooms.BlockPuzzle02)
             {
                 while (xChallengeRoom.iRandSeed % 4 != 1)
                 {
                     xChallengeRoom.iRandSeed++;
                 }
                 if (this.enRegion == Level.WorldRegion.EvergrindEast)
                 {
                     xChallengeRoom.iRoomHeight = 200;
                     xChallengeRoom.iRoomWidth = 400;
                 }
             }
             else if (enUsedChallenge == RogueLikeMode.Room.ChallengeRooms.BlockPuzzle03)
             {
                 while (xChallengeRoom.iRandSeed % 4 != 1)
                 {
                     xChallengeRoom.iRandSeed++;
                 }
                 if (this.enRegion == Level.WorldRegion.EvergrindEast)
                 {
                     xChallengeRoom.iRoomHeight = 200;
                     xChallengeRoom.iRoomWidth = 400;
                 }
             }
             else if (enUsedChallenge == RogueLikeMode.Room.ChallengeRooms.ChickenChaseEG01)
             {
                 xChallengeRoom.iRoomHeight = 200;
                 xChallengeRoom.iRoomWidth = 380;
             }
             else if (enUsedChallenge == RogueLikeMode.Room.ChallengeRooms.ChickenChaseEG02)
             {
                 xChallengeRoom.iRoomHeight = 200;
                 xChallengeRoom.iRoomWidth = 360;
             }
             else if (enUsedChallenge == RogueLikeMode.Room.ChallengeRooms.ChickenChaseEG03)
             {
                 xChallengeRoom.iRoomHeight = 200;
                 xChallengeRoom.iRoomWidth = 380;
             }
             else if (enUsedChallenge == RogueLikeMode.Room.ChallengeRooms.BoarDodging01)
             {
                 xChallengeRoom.iRoomHeight = 200;
                 xChallengeRoom.iRoomWidth = 340;
             }
             else if (enUsedChallenge == RogueLikeMode.Room.ChallengeRooms.BoarDodging02)
             {
                 xChallengeRoom.iRoomHeight = 200;
                 xChallengeRoom.iRoomWidth = 340;
             }
             else if (enUsedChallenge == RogueLikeMode.Room.ChallengeRooms.KillInOrderEG01)
             {
                 xChallengeRoom.iRoomHeight = 200;
                 xChallengeRoom.iRoomWidth = 310;
             }
             else if (enUsedChallenge == RogueLikeMode.Room.ChallengeRooms.KillInOrderEG02)
             {
                 xChallengeRoom.iRoomHeight = 200;
                 xChallengeRoom.iRoomWidth = 320;
             }
             else if (enUsedChallenge == RogueLikeMode.Room.ChallengeRooms.KillInOrderHalloween01)
             {
                 xChallengeRoom.iRoomHeight = 200;
                 xChallengeRoom.iRoomWidth = 320;
             }
             else if (enUsedChallenge == RogueLikeMode.Room.ChallengeRooms.KillInOrderHalloween02)
             {
                 xChallengeRoom.iRoomHeight = 200;
                 xChallengeRoom.iRoomWidth = 320;
             }
             else if (enUsedChallenge == RogueLikeMode.Room.ChallengeRooms.HalloweenSurvival02_Bats)
             {
                 xChallengeRoom.iRoomHeight = 180;
                 xChallengeRoom.iRoomWidth = 300;
             }
             else if (enUsedChallenge == RogueLikeMode.Room.ChallengeRooms.HalloweenSurvival03_BatsAndThorns)
             {
                 xChallengeRoom.iRoomHeight = 180;
                 xChallengeRoom.iRoomWidth = 300;
             }
             else if (enUsedChallenge >= RogueLikeMode.Room.ChallengeRooms.BulletHell01 && enUsedChallenge <= RogueLikeMode.Room.ChallengeRooms.BulletHell03)
             {
                 while (xChallengeRoom.iRandSeed % 8 != 0)
                 {
                     xChallengeRoom.iRandSeed++;
                 }
                 xChallengeRoom.enPropertyFlags |= RogueLikeMode.Room.RoomProperties.RoomVarianceA;
             }
             else if (enUsedChallenge == RogueLikeMode.Room.ChallengeRooms.PerfectGuardFlying01)
             {
                 while (xChallengeRoom.iRandSeed % 8 != 3)
                 {
                     xChallengeRoom.iRandSeed++;
                 }
             }
             else if (enUsedChallenge == RogueLikeMode.Room.ChallengeRooms.KillInOrderFF01)
             {
                 while (xChallengeRoom.iRandSeed % 8 != 1)
                 {
                     xChallengeRoom.iRandSeed++;
                 }
             }
             else if (enUsedChallenge == RogueLikeMode.Room.ChallengeRooms.KillInOrderFF02)
             {
                 while (xChallengeRoom.iRandSeed % 8 != 0)
                 {
                     xChallengeRoom.iRandSeed++;
                 }
             }
             this.lxRooms.Add(xChallengeRoom);
             aiFloor[xChallengeRoom.v2Pos.X, xChallengeRoom.v2Pos.Y] = xChallengeRoom;
             break;
         }
     }
     iImpossible = 0;
     while (bAddEventRoom)
     {
         iImpossible++;
         if (iImpossible >= 100)
         {
             this.TestGeneration(iWidth, iHeight, xSession);
             return;
         }
         RogueLikeMode.Room xAdd3 = this.lxRooms[this.rand.Next(this.lxRooms.Count)];
         pos = xAdd3.v2Pos;
         Point newPos2 = this.AddPoint(pos, this.RanDir());
         if (xSession.enCurrentRegion == Level.WorldRegion.FlyingFortress)
         {
             newPos2 = this.AddPoint(pos, this.RanDir(new int[]
             {
                 0,
                 1,
                 3
             }));
         }
         if (this.ValidNewPosition(newPos2, pos, aiFloor) && aiFloor[newPos2.X, newPos2.Y] == null && xAdd3.enRoomType == RogueLikeMode.Room.RoomTypes.Normal)
         {
             RogueLikeMode.Room xEventRoom = new RogueLikeMode.Room(this.rand, newPos2.X, newPos2.Y);
             xEventRoom.iDistanceFromStartRoom = xAdd3.iDistanceFromStartRoom + 1;
             xEventRoom.enRoomType = RogueLikeMode.Room.RoomTypes.EventRoom;
             RogueLikeMode.Room.EventTypes enUsedEvent = RogueLikeMode.Room.EventTypes.Fishing;
             xEventRoom.enEvent = enUsedEvent;
             if (enUsedEvent == RogueLikeMode.Room.EventTypes.Fishing)
             {
                 RogueLikeFishingMaster.iBaitUsed = 0;
                 xEventRoom.iRoomHeight = 200;
                 xEventRoom.iRoomWidth = 380;
             }
             this.lxRooms.Add(xEventRoom);
             aiFloor[xEventRoom.v2Pos.X, xEventRoom.v2Pos.Y] = xEventRoom;
             break;
         }
     }
     iImpossible = 0;
     while (bAddTreasureRoom)
     {
         iImpossible++;
         if (iImpossible >= 100)
         {
             this.TestGeneration(iWidth, iHeight, xSession);
             return;
         }
         RogueLikeMode.Room xAdd4 = this.lxRooms[this.rand.Next(this.lxRooms.Count)];
         pos = xAdd4.v2Pos;
         Point newPos3 = this.AddPoint(pos, this.RanDir());
         if (this.ValidNewPosition(newPos3, pos, aiFloor) && aiFloor[newPos3.X, newPos3.Y] == null && xAdd4.enRoomType == RogueLikeMode.Room.RoomTypes.Normal)
         {
             RogueLikeMode.Room xTreasureRoom = new RogueLikeMode.Room(this.rand, newPos3.X, newPos3.Y);
             xTreasureRoom.bCompleted = true;
             xTreasureRoom.iDistanceFromStartRoom = xAdd4.iDistanceFromStartRoom + 1;
             xTreasureRoom.enRoomType = RogueLikeMode.Room.RoomTypes.TreasureRoom;
             if (this.enRegion == Level.WorldRegion.FlyingFortress && xTreasureRoom.iRandSeed % 8 == 0)
             {
                 xTreasureRoom.iRandSeed++;
             }
             this.lxRooms.Add(xTreasureRoom);
             aiFloor[xTreasureRoom.v2Pos.X, xTreasureRoom.v2Pos.Y] = xTreasureRoom;
             break;
         }
     }
     iImpossible = 0;
     while (bAddShopRoom)
     {
         iImpossible++;
         if (iImpossible >= 100)
         {
             this.TestGeneration(iWidth, iHeight, xSession);
             return;
         }
         RogueLikeMode.Room xAdd5 = this.lxRooms[this.rand.Next(this.lxRooms.Count)];
         pos = xAdd5.v2Pos;
         Point newPos4 = this.AddPoint(pos, this.RanDir());
         if (this.ValidNewPosition(newPos4, pos, aiFloor) && aiFloor[newPos4.X, newPos4.Y] == null && xAdd5.enRoomType == RogueLikeMode.Room.RoomTypes.Normal)
         {
             RogueLikeMode.Room xChallengeRoom2 = new RogueLikeMode.Room(this.rand, newPos4.X, newPos4.Y);
             xChallengeRoom2.iDistanceFromStartRoom = xAdd5.iDistanceFromStartRoom + 1;
             xChallengeRoom2.enRoomType = RogueLikeMode.Room.RoomTypes.Shop;
             xChallengeRoom2.bCompleted = true;
             if (xSession.enCurrentRegion == Level.WorldRegion.PillarMountains)
             {
                 while (xChallengeRoom2.iRandSeed % 4 != 3)
                 {
                     xChallengeRoom2.iRandSeed++;
                 }
             }
             else if (xSession.enCurrentRegion == Level.WorldRegion.FlyingFortress)
             {
                 xChallengeRoom2.enPropertyFlags &= ~RogueLikeMode.Room.RoomProperties.RoomVarianceA;
                 while (xChallengeRoom2.iRandSeed % 8 != 1)
                 {
                     xChallengeRoom2.iRandSeed++;
                 }
             }
             this.lxRooms.Add(xChallengeRoom2);
             aiFloor[xChallengeRoom2.v2Pos.X, xChallengeRoom2.v2Pos.Y] = xChallengeRoom2;
             break;
         }
     }
     foreach (RogueLikeMode.Room x in this.lxRooms)
     {
         Log.AddLine("Room seed: " + x.iRandSeed);
         if (x.v2Pos.X > 0 && aiFloor[x.v2Pos.X - 1, x.v2Pos.Y] != null)
         {
             x.xWest = aiFloor[x.v2Pos.X - 1, x.v2Pos.Y];
         }
         if (x.v2Pos.X < this.iFloorWidth - 1 && aiFloor[x.v2Pos.X + 1, x.v2Pos.Y] != null)
         {
             x.xEast = aiFloor[x.v2Pos.X + 1, x.v2Pos.Y];
         }
         if (x.v2Pos.Y > 0 && aiFloor[x.v2Pos.X, x.v2Pos.Y - 1] != null)
         {
             x.xNorth = aiFloor[x.v2Pos.X, x.v2Pos.Y - 1];
         }
         if (x.v2Pos.Y < this.iFloorHeight - 1 && aiFloor[x.v2Pos.X, x.v2Pos.Y + 1] != null)
         {
             x.xSouth = aiFloor[x.v2Pos.X, x.v2Pos.Y + 1];
         }
         if (xSession.enCurrentRegion == Level.WorldRegion.PillarMountains)
         {
             int iVariant = x.iRandSeed % 4;
             if (iVariant == 0)
             {
                 x.iRoomWidth = 268;
                 x.iRoomHeight = 135;
             }
             else if (iVariant == 1)
             {
                 x.iRoomWidth = 268;
                 x.iRoomHeight = 135;
             }
             else if (iVariant == 2)
             {
                 x.iRoomWidth = 264;
                 x.iRoomHeight = 106;
             }
             else if (iVariant == 3)
             {
                 x.iRoomWidth = 240;
                 x.iRoomHeight = 80;
             }
         }
     }
     Log.AddLine("Debug seed: " + this.rand.Next());
     int iRandMos = 1;
     if (xSession.iCurrentFloor > 2)
     {
         using (List<RogueLikeMode.Room>.Enumerator enumerator2 = this.lxRooms.GetEnumerator())
         {
             while (enumerator2.MoveNext())
             {
                 RogueLikeMode.Room x2 = enumerator2.Current;
                 if (x2.enRoomType == RogueLikeMode.Room.RoomTypes.Normal)
                 {
                     bool bDoTrap = iRandMos == 1 || this.rand.Next(iRandMos) == 0;
                     if (bDoTrap)
                     {
                         x2.bHasTraps = true;
                         iRandMos++;
                     }
                     else
                     {
                         iRandMos = 1;
                     }
                     if (this.enRegion == Level.WorldRegion.FlyingFortress)
                     {
                         x2.bHasTraps = (this.rand.Next(4) == 0);
                     }
                     if (xSession.enCurrentRegion == Level.WorldRegion.EvergrindEast || xSession.enCurrentRegion == Level.WorldRegion.HalloweenForest)
                     {
                         x2.iRoomWidth = Math.Min(RogueLikeMode.Room.iMaxRoomWidth, x2.iRoomWidth + 20 * (CAS.NumberOfPlayers - 1));
                         x2.iRoomHeight = Math.Min(RogueLikeMode.Room.iMaxRoomHeight, x2.iRoomHeight + 10 * (CAS.NumberOfPlayers - 1));
                     }
                     else if (xSession.enCurrentRegion == Level.WorldRegion.FlyingFortress)
                     {
                         if (!x2.enPropertyFlags.HasFlag(RogueLikeMode.Room.RoomProperties.RoomVarianceA))
                         {
                             if (Program.game.dixPlayers.Count == 1)
                             {
                                 while (x2.iRandSeed % 8 > 4)
                                 {
                                     x2.iRandSeed++;
                                 }
                             }
                             else if (Program.game.dixPlayers.Count == 2)
                             {
                                 while (true)
                                 {
                                     if (x2.iRandSeed % 8 <= 5)
                                     {
                                         if (x2.iRandSeed % 8 < 2)
                                         {
                                             break;
                                         }
                                         if (x2.iRandSeed % 8 > 4)
                                         {
                                             break;
                                         }
                                     }
                                     x2.iRandSeed++;
                                 }
                             }
                             else if (Program.game.dixPlayers.Count == 3)
                             {
                                 while (x2.iRandSeed % 8 >= 2)
                                 {
                                     if (x2.iRandSeed % 8 > 4)
                                     {
                                         break;
                                     }
                                     x2.iRandSeed++;
                                 }
                             }
                             else
                             {
                                 while (x2.iRandSeed % 8 <= 4)
                                 {
                                     x2.iRandSeed++;
                                 }
                             }
                         }
                         else if (Program.game.dixPlayers.Count == 1)
                         {
                             while (x2.iRandSeed % 8 > 2)
                             {
                                 x2.iRandSeed++;
                             }
                         }
                         else if (Program.game.dixPlayers.Count == 2)
                         {
                             while (x2.iRandSeed % 8 >= 1)
                             {
                                 if (x2.iRandSeed % 8 > 2)
                                 {
                                     break;
                                 }
                                 x2.iRandSeed++;
                             }
                         }
                         else
                         {
                             while (x2.iRandSeed % 8 <= 2)
                             {
                                 x2.iRandSeed++;
                             }
                         }
                     }
                 }
             }
             goto IL_171D;
         }
     }
     foreach (RogueLikeMode.Room x3 in this.lxRooms)
     {
         if (x3.enRoomType == RogueLikeMode.Room.RoomTypes.TreasureRoom && x3.iRandSeed % 4 <= 1)
         {
             x3.iRandSeed += this.rand.Next(2) + (2 - x3.iRandSeed % 4);
         }
         if (x3.enRoomType == RogueLikeMode.Room.RoomTypes.Normal)
         {
             if (x3.iRandSeed % 4 == 0 && Program.game.dixPlayers.Count < 3)
             {
                 x3.iRandSeed += this.rand.Next(3) + 1;
             }
             if (Program.game.dixPlayers.Count >= 3 && x3.iRandSeed % 4 == 3)
             {
                 x3.iRandSeed--;
             }
             if (Program.game.dixPlayers.Count >= 4 && x3.iRandSeed % 4 == 2)
             {
                 x3.iRandSeed--;
             }
         }
     }
     IL_171D:
     xSession.lenEncounteredBosses.Add(enUsedBoss);
     xSession.lenEncounteredChallenges.Add(enUsedChallenge);
 }
Example #2
0
 public void NextFloor()
 {
     this.iCurrentFloor++;
     if (this.iCurrentFloor < 3)
     {
         this.enCurrentRegion = Level.WorldRegion.PillarMountains;
     }
     else if (this.iCurrentFloor < 5)
     {
         this.enCurrentRegion = Level.WorldRegion.EvergrindEast;
     }
     else if (this.iCurrentFloor < 7)
     {
         this.enCurrentRegion = Level.WorldRegion.HalloweenForest;
     }
     else if (this.iCurrentFloor < 9)
     {
         this.enCurrentRegion = Level.WorldRegion.FlyingFortress;
     }
     else if (this.iCurrentFloor < 11)
     {
         this.enCurrentRegion = Level.WorldRegion.Winterland;
     }
     RogueLikeMode.randLevelLoadStuff = new Random(this.liFloorSeeds[this.iCurrentFloor]);
     this.xCurrentFloor = new RogueLikeMode.Floor();
     this.xCurrentFloor.rand = RogueLikeMode.randLevelLoadStuff;
     this.xCurrentFloor.TestGeneration(10, 10, this);
     this.xCurrentRoom = this.xCurrentFloor.lxRooms[0];
     this.bJustEnteredNewFloor = true;
     this.iDamageTakenOnFloor = 0;
     this.iFloorsWithoutShop++;
     if (this.iCurrentFloor == 3)
     {
         this.RemoveFromList(this.lenRandomNormalTreasure, 3);
         this.RemoveFromList(this.lenRandomNiceTreasure, 5);
         this.AddTreasureToList(this.lenRandomNormalTreasure, ItemCodex.ItemTypes._OneHanded_IronSword);
         this.AddTreasureToList(this.lenRandomNormalTreasure, ItemCodex.ItemTypes._OneHanded_Rod);
         this.AddTreasureToList(this.lenRandomNormalTreasure, ItemCodex.ItemTypes._Shield_Iron);
         this.AddTreasureToList(this.lenRandomNormalTreasure, ItemCodex.ItemTypes._TwoHanded_Claymore);
         this.AddTreasureToList(this.lenRandomNormalTreasure, ItemCodex.ItemTypes._Armor_ChainMail);
         this.AddTreasureToList(this.lenRandomNormalTreasure, ItemCodex.ItemTypes._Accessory_VoodooDoll);
         this.AddTreasureToList(this.lenRandomNormalTreasure, ItemCodex.ItemTypes._Facegear_Glasses);
         this.AddTreasureToList(this.lenRandomNiceTreasure, ItemCodex.ItemTypes._OneHanded_CarrotSword);
         this.AddTreasureToList(this.lenRandomNiceTreasure, ItemCodex.ItemTypes._OneHanded_Morningstar);
         this.AddTreasureToList(this.lenRandomNiceTreasure, ItemCodex.ItemTypes._OneHanded_RubyRod);
         this.AddTreasureToList(this.lenRandomNiceTreasure, ItemCodex.ItemTypes._TwoHanded_Lantern);
         this.AddTreasureToList(this.lenRandomNiceTreasure, ItemCodex.ItemTypes._TwoHanded_Club);
         this.AddTreasureToList(this.lenRandomNiceTreasure, ItemCodex.ItemTypes._Armor_KnittedShirt);
         this.AddTreasureToList(this.lenRandomNiceTreasure, ItemCodex.ItemTypes._Accessory_SlimeRing);
         this.AddTreasureToList(this.lenRandomNiceTreasure, ItemCodex.ItemTypes._Shield_Barrel);
         this.AddTreasureToList(this.lenRandomNiceTreasure, ItemCodex.ItemTypes._Hat_Eggshell);
         this.AddTreasureToList(this.lenRandomNiceTreasure, ItemCodex.ItemTypes._Hat_Bandana);
         this.AddTreasureToList(this.lenRandomNiceTreasure, ItemCodex.ItemTypes._Hat_Rosett_Blue);
         this.AddTreasureToList(this.lenRandomNiceTreasure, ItemCodex.ItemTypes._Hat_Rosett_Green);
         this.AddTreasureToList(this.lenRandomNiceTreasure, ItemCodex.ItemTypes._Hat_Rosett_Pink);
         this.AddTreasureToList(this.lenRandomNiceTreasure, ItemCodex.ItemTypes._Hat_Rosett_Red);
     }
     if (this.iCurrentFloor == 5)
     {
         this.RemoveFromList(this.lenRandomNormalTreasure, 5);
         this.RemoveFromList(this.lenRandomNiceTreasure, 5);
         this.AddTreasureToList(this.lenRandomNormalTreasure, ItemCodex.ItemTypes._OneHanded_Morningstar);
         this.AddTreasureToList(this.lenRandomNormalTreasure, ItemCodex.ItemTypes._TwoHanded_Club);
         this.AddTreasureToList(this.lenRandomNormalTreasure, ItemCodex.ItemTypes._OneHanded_RubyRod);
         this.AddTreasureToList(this.lenRandomNormalTreasure, ItemCodex.ItemTypes._Shield_Barrel);
         this.AddTreasureToList(this.lenRandomNormalTreasure, ItemCodex.ItemTypes._Armor_KnittedShirt);
         this.AddTreasureToList(this.lenRandomNormalTreasure, ItemCodex.ItemTypes._Hat_Eggshell);
         this.AddTreasureToList(this.lenRandomNiceTreasure, ItemCodex.ItemTypes._Shield_Crystal);
         this.AddTreasureToList(this.lenRandomNiceTreasure, ItemCodex.ItemTypes._Armor_SlimeArmor);
         this.AddTreasureToList(this.lenRandomNiceTreasure, ItemCodex.ItemTypes._Accessory_PlasmaBracelet);
         this.AddTreasureToList(this.lenRandomNiceTreasure, ItemCodex.ItemTypes._Hat_Crown);
     }
 }