示例#1
0
 public void addRegionHeader(RegionHeader regionHeader)
 {
     if(regions.ContainsKey(regionHeader.getId()))
     {
         throw new Exception("region ID already defined");
     }
     else
     {
         regions.Add(regionHeader.getId(), regionHeader);
     }
 }
示例#2
0
 public void LoadObject(StreamReader inStream)
 {
     currentRegionID = inStream.ReadLine();
     regions.Clear();
     int regionsSize = Int32.Parse(inStream.ReadLine());
     for(int i=0; i < regionsSize; i++)
     {
         RegionHeader tempRegionHeader = new RegionHeader("");
         tempRegionHeader.LoadObject(inStream);
         regions.Add(tempRegionHeader.getId(), tempRegionHeader);
     }
     setOverworldWidth(Int32.Parse(inStream.ReadLine()));
     setOverworldHeight(Int32.Parse(inStream.ReadLine()));
     for(int x=0; x < getOverworldWidth(); x++)
     {
         for(int y=0; y < getOverworldHeight(); y++)
         {
             getOverworldCells()[x,y].LoadObject(inStream);
         }
     }
 }
        public void addCaveBranch(RegionHeader topLevel, int topX, int topY, int depth, Quinoa quinoa)
        {
            CaveGenerator lastGen = null;

            for(int deep=0; deep < depth; deep++)
            {
                int width = 80 + (int)(RandomNumber.RandomDouble() * 40);
                int height = 80 + (int)(RandomNumber.RandomDouble() * 40);
                int chamberCount = 3 + (int)(RandomNumber.RandomDouble() * 4);
                int smoothness = (int)(RandomNumber.RandomDouble() * 2);
                double fillPercentage = 0.45 + (RandomNumber.RandomDouble() * 0.20);

                CaveGenerator caveGen = new CaveGenerator(width, height, topLevel.getId() + "-cave" + deep, fillPercentage, smoothness, quinoa);
                caveGen.addChamber(new Chamber(5,5,caveGen.region.getWidth() - 10,caveGen.region.getHeight() - 10, ChamberType.OPEN));
                for(int i=0; i < chamberCount; i++)
                {
                    int caveX = 5 + (int)(RandomNumber.RandomDouble() * (caveGen.region.getWidth() - 41));
                    int caveY = 5 + (int)(RandomNumber.RandomDouble() * (caveGen.region.getHeight() - 41));

                    ChamberType type = ChamberType.NULL;
                    if(RandomNumber.RandomDouble() < 0.20)
                    {
                        type = ChamberType.MUSHROOM;
                    }
                    else
                    {
                        type = ChamberType.FLOODED;
                    }
                    caveGen.addChamber(new Chamber(caveX,caveY,(int)(RandomNumber.RandomDouble() * 20) + 10,(int)(RandomNumber.RandomDouble() * 20) + 10, type));
                }
                caveGen.smoothWater();
                caveGen.placeExits();
                caveGen.addTorches();
                caveGen.addMinerals(deep+1);

                if(deep == depth - 1)
                {
                    caveGen.addTreasure();
                    this.caveBottomIDs.Add(caveGen.header.getId());
                }

                caveGen.header.setName("Cave (level " + (deep + 1) + ")");
                caveGen.header.setRegion(caveGen.region);
                caveGen.header.storeRegion(true);

                if(deep == 0)
                {
                    caveGen.getEntrance().setDx(topX);
                    caveGen.getEntrance().setDy(topY+1);
                    caveGen.getEntrance().setDestinationRegionID(topLevel.getId());

                    topLevel.getExits().Add(new RegionExit(topX,topY,caveGen.getEntrance().getX(),caveGen.getEntrance().getY()+1,caveGen.header.getId(), ExitDecorator.CAVE));
                }
                else
                {
                    caveGen.getEntrance().setDx(lastGen.exit.getX());
                    caveGen.getEntrance().setDy(lastGen.exit.getY()+1);
                    caveGen.getEntrance().setDestinationRegionID(lastGen.header.getId());

                    lastGen.exit.setDx(caveGen.entrance.getX());
                    lastGen.exit.setDy(caveGen.entrance.getY()+1);
                    lastGen.exit.setDestinationRegionID(caveGen.header.getId());

                    if(deep == depth-1)
                    {
                        caveGen.header.setName("Cave (bottom level)");
                        caveGen.header.getExits().Remove(caveGen.exit);
                    }
                }

                quinoa.getMap().addRegionHeader(caveGen.header);

                lastGen = caveGen;
            }
        }