예제 #1
0
 private static void AddEntitiesAndTilesToMap(Map map, List <Tile> specialTilePile, int randomSeed, List <ICharacter> entityPile, bool placeBoss)
 {
     foreach (Tile tile in specialTilePile)
     {
         if (tile.GetType() != typeof(ExitTile) && tile.Position == null)
         {
             tile.Position = FindTileOrEntitySpawn.StartingPostion(map, tile);
         }
         map.SetTilePosition(tile.Position, tile.InstanValue);
     }
     for (int i = 0; i < randomSeed; i++)
     {
         NormalMonster monster = new NormalMonster();
         monster.Position = FindTileOrEntitySpawn.StartingPostion(map, monster);
         entityPile.Add(monster);
     }
     if (map.GetType() == typeof(CaveMap) && placeBoss)
     {
         BossToken boss = new BossToken();
         boss.Position = FindTileOrEntitySpawn.StartingPostion(map, boss);
         entityPile.Add(boss);
     }
     foreach (ICharacter entity in entityPile)
     {
         map.SetEntityPosition(entity);
     }
 }
예제 #2
0
 private static void AddEntitiesAndTilesToMap(Map map, List <Tile> specialTilePile, List <ICharacter> entityPile)
 {
     foreach (ICharacter entity in entityPile)
     {
         map.SetTilePosition(entity.Position, entity.Value);
     }
     foreach (Tile tile in specialTilePile)
     {
         if (tile.GetType() != typeof(ExitTile) && tile.Position == null)
         {
             tile.Position = FindTileOrEntitySpawn.StartingPostion(map, tile);
         }
         map.MapArrayOfArrays[tile.Position[0]][tile.Position[1]] = tile.InstanValue;
     }
 }
예제 #3
0
        /// <summary>
        /// Runs the logic around the game loop
        /// </summary>
        /// <param name="difficulty">Difficulty of the game</param>
        /// <param name="newPlayer">The current player</param>
        /// <returns>Whether or not the game will continue</returns>
        public void RunMapGame()
        {
            EncounterProg encounter = new EncounterProg();

            encounter.RunCharacterCreation();

            Random randomNumberSeed = new Random();

            bool newMap = true;

            int height = 8, width = 20;

            while (newMap)
            {
                PlayerToken player = new PlayerToken(encounter);

                Console.WriteLine("Loading New Map...");
                Console.WriteLine("This may take up to 60 seconds...");

                Map     map     = new Map(width, height);
                TownMap townMap = new TownMap(width, height);
                Dictionary <int, CaveMap> caveMapStorage = new Dictionary <int, CaveMap>();
                List <Tile> specialTilePile = new List <Tile>();

                int randomSeed = randomNumberSeed.Next(_currentLevel - 1, _currentLevel + 2);
                if (_currentLevel == 1)
                {
                    randomSeed = randomNumberSeed.Next(0, 3);
                }
                else if (_currentLevel == 2)
                {
                    randomSeed = randomNumberSeed.Next(1, 3);
                }
                for (int i = 0; i < randomSeed; i++)
                {
                    double   randomWidthSeed  = randomNumberSeed.Next(2, 4);
                    double   randomHeightSeed = randomNumberSeed.Next(1, 1);
                    CaveMap  caveMap          = new CaveMap((int)(width / (randomWidthSeed)), (int)(height / (randomHeightSeed)));
                    CaveTile caveTile         = new CaveTile();
                    caveTile.AssociationNum = i + 1;
                    specialTilePile.Add(caveTile);
                    caveMapStorage.Add(i + 1, caveMap);
                }
                TownMapTile currentTownMapTile = new TownMapTile();
                ExitTile    endTile            = new ExitTile();
                endTile.Position            = new int[2];
                currentTownMapTile.Position = FindTileOrEntitySpawn.StartingPostion(map, currentTownMapTile);
                specialTilePile.Add(currentTownMapTile);
                specialTilePile.Add(endTile);


                List <ICharacter> entityPile = new List <ICharacter>();
                randomSeed = randomNumberSeed.Next(_currentLevel, _currentLevel * 5);

                bool isTownMap = true;
                bool isCaveMap = true;
                while ((isTownMap || isCaveMap) && newMap)
                {
                    newMap = RunWorldMap(encounter, player, map, specialTilePile, randomSeed, endTile, entityPile);

                    isTownMap = false;
                    isCaveMap = false;
                    foreach (Tile tile in specialTilePile)
                    {
                        if (tile.GetType() == typeof(CaveTile) && IsColliding.IsCurrentlyColliding(tile, player))
                        {
                            newMap    = RunCaveMap(encounter, player, caveMapStorage, endTile, tile);
                            isCaveMap = true;
                        }
                        else if (tile.GetType() == typeof(TownMapTile) && IsColliding.IsCurrentlyColliding(currentTownMapTile, player))
                        {
                            encounter.TownReplenish();
                            newMap    = RunTownMap(encounter, player, townMap, currentTownMapTile, endTile);
                            isTownMap = true;
                        }
                    }
                }

                width  += 10;
                height += 2;
                if (width == 100)
                {
                    newMap = false;
                }

                _currentLevel++;
            }

            Console.WriteLine("Game Over");
        }