/// <summary> /// Clears the blocks. /// </summary> public void ClearBlocks() { //Clear the blocks _blocks = new Block[Game1.MAXX,Game1.MAXY,Game1.MAXZ]; for (int x = 0; x < Game1.MAXX; x++) { for (int y = 0; y < Game1.MAXY; y++) { for (int z = 0; z < Game1.MAXZ; z++) { var b = new Block(); b.SetIndex(Blocks.AIR); _blocks[x,y,z] = b; } } } }
/// <summary> /// Generates the test pattern. /// </summary> public void GenerateTestPattern() { //Clear the array ClearBlocks(); List<Point> points = new List<Point> (); points.Add(new Point(2,2)); points.Add(new Point(2,2).Add(Assets.FacingDirection(Facing.North))); points.Add(new Point(2,2).Add(Assets.FacingDirection(Facing.East))); points.Add(new Point(2,2).Add(Assets.FacingDirection(Facing.West))); points.Add(new Point(2,2).Add(Assets.FacingDirection(Facing.South))); Dictionary<Point, Color> colors = new Dictionary<Point, Color>(){ { points[0], Color.White }, //Center Point { points[1], Color.Red }, //North { points[2], Color.Orange }, //East { points[3], Color.Green }, //West { points[4], Color.Yellow } //South }; //To get a color int i = 0; foreach (Point p in points) { Color c = colors[p]; for(int z = 0; z < 6; z++){ Block b = new Block(); b.SetIndex(Blocks.BLOCK); b.Color = c; b.InfluenceColor = c; b.DrawRect = new Rectangle(_tiles[p.X,p.Y].DrawRect.X, _tiles[p.X,p.Y].DrawRect.Y - (Blocks.BLOCKHEIGHT*(z+1)), 31,31); _blocks[p.X,p.Y,z] = b; } i++; } }
/// <summary> /// Generates the blocks. /// </summary> public void GenerateBlocks() { //Clear the blocks _blocks = new Block[Game1.MAXX,Game1.MAXY,Game1.MAXZ]; for (int x = 0; x < Game1.MAXX; x++) { for (int y = 0; y < Game1.MAXY; y++) { for (int z = 0; z < Game1.MAXZ; z++) { var b = new Block(); b.SetIndex(Blocks.AIR); b.ShowInfluence = InfluenceViewIsOn; b.InfluenceColor = new Color ( 1f * GetInfluencePercent(new Point(x,y)),1f - GetInfluencePercent (new Point(x, y)),1f - GetInfluencePercent (new Point(x, y))); _blocks[x,y,z] = b; } } } //Generate buildings for (int y = 0; y < Game1.MAXY; y++) { for (int x = 0; x < Game1.MAXX; x++) { float influencepercent = GetInfluencePercent(new Point(x,y)); Influence influence = Assets.Influence.Rural; foreach(Influence i in Assets.Influence.Influences) { //Go through the list of influences and compare the land coverage percent to the //distance from the influence point. The lowest one that fits in our number is //one if(influencepercent < i.LandCoverage && i.LandCoverage < influence.LandCoverage) influence = i; } //Now we will try to build our building if(_tiles[x,y].Buildable) if(Assets.Random.Next(0,100) < influence.BuildRate) GenerateBuilding(x,y, influence); } } }