public void GenerateRegion(int ID, WorldLocation Location, World.WorldScene NewWorld, Random rnd) { World.Obj.ObjRegion NewRegion = new World.Obj.ObjRegion(); NewRegion.Name = "Region_" + ID; NewRegion.Origine = Location; NewRegion.BiomeID = rnd.Next(GameObjectsManager.Biomes.Count); NewRegion.Color = new Color(rnd.Next(256), rnd.Next(256), rnd.Next(256)); NewWorld.Region.Add(ID, NewRegion); }
public static void FillRectangle(this World.WorldScene W, Rectangle Rect) { }
public ChunkDecorator(World.WorldScene _World, Random _Rnd) { W = _World; Rnd = _Rnd; }
public World.WorldScene Generate() { Stopwatch stw = new Stopwatch(); stw.Start(); World.WorldScene NewWorld = new World.WorldScene(WrldProps, Rnd); int MaxWorldSize = WrldProps.Size * 16; //debug; Bitmap Map = new System.Drawing.Bitmap(MaxWorldSize, MaxWorldSize); int[,] rGrid = new int[MaxWorldSize, MaxWorldSize]; //Adding randome Region Debug.Logs.Write("[WorldGenerator] Creating Random Point", Debug.LogType.Info); for (int rID = 1; rID <= WrldProps.regionCount; rID++) { int x = FastRnd.Next(MaxWorldSize); int y = FastRnd.Next(MaxWorldSize); regionGenerator.GenerateRegion(rID, Location.ToWorldLocation(new Microsoft.Xna.Framework.Point(x, y)), NewWorld, Rnd); PutPixel(rGrid, Map, x, y, rID); Map.SetPixel(x, y, Color.Red); } //expanding Region Debug.Logs.Write("[WorldGenerator] Expending Region", Debug.LogType.Info); bool DoLoop = true; int LoopCount = 0; do { for (int x = 0; x <= MaxWorldSize - 1; x++) { for (int y = 0; y <= MaxWorldSize - 1; y++) { if (!(rGrid[x, y] == 0)) { int RegionID = rGrid[x, y]; int Direction = FastRnd.Next(0, 5); switch (Direction) { case 0: //do nothing break; case 1: PutPixel(rGrid, Map, x - 1, y, RegionID); break; case 2: PutPixel(rGrid, Map, x + 1, y, RegionID); break; case 3: PutPixel(rGrid, Map, x, y - 1, RegionID); break; case 4: PutPixel(rGrid, Map, x, y + 1, RegionID); break; default: break; } } } } //exit Loop if (LoopCount == WrldProps.RegionExpention) { DoLoop = false; } LoopCount++; } while (DoLoop); Debug.Logs.Write("[WorldGenerator] Creating Chunk", Debug.LogType.Info); NewWorld.Chunks = new ObjChunk[WrldProps.Size, WrldProps.Size]; for (int cX = 0; cX <= WrldProps.Size - 1; cX++) { for (int cY = 0; cY <= WrldProps.Size - 1; cY++) { NewWorld.Chunks[cX, cY] = new ObjChunk(); for (int tX = 0; tX <= 15; tX++) { for (int tY = 0; tY <= 15; tY++) { NewWorld.Chunks[cX, cY].Tiles[tX, tY] = new World.Obj.ObjTile(); NewWorld.Chunks[cX, cY].Tiles[tX, tY].Region = rGrid[cX * 16 + tX, cY * 16 + tY]; } } } } NewWorld.miniMap.MiniMapBitmap = Map; Features.Road r = new Features.Road(); r.Apply(rGrid, Map, NewWorld); Map.Save("World.png"); NewWorld.miniMap.RefreshMiniMap(); foreach (KeyValuePair <string, Plugin.IPlugin> i in GameObjectsManager.Plugins) { i.Value.OnWorldGeneration(NewWorld); } stw.Stop(); Debug.Logs.Write("Generator elapsed time : " + stw.ElapsedMilliseconds); return(NewWorld); }
public MiniMap(int x, int y, World.WorldScene _World) { W = _World; Focus = new Rectangle(0, 0, 128, 128); this.SizeBox = new Rectangle(new Point(x, y), new Point(192, 192)); }
public virtual void Apply(int[,] _Grid, Bitmap _Bitmap, World.WorldScene _World) { }