コード例 #1
0
ファイル: Core.cs プロジェクト: Craydel/DM_UBER_TOOL
        /// <summary>
        /// Creates a new instance of everything.  New hero, clears mobs and items
        /// </summary>
        public static void InitMaze()
        {
            GetResourcesPath();
              ReloadImages();

              if(items == null)
            items = new ArrayList();

              if(mobs == null)
            mobs = new ArrayList();

              hero = new Hero();
              items.Clear();
              mobs.Clear();

              GenerateMaze();
        }
コード例 #2
0
ファイル: Core.cs プロジェクト: Craydel/DM_UBER_TOOL
        /// <summary>
        /// Generates a single level of the dungeon.
        /// Creates the maze, sets walls, places stair tiles, items, mobs and the hero.
        /// Does noterase the inventory of the hero, but will clear the items and mobs lists prior to placement.
        /// </summary>
        public static void GenerateMaze()
        {
            if( hero == null )
            hero = new Hero();

              // new level means old lists are gone forever
              items.Clear();
              mobs.Clear();

              if(grid == null)
              {
            // no existing dungeon - set initial values
            dungeonLevel = 1;
            width = minWidth;
            height = minHeight;
            pathWidth = maxPathWidth;
              }
              else
              {
            // dungeon exists - figure new values based on which way the Hero went (up or down)
            if(grid[hero.x, hero.y].type == FloorType.StairsDown)
              dungeonLevel++;
            else if(grid[hero.x, hero.y].type == FloorType.StairsUp)
              if(--dungeonLevel < 1) // can't go to level zero or -1 or something silly
            dungeonLevel = 1;

            pathWidth = Math.Max(maxPathWidth-dungeonLevel, minPathWidth);
            width     = Math.Max(minWidth, Math.Min(dungeonLevel, maxWidth));
            height    = Math.Max(minHeight, Math.Min(dungeonLevel, maxHeight));
              }

              // request a maze from MazeGenerator with the new parameters
              //grid = MazeGenerator.GenerateMaze( width,
              //                                   height,
              //                                   pathWidth,
              //                                   1.25f - Random(50)/100.0f  // yields 75% to 125%, so a 50% chance to have less than 100% of the maze full.
              //                                 );

              //
              // DEBUG Stuff
              //
              //Generator.MazeType debugMazeType = Generator.MazeType.Castle;
              float debugPercentFull = 1.25f - Random(50) / 100.0f;
              //grid = MazeGenerator.GenerateMaze(width,
              //                                   height,
              //                                   pathWidth,
              //                                   debugMazeType,
              //                                   debugPercentFull
              //                                 );
              grid = MazeGenerator.GenerateMaze(width,
                                         height,
                                         pathWidth,
                                         type,
                                         debugPercentFull
                                       );

              //
              // End DEBUG stuff
              //

              // define new visibility mask for minimap
              visibility = new bool[grid.GetLength(0), grid.GetLength(1)];

              // define now minimap
              if(miniMap != null)
            miniMap.Dispose();

              miniMap = new Bitmap(mmScale*grid.GetLength(0), mmScale*grid.GetLength(1));
              Graphics mmg = Graphics.FromImage(miniMap);
              mmg.Clear(Color.Black);
              mmg.Dispose();

              // set each floorTile to the right type (wall/floor) based on mazeMask values (true = wall up, false = wall down = floor)
              //for(int i=0; i<grid.GetLength(0); i++)
              //  for(int j=0; j<grid.GetLength(1); j++)
              //    grid[i, j] = new FloorTile(i, j, mazeMask[i, j] ? FloorType.Wall : FloorType.Floor );

              //
              // DEBUG - testing purposes, only place the hero for now.
              //

              // put all the stuff that makes it a level.
              hero.x = grid.GetLength(0)/2;
              hero.y = grid.GetLength(1)/2;

              if(!true)
              {
            PlaceHero();                  // hero 1st - we check their position when placing mobs.  If they're not there, this check will cause a crash.
            PlaceStairs(width / 2, 1);    // warp to another level
            PlaceMobs(width * 2);       // throw some bad guys in for the Hero to beat up
            PlaceItems(width);          // OMGWTFPWN3DBBQLootz!!1!
              }
        }