public void ToolMouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left && this.control_point != null) { HashSet <DrawingObject> drawingObjects = new HashSet <DrawingObject>(); drawingObjects.Add(this.new_line1); drawingObjects.Add(this.new_line2); if (this.isComposite) { MouseUpComposite(drawingObjects); } else { MouseUpLine(drawingObjects); } this.canvas.cleaning(drawingObjects); this.canvas.RemoveDrawingObject(this.control_point); this.control_point = null; this.new_line1 = null; this.new_line2 = null; this.comp = null; this.isComposite = false; } }
static void Main(string[] args) { // Create a rectangle centered at (5,5) with length and width of 1 and 4 Shapes.Rectangle r = new Shapes.Rectangle(1, 4, 5, 5); // Create a square centered at (4,4) with length of 2 in both dimension Shapes.Square s = new Shapes.Square(2, 4, 4); // Create a circle centered at (0,0) with a radius of 4 Shapes.Circle c = new Shapes.Circle(4, 0, 0); Console.WriteLine("The height of the rectangle is " + r.xLength + " and the width is " + r.yLength + " at (" + r.centerX + ", " + r.centerY + ")"); r.scale(6, 2); Console.WriteLine("The height of the rectangle is " + r.xLength + " and the width is " + r.yLength + " at (" + r.centerX + ", " + r.centerY + ")"); r.move(2, 2); Console.WriteLine("The height of the rectangle is " + r.xLength + " and the width is " + r.yLength + " at (" + r.centerX + ", " + r.centerY + ")\n"); Console.WriteLine("The height of the square is " + s.xLength + " and the width is " + s.yLength + " at (" + s.centerX + ", " + s.centerY + ")"); s.scale(6, 2); Console.WriteLine("The height of the square is " + s.xLength + " and the width is " + s.yLength + " at (" + s.centerX + ", " + s.centerY + ")"); s.move(2, 2); Console.WriteLine("The height of the square is " + s.xLength + " and the width is " + s.yLength + " at (" + s.centerX + ", " + s.centerY + ")\n"); Console.WriteLine("The radius of the circle is " + c.radius + " at (" + c.centerX + ", " + c.centerY + ")"); c.scale(6); Console.WriteLine("The radius of the circle is " + c.radius + " at (" + c.centerX + ", " + c.centerY + ")"); c.move(2, 2); Console.WriteLine("The radius of the circle is " + c.radius + " at (" + c.centerX + ", " + c.centerY + ")"); // Wait for user input to close the console Console.WriteLine("Press ENTER to close the window"); Console.ReadLine(); }
protected override void Init() { Title = "Issue 11033"; var layout = new StackLayout(); var instructions = new Label { Padding = 12, BackgroundColor = Color.Black, TextColor = Color.White, Text = "If the Ellipse renders without problems, the test has passed." }; var rectangle = new Shapes.Rectangle { RadiusX = 200, RadiusY = 200, StrokeLineCap = PenLineCap.Round, StrokeThickness = 2, StrokeLineJoin = PenLineJoin.Round, Stroke = Brush.Red, Rotation = 25, HeightRequest = 100, WidthRequest = 100 }; layout.Children.Add(instructions); layout.Children.Add(rectangle); Content = layout; }
public override void Execute() { using (var folderDialog = new FolderBrowserDialog()) { if (folderDialog.ShowDialog() == DialogResult.OK) { path = folderDialog.SelectedPath; path += "\\"; Debug.WriteLine("direktory: " + path); } } List <DrawingObject> listDrawingObject = canvas.GetListDrawingObject(); foreach (DrawingObject obj in listDrawingObject) { if (obj is Vertex) { Debug.WriteLine("OBJEK VERTEX: " + obj.ID.ToString()); Shapes.Rectangle tempObj = new Shapes.Rectangle(); tempObj = (Shapes.Rectangle)obj; tempObj.GenerateFile(this.path); } } //SuccessDialog(); }
private void addRectangle() { Pen pen = new Pen(this.Pen.Brush, this.Pen.Width); pen.DashStyle = this.Pen.DashStyle; Shapes.Rectangle rectangle = new Shapes.Rectangle(pen, pointA, pointB); this.Shapes.Add(rectangle); }
public void MouseUpLine(HashSet <DrawingObject> drawingObjects) { DrawingObject composite = new Composite(drawingObjects); this.canvas.AddDrawingObject(composite); this.canvas.cleaning(drawingObjects); this.canvas.RemoveDrawingObject(this.control_point); this.control_point = null; }
public Control () { this.HitTestEnabled = true; this.HorizontalAlignment = HorizontalAlignment.Stretch; this.VerticalAlignment = VerticalAlignment.Stretch; this.Forecolor = Microsoft.Xna.Framework.Color.White; rcBackground = new Shapes.Rectangle(); rcBackground.Parent = this; }
public Control() { this.HitTestEnabled = true; this.HorizontalAlignment = HorizontalAlignment.Stretch; this.VerticalAlignment = VerticalAlignment.Stretch; this.Forecolor = Microsoft.Xna.Framework.Color.White; rcBackground = new Shapes.Rectangle(); rcBackground.Parent = this; }
public void Render(Graphics g, Shape shape) { Shapes.Rectangle rectangle = (Shapes.Rectangle)shape; g.FillRectangle( new SolidBrush(rectangle.Color), rectangle.Points[0].X, rectangle.Points[0].Y, rectangle.Width, rectangle.Height); }
public DrawRectangleCommand(Canvas InputCanvas, Color ILineColor, Color IFillColor, int XPoint, int YPoint, int Width, int Height) { this.ActiveCanvas = InputCanvas; this.LineColor = ILineColor; this.FillColor = IFillColor; this.Width = Width; this.Height = Height; this.X = XPoint; this.Y = YPoint; RectangleShape = new Shapes.Rectangle(X, Y, Width, Height); RectangleShape.SetOutlineColor(LineColor); RectangleShape.SetFillColor(FillColor); }
public void DrawRectangle(Shapes.Rectangle rect) { g.TranslateTransform((float)(rect.Center.X), (float)(rect.Center.Y)); g.RotateTransform((float)rect.Rotate); g.TranslateTransform((float)(-rect.Center.X), (float)(-rect.Center.Y)); g.DrawRectangle(new System.Drawing.Pen(rect.Color.ToDrawingColor(), (float)rect.Thickness), new System.Drawing.Rectangle(new Point(Convert.ToInt32(rect.Center.X - rect.Size.Width / 2), Convert.ToInt32(rect.Center.Y - rect.Size.Height / 2)), new Size(Convert.ToInt32(rect.Size.Width), Convert.ToInt32(rect.Size.Height)) ) ); g.ResetTransform(); }
public void DrawRectangle(Shapes.Rectangle rect) { var rectangle = new System.Windows.Shapes.Rectangle(); rectangle.Width = rect.Size.Width; rectangle.Height = rect.Size.Height; rectangle.Stroke = rect.Color.ToBrush(); rectangle.StrokeThickness = rect.Thickness; rectangle.IsEnabled = false; Canvas.SetLeft(rectangle, rect.Center.X - rect.Size.Width / 2); Canvas.SetTop(rectangle, rect.Center.Y - rect.Size.Height / 2); RotateTransform rotateTransform1 = new RotateTransform(rect.Rotate); rotateTransform1.CenterX = rect.Size.Width / 2; rotateTransform1.CenterY = rect.Size.Height / 2; rectangle.RenderTransform = rotateTransform1; canvas.Children.Add(rectangle); }
public void addControlPoint(DrawingObject selected_object) { Line li = (Line)selected_object; if (li == null) { return; } this.new_line1 = new Line(li.startPoint, clickPoint); this.new_line2 = new Line(clickPoint, li.endPoint); this.control_point = new Shapes.Rectangle(clickPoint, new Point(clickPoint.X + 1, clickPoint.Y + 1)); this.control_point.addObserver(1, this.new_line1); this.control_point.addObserver(0, this.new_line2); this.canvas.RemoveDrawingObject(selected_object); this.canvas.AddDrawingObject(this.new_line1); this.canvas.AddDrawingObject(this.new_line2); this.canvas.AddDrawingObject(this.control_point); }
public Issue13164SecondPage() { var layout = new StackLayout(); var instructions = new Label { Padding = 12, BackgroundColor = Color.Black, TextColor = Color.White, Text = "Navigate back, and navigate again to this page several times. If shapes are always rendered, the test has passed." }; var ellipse = new Ellipse { HorizontalOptions = LayoutOptions.Start, Stroke = Brush.DarkBlue, Fill = Brush.BlueViolet, HeightRequest = 50, WidthRequest = 100 }; var rectangle = new Shapes.Rectangle { HorizontalOptions = LayoutOptions.Start, StrokeThickness = 3, Stroke = Brush.DarkOliveGreen, Fill = Brush.Orange, HeightRequest = 80, WidthRequest = 120 }; layout.Children.Add(instructions); layout.Children.Add(ellipse); layout.Children.Add(rectangle); Content = layout; }
public override bool Place(Point origin, StructureMap structures) { Dictionary <ushort, int> nums = new Dictionary <ushort, int>(); Point point = new Point(origin.X - 25, origin.Y - 25); Shapes.Rectangle rectangle = new Shapes.Rectangle(50, 50); ushort[] numArray = new ushort[] { 0, 59, 147, 1 }; WorldUtils.Gen(point, rectangle, (new Actions.TileScanner(numArray)).Output(nums)); int item = nums[0] + nums[1]; int num = nums[59]; int item1 = nums[147]; if (item1 <= num || item1 <= item) { return(false); } int num1 = 0; for (int i = GenBase._random.Next(10, 15); i > 5; i--) { int num2 = GenBase._random.Next(-5, 5); Point point1 = new Point(origin.X + num2, origin.Y + num1); Shapes.Circle circle = new Shapes.Circle(i); GenAction[] blotch = new GenAction[] { new Modifiers.Blotches(4, 0.3), null, null }; ushort[] numArray1 = new ushort[] { 147, 161, 224, 0, 1 }; blotch[1] = new Modifiers.OnlyTiles(numArray1); blotch[2] = new Actions.SetTile(162, true, true); WorldUtils.Gen(point1, circle, Actions.Chain(blotch)); Point point2 = new Point(origin.X + num2, origin.Y + num1); Shapes.Circle circle1 = new Shapes.Circle(i); GenAction[] genActionArray = new GenAction[] { new Modifiers.Blotches(4, 0.3), new Modifiers.HasLiquid(-1, -1), new Actions.SetTile(162, true, true), new Actions.SetLiquid(0, 0) }; WorldUtils.Gen(point2, circle1, Actions.Chain(genActionArray)); num1 = num1 + (i - 2); } return(true); }
public void MarchingSquaresTest() { Game game = new Game(1024, 768, false, "Marching Cubes", 60); Scene scene = new Scene() { BackgroundColor = Color.LightGray }; Polygon pol = new Polygon() { Position = new PointF(1024 / 2, 768 / 2) }; pol.Points.Add(new PointF(-120, -100)); pol.Points.Add(new PointF(100, -100)); pol.Points.Add(new PointF(100, 80)); pol.Points.Add(new PointF(50, 20)); pol.Points.Add(new PointF(-100, 100)); //scene.Add(pol); Ellipse eC = new Ellipse() { Position = new PointF(pol.Center.X, pol.Center.Y), Width = 8, Height = 8, FillColor = Color.Pink }; //scene.Add(eC); foreach (PointF p in pol.Points) { Ellipse e = new Ellipse() { Position = new PointF(p.X, p.Y), Width = 8, Height = 8, FillColor = Color.Pink }; //scene.Add(e); } Random rng = new Random(); int cellsX = 30; int cellsY = 30; Cell[,] cells = new Cell[cellsX, cellsY]; UberCell[,] ubercells = new UberCell[cellsX / 2, cellsY / 2]; for (int u = 0; u < cellsX; u++) { for (int v = 0; v < cellsY; v++) { Cell c = new Cell() { PosX = 320 + u * 10, PosY = 250 + v * 10 }; // if (u > 5 && u < 25 && v > 5 && v < 25) c.Value = 0; //else // c.Value = 0; cells[u, v] = c; } } int rU = 0; int rV = 0; for (int u = 0; u < cellsX - 1; u += 2) { rV = 0; for (int v = 0; v < cellsY - 1; v += 2) { ubercells[rU, rV] = new UberCell() { TopLeft = cells[u, v], TopRight = cells[u + 1, v], BottomLeft = cells[u, v + 1], BottomRight = cells[u + 1, v + 1], PosX = cells[u, v].PosX, PosY = cells[u, v].PosY }; rV++; } rU++; } List <Shapes.Rectangle> cellRects = new List <Shapes.Rectangle>(); foreach (Cell cell in cells) { Shapes.Rectangle r = new Shapes.Rectangle() { Position = new PointF(cell.PosY, cell.PosX), Width = 9, Height = 9, FillColor = Color.FromArgb(cell.Value, 20, 20), Tag = cell }; cellRects.Add(r); scene.Shapes.Add(r); } List <Shapes.Rectangle> ubercellRects = new List <Shapes.Rectangle>(); foreach (UberCell uCell in ubercells) { Shapes.Rectangle rect = new Shapes.Rectangle() { Position = new PointF(uCell.PosX, uCell.PosY), Width = 19, Height = 19, Visible = false }; ubercellRects.Add(rect); scene.Shapes.Add(rect); } List <PointF> isoPoints = new List <PointF>(); foreach (UberCell uCell in ubercells) { bool tl = uCell.TopLeft.Value > 100; bool tr = uCell.TopRight.Value > 100; bool bl = uCell.BottomLeft.Value > 100; bool br = uCell.BottomRight.Value > 100; if (!tl && !tr && !bl && !br) { // ... } else if (tl && tr && bl && br) { // ... } else if ((!tl && !tr && bl && !br) || (tl && tr && !bl && br)) { isoPoints.Add(new PointF(uCell.PosX, uCell.HalfY)); isoPoints.Add(new PointF(uCell.HalfX, uCell.FullY)); } else if ((tl && !tr && !bl && !br) || (!tl && tr && bl && br)) { isoPoints.Add(new PointF(uCell.HalfX, uCell.PosY)); isoPoints.Add(new PointF(uCell.PosX, uCell.HalfY)); } else if ((!tl && tr && !bl && !br) || (tl && !tr && bl && br)) { isoPoints.Add(new PointF(uCell.HalfX, uCell.PosY)); isoPoints.Add(new PointF(uCell.FullX, uCell.HalfY)); } else if ((!tl && !tr && !bl && br) || (tl && tr && bl && !br)) { isoPoints.Add(new PointF(uCell.FullX, uCell.HalfY)); isoPoints.Add(new PointF(uCell.HalfX, uCell.FullY)); } else if ((tl && tr && !bl && !br) || (!tl && !tr && bl && br)) { isoPoints.Add(new PointF(uCell.PosX, uCell.HalfY)); isoPoints.Add(new PointF(uCell.FullX, uCell.HalfY)); } else if ((tl && !tr && bl && !br) || (!tl && tr && !bl && br)) { isoPoints.Add(new PointF(uCell.HalfX, uCell.PosY)); isoPoints.Add(new PointF(uCell.HalfX, uCell.FullY)); } else { // ... } } List <Ellipse> isoCircles = new List <Ellipse>(); foreach (PointF p in isoPoints) { Ellipse e = new Ellipse() { Position = p, Width = 4, Height = 4, FillColor = Color.Pink }; isoCircles.Add(e); scene.Shapes.Add(e); } Ellipse crosshair = new Ellipse() { Width = 30, Height = 30, FillColor = Color.Cyan }; scene.Add(crosshair); bool keyRight = false; bool keyLeft = false; bool keyDown = false; bool keyUp = false; bool keyE = false; bool keyQ = false; game.KeyDown += args => { switch (args.Key) { case Key.Right: keyRight = true; break; case Key.Left: keyLeft = true; break; case Key.Up: keyUp = true; break; case Key.Down: keyDown = true; break; case Key.E: keyE = true; break; case Key.Q: keyQ = true; break; case Key.H: ubercellRects.ForEach(r => r.Visible = !r.Visible); break; } }; game.KeyUp += args => { switch (args.Key) { case Key.Right: keyRight = false; break; case Key.Left: keyLeft = false; break; case Key.Up: keyUp = false; break; case Key.Down: keyDown = false; break; case Key.E: keyE = false; break; case Key.Q: keyQ = false; break; } }; game.MouseMove += args => { crosshair.Position = new PointF(args.X, 768 - args.Y); }; Polygon isoshape = new Polygon(); scene.Add(isoshape); game.MouseDown += args => { foreach (Shapes.Rectangle r in cellRects) { if (crosshair.Contains(r.Center)) { if (args.Button == MouseButton.Left) { (r.Tag as Cell).Value -= 255; } else { (r.Tag as Cell).Value += 255; } } } redrawCells(cellRects, ref scene); isoCircles.ForEach(c => scene.Shapes.Remove(c)); //isoCircles = marchingSquares(ubercells).Select(n => new Ellipse() //{ // Position = new PointF(n.X, n.Y), // Width = 8, // Height = 8, // FillColor = Color.Yellow //}).ToList(); isoshape.Points = new List <PointF>(); marchingSquares(ubercells).ForEach(p => isoshape.Points.Add(p)); //scene.Shapes.AddRange(isoCircles); }; float movementSpeed = 2f; scene.Update += e => { float delta = (float)e.Time; if (keyRight) { pol.Position = pol.Position.Translate(movementSpeed, 0); } if (keyLeft) { pol.Position = pol.Position.Translate(-movementSpeed, 0); } if (keyUp) { pol.Position = pol.Position.Translate(0, movementSpeed); } if (keyDown) { pol.Position = pol.Position.Translate(0, -movementSpeed); } if (keyE) { pol.Rotation += .1f * delta; } if (keyQ) { pol.Rotation -= .1f * delta; } }; game.ActiveScene = scene; game.Start(); }
public void RotationTest() { Game game = new Game(1024, 768, false, "Test Game", 60); Line line = new Line() { Position = new PointF(30, 300), End = new PointF(420, 500), FillColor = Color.Aqua, Rotation = 0 }; Shapes.Rectangle rectangle = new Shapes.Rectangle() { Position = new PointF(200, 300), Width = 120, Height = 240, FillColor = Color.OrangeRed, Rotation = 1 }; Scene scene = new Scene(); scene.Add(line); scene.Add(rectangle); float deltaTime = 1; scene.Update += e => { deltaTime = (float)e.Time; }; bool mouseDownLeft = false, mouseDownRight = false; float pmX = -1, pmY = -1; game.MouseDown += e => { if (e.Button.Equals(MouseButton.Left)) { mouseDownLeft = true; } }; game.MouseUp += e => { if (e.Button.Equals(MouseButton.Left)) { mouseDownLeft = false; } }; game.MouseMove += e => { float x = e.X; float y = e.Y; float dX = x - pmX; float dY = pmY - y; pmX = x; pmY = y; if (mouseDownLeft) { line.Position = new PointF(line.Position.X + dX, line.Position.Y + dY); } if (mouseDownRight) { line.End = new PointF(line.End.X + dX, line.End.Y + dY); } }; game.KeyPress += e => { if (e.KeyChar == 'e') { rectangle.Rotation += 1f * deltaTime; } if (e.KeyChar == 'q') { rectangle.Rotation -= 1f * deltaTime; } }; game.ActiveScene = scene; game.Start(); }
public void NewPhysicsTest() { ConvertUnits.SetDisplayUnitToSimUnitRatio(32); Random rng = new Random(); float delta = .3333333f; Dictionary <BaseShape, Body> bodies = new Dictionary <BaseShape, Body>(); float width = 1024, height = 768; Game game = new Game((int)width, (int)height, false, "New Physics Test", 60); Scene scene = new Scene() { BackgroundColor = Color.DarkGray }; World world = new World(new Vector2(0, -9.82f)); Shapes.Rectangle floor = new Shapes.Rectangle() { Position = new PointF(width / 2 - 200, height * .25f), FillColor = Color.LightGray, Width = 400, Height = 80 }; scene.Add(floor); Body bodyFloor = BodyFactory.CreateRectangle(world, ToSimUnits(floor.Width), ToSimUnits(floor.Height), 1, new Vector2(ToSimUnits(floor.X) + ToSimUnits(floor.Width / 2), ToSimUnits(floor.Y + floor.Height / 2))); bodyFloor.IsStatic = true; bodyFloor.BodyType = BodyType.Static; game.KeyPress += e => { if (e.KeyChar.Equals('e')) { floor.Rotation += .2f * delta; bodyFloor.Rotation = -(float)(floor.Rotation * (Math.PI * 2)); } if (e.KeyChar.Equals('q')) { floor.Rotation -= .2f * delta; bodyFloor.Rotation = -(float)(floor.Rotation * (Math.PI * 2)); } }; game.MouseDown += e => { float rWidth = rng.Next(30, 120); float rHeight = rng.Next(30, 120); Shapes.Rectangle rect = new Shapes.Rectangle() { Position = new PointF(e.X - rWidth / 2, height - e.Y - rHeight / 2), Width = rWidth, Height = rHeight, FillColor = Color.FromArgb(rng.Next(256), rng.Next(256), rng.Next(256)) }; scene.Add(rect); Body rectBody = BodyFactory.CreateRectangle(world, ToSimUnits(rect.Width), ToSimUnits(rect.Height), 1, new Vector2(ToSimUnits(rect.X + rect.Width / 2), ToSimUnits(rect.Y + rect.Height / 2))); rectBody.BodyType = BodyType.Dynamic; rectBody.FixtureList.First().UserData = rect; bodies.Add(rect, rectBody); }; scene.Update += e => { delta = (float)e.Time; world.Step(delta); foreach (BaseShape shape in bodies.Keys) { Body body = bodies[shape]; //shape.Position = new PointF( // ToDisplayUnits(body.Position.X) + shape.Width / 2, ToDisplayUnits(body.Position.Y) + shape.Height / 2); shape.Position = new PointF( ToDisplayUnits(body.Position.X) - shape.Width / 2, ToDisplayUnits(body.Position.Y) - shape.Height / 2); shape.Rotation = -(float)(body.Rotation / (2 * Math.PI)); } }; game.ActiveScene = scene; game.Start(); }
public override bool Place(Point origin, StructureMap structures) { Point y; Point point; Dictionary <ushort, int> nums = new Dictionary <ushort, int>(); Point point1 = new Point(origin.X - 25, origin.Y - 25); Shapes.Rectangle rectangle = new Shapes.Rectangle(50, 50); ushort[] numArray = new ushort[] { 0, 1 }; WorldUtils.Gen(point1, rectangle, (new Actions.TileScanner(numArray)).Output(nums)); if (nums[0] + nums[1] < 1250) { return(false); } Searches.Up up = new Searches.Up(1000); GenCondition[] genConditionArray = new GenCondition[] { (new Conditions.IsSolid()).AreaOr(1, 50).Not() }; bool flag = WorldUtils.Find(origin, Searches.Chain(up, genConditionArray), out y); Point point2 = origin; Searches.Up up1 = new Searches.Up(origin.Y - y.Y); GenCondition[] isTile = new GenCondition[1]; ushort[] numArray1 = new ushort[] { 53 }; isTile[0] = new Conditions.IsTile(numArray1); if (WorldUtils.Find(point2, Searches.Chain(up1, isTile), out point)) { return(false); } if (!flag) { return(false); } y.Y = y.Y + 50; ShapeData shapeDatum = new ShapeData(); ShapeData shapeDatum1 = new ShapeData(); Point point3 = new Point(origin.X, origin.Y + 20); Point point4 = new Point(origin.X, origin.Y + 30); float single = 0.8f + GenBase._random.NextFloat() * 0.5f; if (!structures.CanPlace(new Rectangle(point3.X - (int)(20f * single), point3.Y - 20, (int)(40f * single), 40), 0)) { return(false); } if (!structures.CanPlace(new Rectangle(origin.X, y.Y + 10, 1, origin.Y - y.Y - 9), 2)) { return(false); } Shapes.Slime slime = new Shapes.Slime(20, single, 1f); GenAction[] blotch = new GenAction[] { new Modifiers.Blotches(2, 0.4), (new Actions.ClearTile(true)).Output(shapeDatum) }; WorldUtils.Gen(point3, slime, Actions.Chain(blotch)); Shapes.Mound mound = new Shapes.Mound(14, 14); GenAction[] genActionArray = new GenAction[] { new Modifiers.Blotches(2, 1, 0.8), new Actions.SetTile(0, false, true), (new Actions.SetFrames(true)).Output(shapeDatum1) }; WorldUtils.Gen(point4, mound, Actions.Chain(genActionArray)); shapeDatum.Subtract(shapeDatum1, point3, point4); ModShapes.InnerOutline innerOutline = new ModShapes.InnerOutline(shapeDatum, true); GenAction[] setTile = new GenAction[] { new Actions.SetTile(2, false, true), new Actions.SetFrames(true) }; WorldUtils.Gen(point3, innerOutline, Actions.Chain(setTile)); ModShapes.All all = new ModShapes.All(shapeDatum); GenAction[] rectangleMask = new GenAction[] { new Modifiers.RectangleMask(-40, 40, 0, 40), new Modifiers.IsEmpty(), new Actions.SetLiquid(0, 255) }; WorldUtils.Gen(point3, all, Actions.Chain(rectangleMask)); ModShapes.All all1 = new ModShapes.All(shapeDatum); GenAction[] placeWall = new GenAction[] { new Actions.PlaceWall(68, true), null, null, null }; ushort[] numArray2 = new ushort[] { 2 }; placeWall[1] = new Modifiers.OnlyTiles(numArray2); placeWall[2] = new Modifiers.Offset(0, 1); placeWall[3] = new ActionVines(3, 5, 52); WorldUtils.Gen(point3, all1, Actions.Chain(placeWall)); ShapeData shapeDatum2 = new ShapeData(); Point point5 = new Point(origin.X, y.Y + 10); Shapes.Rectangle rectangle1 = new Shapes.Rectangle(1, origin.Y - y.Y - 9); GenAction[] onlyTile = new GenAction[] { new Modifiers.Blotches(2, 0.2), (new Actions.ClearTile(false)).Output(shapeDatum2), new Modifiers.Expand(1), null, null }; ushort[] numArray3 = new ushort[] { 53 }; onlyTile[3] = new Modifiers.OnlyTiles(numArray3); onlyTile[4] = (new Actions.SetTile(397, false, true)).Output(shapeDatum2); WorldUtils.Gen(point5, rectangle1, Actions.Chain(onlyTile)); WorldUtils.Gen(new Point(origin.X, y.Y + 10), new ModShapes.All(shapeDatum2), new Actions.SetFrames(true)); if (GenBase._random.Next(3) != 0) { WorldGen.PlaceTile(point4.X, point4.Y - 15, 186, true, false, -1, 15); } else { WorldGen.PlaceTile(point4.X, point4.Y - 15, 187, true, false, -1, 17); } ModShapes.All all2 = new ModShapes.All(shapeDatum1); GenAction[] offset = new GenAction[] { new Modifiers.Offset(0, -1), null, null, null }; ushort[] numArray4 = new ushort[] { 2 }; offset[1] = new Modifiers.OnlyTiles(numArray4); offset[2] = new Modifiers.Offset(0, -1); offset[3] = new ActionGrass(); WorldUtils.Gen(point4, all2, Actions.Chain(offset)); structures.AddStructure(new Rectangle(point3.X - (int)(20f * single), point3.Y - 20, (int)(40f * single), 40), 4); return(true); }
public override bool Place(Point origin, StructureMap structures) { Point point; Point point1; Point point2 = new Point(origin.X - 3, origin.Y); Searches.Down down = new Searches.Down(200); GenCondition[] genConditionArray = new GenCondition[] { (new Conditions.IsSolid()).AreaAnd(6, 1) }; if (!WorldUtils.Find(point2, Searches.Chain(down, genConditionArray), out point)) { return(false); } Point point3 = new Point(point.X, point.Y - 5); Searches.Up up = new Searches.Up(120); GenCondition[] genConditionArray1 = new GenCondition[] { (new Conditions.IsSolid()).AreaOr(6, 1) }; if (!WorldUtils.Find(point3, Searches.Chain(up, genConditionArray1), out point1) || point.Y - 5 - point1.Y > 60) { return(false); } if (point.Y - point1.Y < 30) { return(false); } if (!structures.CanPlace(new Rectangle(point.X - 30, point.Y - 60, 60, 90), 0)) { return(false); } Dictionary <ushort, int> nums = new Dictionary <ushort, int>(); Point point4 = new Point(point.X - 25, point.Y - 25); Shapes.Rectangle rectangle = new Shapes.Rectangle(50, 50); ushort[] numArray = new ushort[] { 0, 59, 147, 1 }; WorldUtils.Gen(point4, rectangle, (new Actions.TileScanner(numArray)).Output(nums)); int item = nums[0] + nums[1]; int num = nums[59]; if (nums[147] > num || item > num || num < 50) { return(false); } int y = (point.Y - point1.Y - 9) / 5; int num1 = y * 5; int num2 = 0; double num3 = GenBase._random.NextDouble() + 1; double num4 = GenBase._random.NextDouble() + 2; if (GenBase._random.Next(2) == 0) { num4 = -num4; } for (int i = 0; i < y; i++) { double num5 = (double)(i + 1) / 12; int num6 = (int)(Math.Sin(num5 * num3 * 3.14159274101257) * num4); int num7 = (num6 < num2 ? num6 - num2 : 0); Point point5 = new Point(point.X + num2 + num7, point.Y - (i + 1) * 5); Shapes.Rectangle rectangle1 = new Shapes.Rectangle(6 + Math.Abs(num6 - num2), 7); GenAction[] removeWall = new GenAction[] { new Actions.RemoveWall(), new Actions.SetTile(383, false, true), new Actions.SetFrames(false) }; WorldUtils.Gen(point5, rectangle1, Actions.Chain(removeWall)); Point point6 = new Point(point.X + num2 + num7 + 2, point.Y - (i + 1) * 5); Shapes.Rectangle rectangle2 = new Shapes.Rectangle(2 + Math.Abs(num6 - num2), 5); GenAction[] clearTile = new GenAction[] { new Actions.ClearTile(true), new Actions.PlaceWall(78, true) }; WorldUtils.Gen(point6, rectangle2, Actions.Chain(clearTile)); Point point7 = new Point(point.X + num2 + 2, point.Y - i * 5); Shapes.Rectangle rectangle3 = new Shapes.Rectangle(2, 2); GenAction[] genActionArray = new GenAction[] { new Actions.ClearTile(true), new Actions.PlaceWall(78, true) }; WorldUtils.Gen(point7, rectangle3, Actions.Chain(genActionArray)); num2 = num6; } int num8 = 6; if (num4 < 0) { num8 = 0; } List <Point> points = new List <Point>(); for (int j = 0; j < 2; j++) { double num9 = ((double)j + 1) / 3; int num10 = num8 + (int)(Math.Sin((double)y * num9 / 12 * num3 * 3.14159274101257) * num4); double num11 = GenBase._random.NextDouble() * 0.785398185253143 - 0.785398185253143 - 0.200000002980232; if (num8 == 0) { num11 = num11 - 1.57079637050629; } Point point8 = new Point(point.X + num10, point.Y - (int)((double)(y * 5) * num9)); ShapeBranch shapeBranch = (new ShapeBranch(num11, (double)GenBase._random.Next(12, 16))).OutputEndpoints(points); GenAction[] setTile = new GenAction[] { new Actions.SetTile(383, false, true), new Actions.SetFrames(true) }; WorldUtils.Gen(point8, shapeBranch, Actions.Chain(setTile)); num8 = 6 - num8; } int num12 = (int)(Math.Sin((double)y / 12 * num3 * 3.14159274101257) * num4); Point point9 = new Point(point.X + 6 + num12, point.Y - num1); ShapeBranch shapeBranch1 = (new ShapeBranch(-0.685398185253143, (double)GenBase._random.Next(16, 22))).OutputEndpoints(points); GenAction[] setTile1 = new GenAction[] { new Actions.SetTile(383, false, true), new Actions.SetFrames(true) }; WorldUtils.Gen(point9, shapeBranch1, Actions.Chain(setTile1)); Point point10 = new Point(point.X + num12, point.Y - num1); ShapeBranch shapeBranch2 = (new ShapeBranch(-2.45619455575943, (double)GenBase._random.Next(16, 22))).OutputEndpoints(points); GenAction[] genActionArray1 = new GenAction[] { new Actions.SetTile(383, false, true), new Actions.SetFrames(true) }; WorldUtils.Gen(point10, shapeBranch2, Actions.Chain(genActionArray1)); foreach (Point point11 in points) { Shapes.Circle circle = new Shapes.Circle(4); GenAction[] blotch = new GenAction[] { new Modifiers.Blotches(4, 2, 0.3), null, null, null, null }; ushort[] numArray1 = new ushort[] { 383 }; blotch[1] = new Modifiers.SkipTiles(numArray1); byte[] numArray2 = new byte[] { 78 }; blotch[2] = new Modifiers.SkipWalls(numArray2); blotch[3] = new Actions.SetTile(384, false, true); blotch[4] = new Actions.SetFrames(true); WorldUtils.Gen(point11, circle, Actions.Chain(blotch)); } for (int k = 0; k < 4; k++) { float single = (float)k / 3f * 2f + 0.57075f; WorldUtils.Gen(point, new ShapeRoot(single, (float)GenBase._random.Next(40, 60), 4f, 1f), new Actions.SetTile(383, true, true)); } WorldGen.AddBuriedChest(point.X + 3, point.Y - 1, (GenBase._random.Next(4) == 0 ? 0 : WorldGen.GetNextJungleChestItem()), false, 10); structures.AddStructure(new Rectangle(point.X - 30, point.Y - 30, 60, 60), 0); return(true); }
public void StressTest() { Random rng = new Random(); Game game = new Game(1024, 768, false, "Stress Test", 60); Scene scene = new Scene(); float rectsX = 20, rectsY = 20; float rectsWidth = 1024 / rectsX; float rectsHeight = 1024 / rectsY; for (int u = 0; u < rectsX; u++) { for (int v = 0; v < rectsY; v++) { Shapes.Rectangle rect = new Shapes.Rectangle() { Position = new PointF(u * rectsWidth, v * rectsHeight), Width = rectsWidth, Height = rectsHeight, FillColor = rng.NextColor() }; scene.Add(rect); } } Shapes.Rectangle floor = new Shapes.Rectangle() { Position = new PointF(0, -100), Width = 1024, Height = 60, Physics = new Physics(false, 10, 0, 1f), Tag = "FLOOR" }; scene.Add(floor); double delta = 0; scene.Update += e => { delta = e.Time; Console.WriteLine(1 / delta); }; int tEllapsed = 0; Timer t = new Timer(state => { if (tEllapsed >= 5200) { scene.Shapes.ForEach(s => s.Physics = new Physics(true, 1, .5f, 1)); } else { scene.Shapes.Where(s => s.Tag == null).ToList().ForEach(s => s.Rotation += 1f * (float)delta); } tEllapsed += 100; }, null, 1000, 100); game.ActiveScene = scene; game.Start(); }
public void ImplementedPhysicsTest() { Game game = new Game(1024, 768, false, "Physics Test", 60); Scene scene = new Scene(); Random rng = new Random(); List <BaseShape> shapes = new List <BaseShape>(); Line aim = new Line() { FillColor = Color.Pink }; Shapes.Rectangle rect1 = new Shapes.Rectangle() { Position = new PointF(1024f / 2f, 768f * .7f), Width = 200, Height = 200, FillColor = Color.Red, Physics = new Physics(true, 1, .15f, 1) }; rect1.Physics.OnCollision += info => { rect1.FillColor = Color.FromArgb(rng.Next(256), rng.Next(256), rng.Next(256)); }; shapes.Add(rect1); Shapes.Rectangle rect2 = new Shapes.Rectangle() { Position = new PointF(1024f / 2f - 250, 768f * .75f), Width = 100, Height = 100, FillColor = Color.Yellow, Physics = new Physics(true, 1, .25f, 1) }; rect2.Physics.OnCollision += info => { rect2.FillColor = Color.FromArgb(rng.Next(256), rng.Next(256), rng.Next(256)); }; shapes.Add(rect2); Shapes.Rectangle floor = new Shapes.Rectangle() { Position = new PointF(0, 0), Width = 1024, Height = 60, FillColor = Color.Gray, Physics = new Physics(false, 1, 0, 1) }; floor.Physics.OnCollision += info => { Console.WriteLine($"Something just hit the floor with a tangent speed of {info.TangentSpeed}."); }; //shapes.Add(floor); Shapes.Rectangle wall1 = new Shapes.Rectangle() { Position = new PointF(0, 0), Width = 60, Height = 90001, FillColor = Color.Gray, Physics = new Physics(false, 1, 0, 1) }; //shapes.Add(wall1); Shapes.Rectangle wall2 = new Shapes.Rectangle() { Position = new PointF(1024 - 60, 0), Width = 60, Height = 90001, FillColor = Color.Gray, Physics = new Physics(false, 1, 0, 1) }; Shapes.Rectangle ceiling = new Shapes.Rectangle() { Position = new PointF(0, 768 - 60), Width = 1024, Height = 60, FillColor = Color.Gray, Physics = new Physics(false, 1, 0, 1) }; //shapes.Add(wall2); Shapes.Ellipse ell = new Ellipse() { Position = new PointF(320, 550), Sides = 100, Width = 160, Height = 80, FillColor = Color.Green, Physics = new Physics(true, 1, 0, 1) }; shapes.Add(ell); BaseShape pushTarget = null; bool mouseDown = false; PointF originalClick = PointF.Empty; game.MouseDown += e => { if (e.Button == MouseButton.Left) { if (!mouseDown) { pushTarget = shapes.FirstOrDefault(s => s.Contains(new PointF(e.X, 768 - e.Y))); if (pushTarget != null) { mouseDown = true; aim.Position = new PointF(e.X, 768 - e.Y); aim.End = new PointF(e.X, 768 - e.Y); aim.Visible = true; originalClick = new PointF(e.X, 768 - e.Y); } } } else if (e.Button == MouseButton.Right) { float width = rng.Next(40, 150); float height = rng.Next(40, 150); Shapes.Rectangle newRect = new Shapes.Rectangle() { Position = new PointF(e.X - width / 2, 768 - e.Y - height / 2), Width = width, Height = height, FillColor = Color.FromArgb(rng.Next(256), rng.Next(256), rng.Next(256)), Physics = new Physics(true, 1, 0, 1) }; newRect.Physics.OnCollision += info => { newRect.FillColor = Color.FromArgb(rng.Next(256), rng.Next(256), rng.Next(256)); }; shapes.Add(newRect); scene.Shapes.Insert(0, newRect); } else if (e.Button == MouseButton.Middle) { BaseShape shape = shapes.Where(s => s.Physics != null).FirstOrDefault(n => n.Contains(new PointF(e.X, 768 - e.Y))); if (shape != null) { if (shape.Physics.GravityScale == 1) { shape.Physics.GravityScale = 0; } else { shape.Physics.GravityScale = 1; } } } }; game.MouseUp += e => { if (e.Button == MouseButton.Left) { if (mouseDown) { if (pushTarget != null) { mouseDown = false; aim.Visible = false; PointF force = new PointF( (aim.X2 - aim.X), (aim.Y2 - aim.Y)); pushTarget.Physics.Push(force, new PointF(ToSimUnits(originalClick.X), ToSimUnits(originalClick.Y))); } } } }; bool leftShiftHeld = false; bool rightShiftHeld = false; bool leftControlHeld = false; bool rightControlHeld = false; game.KeyDown += e => { switch (e.Key) { case Key.LShift: leftShiftHeld = true; break; case Key.RShift: rightShiftHeld = true; break; case Key.LControl: leftControlHeld = true; break; case Key.RControl: rightControlHeld = true; break; case Key.A: if (leftShiftHeld) { shapes.Where(n => n.Physics != null).Select(n => n.Physics).ToList().ForEach(p => p.Push(new PointF(-35, 0))); } break; case Key.D: if (leftShiftHeld) { shapes.Where(n => n.Physics != null).Select(n => n.Physics).ToList().ForEach(p => p.Push(new PointF(35, 0))); } break; case Key.W: if (leftShiftHeld) { shapes.Where(n => n.Physics != null).Select(n => n.Physics).ToList().ForEach(p => p.Push(new PointF(0, 35))); } break; case Key.S: if (leftShiftHeld) { shapes.Where(n => n.Physics != null).Select(n => n.Physics).ToList().ForEach(p => p.Push(new PointF(0, -35))); } break; case Key.G: shapes.Where(n => n.Physics != null).Select(n => n.Physics).ToList().ForEach(p => { if (p.GravityScale == 0) { p.GravityScale = 1; } else { p.GravityScale = 0; } }); break; case Key.T: ceiling.Visible = !ceiling.Visible; ceiling.Physics.Enabled = !ceiling.Physics.Enabled; break; } }; game.KeyUp += e => { switch (e.Key) { case Key.LShift: leftShiftHeld = false; break; case Key.RShift: rightShiftHeld = false; break; case Key.LControl: leftControlHeld = false; break; case Key.RControl: rightControlHeld = false; break; } }; PointF mousePoint = Point.Empty; game.MouseMove += e => { mousePoint = new PointF(e.X, 768 - e.Y); if (mouseDown) { aim.End = new PointF(e.X, 768 - e.Y); } }; Timer spawnTimer = null; game.KeyPress += e => { switch (e.KeyChar) { case 'f': shapes.ForEach(s => { if (s.Physics != null) { s.Physics.Enabled = !s.Physics.Enabled; } }); break; case 's': if (spawnTimer != null) { spawnTimer.Dispose(); spawnTimer = null; } else { spawnTimer = new Timer(state => { float width = rng.Next(10, 35); float height = rng.Next(10, 35); Shapes.Ellipse newRect = new Shapes.Ellipse() { Position = new PointF(mousePoint.X, mousePoint.Y), Width = width, Height = width, FillColor = Color.FromArgb(rng.Next(256), rng.Next(256), rng.Next(256)), Physics = new Physics(true, 1, 0, 1) }; newRect.Physics.OnCollision += info => { newRect.FillColor = Color.FromArgb(rng.Next(256), rng.Next(256), rng.Next(256)); }; shapes.Add(newRect); scene.Shapes.Insert(0, newRect); }, new object(), 0, 200); } break; case 'a': if (Math.Abs(rect1.Physics.LinearVelocity.X) < 6) { rect1.Physics.Push(new PointF(-3, 0)); } break; case 'd': if (Math.Abs(rect1.Physics.LinearVelocity.X) < 6) { rect1.Physics.Push(new PointF(3, 0)); } break; case ' ': rect1.Physics.Push(new PointF(0, 20)); break; case '+': BaseShape shape = shapes.FirstOrDefault(n => n.Contains(mousePoint)); if (shape != null) { if (!leftShiftHeld) { shape.Width += 10; } else { shape.Height += 10; } } break; case '-': BaseShape shapeM = shapes.FirstOrDefault(n => n.Contains(mousePoint)); if (shapeM != null) { if (!leftShiftHeld) { shapeM.Width -= 10; } else { shapeM.Height -= 10; } } break; } }; scene.Update += e => { // ... }; shapes.ForEach(s => scene.Add(s)); scene.Add(floor); scene.Add(wall1); scene.Add(wall2); scene.Add(aim); scene.Add(ceiling); game.ActiveScene = scene; game.Start(); }
public override bool Place(Point origin, StructureMap structures) { Point result1; if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(200), (GenCondition) new Conditions.IsSolid()), out result1) || result1 == origin) { return(false); } var room1 = GetRoom(result1); var room2 = GetRoom(new Point(room1.Center.X, room1.Y + 1)); var room3 = GetRoom(new Point(room1.Center.X, room1.Y + room1.Height + 10)); room3.Y = room1.Y + room1.Height - 1; var num1 = RoomSolidPrecentage(room2); var num2 = RoomSolidPrecentage(room3); room1.Y += 3; room2.Y += 3; room3.Y += 3; var rectangleList1 = new List <Rectangle>(); if (_random.NextFloat() > num1 + 0.200000002980232) { rectangleList1.Add(room2); } else { room2 = room1; } rectangleList1.Add(room1); if (_random.NextFloat() > num2 + 0.200000002980232) { rectangleList1.Add(room3); } else { room3 = room1; } foreach (var rectangle in rectangleList1) { if (rectangle.Y + rectangle.Height > Main.maxTilesY - 220) { return(false); } } var resultsOutput = new Dictionary <ushort, int>(); foreach (var rectangle in rectangleList1) { WorldUtils.Gen(new Point(rectangle.X - 10, rectangle.Y - 10), new Shapes.Rectangle(rectangle.Width + 20, rectangle.Height + 20), new Actions.TileScanner((ushort)0, (ushort)59, (ushort)147, (ushort)1, (ushort)161, (ushort)53, (ushort)396, (ushort)397, (ushort)368, (ushort)367, (ushort)60, (ushort)70) .Output(resultsOutput)); } var tupleList1 = new List <Tuple <BuildData, int> >(); tupleList1.Add(Tuple.Create(BuildData.Default, resultsOutput[0] + resultsOutput[1])); tupleList1.Add(Tuple.Create(BuildData.Jungle, resultsOutput[59] + resultsOutput[60] * 10)); tupleList1.Add(Tuple.Create(BuildData.Mushroom, resultsOutput[59] + resultsOutput[70] * 10)); tupleList1.Add(Tuple.Create(BuildData.Snow, resultsOutput[147] + resultsOutput[161])); tupleList1.Add(Tuple.Create(BuildData.Desert, resultsOutput[397] + resultsOutput[396] + resultsOutput[53])); tupleList1.Add(Tuple.Create(BuildData.Granite, resultsOutput[368])); tupleList1.Add(Tuple.Create(BuildData.Marble, resultsOutput[367])); tupleList1.Sort(SortBiomeResults); var buildData = tupleList1[0].Item1; foreach (var area in rectangleList1) { if (buildData != BuildData.Granite) { Point result2; if (WorldUtils.Find(new Point(area.X - 2, area.Y - 2), Searches.Chain(new Searches.Rectangle(area.Width + 4, area.Height + 4).RequireAll(false), (GenCondition) new Conditions.HasLava()), out result2)) { return(false); } } if (!structures.CanPlace(area, _blacklistedTiles, 5)) { return(false); } } var val1_1 = room1.X; var val1_2 = room1.X + room1.Width - 1; var rectangleList2 = new List <Rectangle>(); foreach (var rectangle in rectangleList1) { val1_1 = Math.Min(val1_1, rectangle.X); val1_2 = Math.Max(val1_2, rectangle.X + rectangle.Width - 1); } var num3 = 6; while (num3 > 4 && (val1_2 - val1_1) % num3 != 0) { --num3; } var x1 = val1_1; while (x1 <= val1_2) { for (var index1 = 0; index1 < rectangleList1.Count; ++index1) { var rectangle = rectangleList1[index1]; if (x1 >= rectangle.X && x1 < rectangle.X + rectangle.Width) { var y = rectangle.Y + rectangle.Height; var num4 = 50; for (var index2 = index1 + 1; index2 < rectangleList1.Count; ++index2) { if (x1 >= rectangleList1[index2].X && x1 < rectangleList1[index2].X + rectangleList1[index2].Width) { num4 = Math.Min(num4, rectangleList1[index2].Y - y); } } if (num4 > 0) { Point result2; var flag = WorldUtils.Find(new Point(x1, y), Searches.Chain(new Searches.Down(num4), (GenCondition) new Conditions.IsSolid()), out result2); if (num4 < 50) { flag = true; result2 = new Point(x1, y + num4); } if (flag) { rectangleList2.Add(new Rectangle(x1, y, 1, result2.Y - y)); } } } } x1 += num3; } var pointList1 = new List <Point>(); foreach (var rectangle in rectangleList1) { int exitY; if (FindSideExit( new Rectangle(rectangle.X + rectangle.Width, rectangle.Y + 1, 1, rectangle.Height - 2), false, out exitY)) { pointList1.Add(new Point(rectangle.X + rectangle.Width - 1, exitY)); } if (FindSideExit( new Rectangle(rectangle.X, rectangle.Y + 1, 1, rectangle.Height - 2), true, out exitY)) { pointList1.Add(new Point(rectangle.X, exitY)); } } var tupleList2 = new List <Tuple <Point, Point> >(); for (var index = 1; index < rectangleList1.Count; ++index) { var rectangle1 = rectangleList1[index]; var rectangle2 = rectangleList1[index - 1]; if (rectangle2.X - rectangle1.X > rectangle1.X + rectangle1.Width - (rectangle2.X + rectangle2.Width)) { tupleList2.Add(new Tuple <Point, Point>( new Point(rectangle1.X + rectangle1.Width - 1, rectangle1.Y + 1), new Point(rectangle1.X + rectangle1.Width - rectangle1.Height + 1, rectangle1.Y + rectangle1.Height - 1))); } else { tupleList2.Add(new Tuple <Point, Point>(new Point(rectangle1.X, rectangle1.Y + 1), new Point(rectangle1.X + rectangle1.Height - 1, rectangle1.Y + rectangle1.Height - 1))); } } var pointList2 = new List <Point>(); int exitX; if (FindVerticalExit(new Rectangle(room2.X + 2, room2.Y, room2.Width - 4, 1), true, out exitX)) { pointList2.Add(new Point(exitX, room2.Y)); } if (FindVerticalExit( new Rectangle(room3.X + 2, room3.Y + room3.Height - 1, room3.Width - 4, 1), false, out exitX)) { pointList2.Add(new Point(exitX, room3.Y + room3.Height - 1)); } foreach (var area in rectangleList1) { WorldUtils.Gen(new Point(area.X, area.Y), new Shapes.Rectangle(area.Width, area.Height), Actions.Chain((GenAction) new Actions.SetTile(buildData.Tile, false, true), (GenAction) new Actions.SetFrames(true))); WorldUtils.Gen(new Point(area.X + 1, area.Y + 1), new Shapes.Rectangle(area.Width - 2, area.Height - 2), Actions.Chain((GenAction) new Actions.ClearTile(true), (GenAction) new Actions.PlaceWall(buildData.Wall, true))); structures.AddStructure(area, 8); } foreach (var tuple in tupleList2) { var origin1 = tuple.Item1; var point = tuple.Item2; var num4 = point.X > origin1.X ? 1 : -1; var data = new ShapeData(); for (var y = 0; y < point.Y - origin1.Y; ++y) { data.Add(num4 * (y + 1), y); } WorldUtils.Gen(origin1, new ModShapes.All(data), Actions.Chain((GenAction) new Actions.PlaceTile(19, buildData.PlatformStyle), (GenAction) new Actions.SetSlope(num4 == 1 ? 1 : 2), (GenAction) new Actions.SetFrames(true))); WorldUtils.Gen(new Point(origin1.X + (num4 == 1 ? 1 : -4), origin1.Y - 1), new Shapes.Rectangle(4, 1), Actions.Chain((GenAction) new Actions.Clear(), (GenAction) new Actions.PlaceWall(buildData.Wall, true), (GenAction) new Actions.PlaceTile(19, buildData.PlatformStyle), (GenAction) new Actions.SetFrames(true))); } foreach (var origin1 in pointList1) { WorldUtils.Gen(origin1, new Shapes.Rectangle(1, 3), new Actions.ClearTile(true)); WorldGen.PlaceTile(origin1.X, origin1.Y, 10, true, true, -1, buildData.DoorStyle); } foreach (var origin1 in pointList2) { var rectangle = new Shapes.Rectangle(3, 1); var action = Actions.Chain((GenAction) new Actions.ClearMetadata(), (GenAction) new Actions.PlaceTile(19, buildData.PlatformStyle), (GenAction) new Actions.SetFrames(true)); WorldUtils.Gen(origin1, rectangle, action); } foreach (var rectangle in rectangleList2) { if (rectangle.Height > 1 && _tiles[rectangle.X, rectangle.Y - 1].type != 19) { WorldUtils.Gen(new Point(rectangle.X, rectangle.Y), new Shapes.Rectangle(rectangle.Width, rectangle.Height), Actions.Chain((GenAction) new Actions.SetTile(124, false, true), (GenAction) new Actions.SetFrames(true))); var tile = _tiles[rectangle.X, rectangle.Y + rectangle.Height]; tile.slope(0); tile.halfBrick(false); } } var pointArray = new Point[7] { new Point(14, buildData.TableStyle), new Point(16, 0), new Point(18, buildData.WorkbenchStyle), new Point(86, 0), new Point(87, buildData.PianoStyle), new Point(94, 0), new Point(101, buildData.BookcaseStyle) }; foreach (var rectangle in rectangleList1) { var num4 = rectangle.Width / 8; var num5 = rectangle.Width / (num4 + 1); var num6 = _random.Next(2); for (var index1 = 0; index1 < num4; ++index1) { var num7 = (index1 + 1) * num5 + rectangle.X; switch (index1 + num6 % 2) { case 0: var num8 = rectangle.Y + Math.Min(rectangle.Height / 2, rectangle.Height - 5); var vector2 = WorldGen.randHousePicture(); var x2 = (int)vector2.X; var y = (int)vector2.Y; if (!WorldGen.nearPicture(num7, num8)) { WorldGen.PlaceTile(num7, num8, x2, true, false, -1, y); } break; case 1: var j = rectangle.Y + 1; WorldGen.PlaceTile(num7, j, 34, true, false, -1, _random.Next(6)); for (var index2 = -1; index2 < 2; ++index2) { for (var index3 = 0; index3 < 3; ++index3) { _tiles[index2 + num7, index3 + j].frameX += 54; } } break; } } var num9 = rectangle.Width / 8 + 3; WorldGen.SetupStatueList(); for (; num9 > 0; --num9) { var num7 = _random.Next(rectangle.Width - 3) + 1 + rectangle.X; var num8 = rectangle.Y + rectangle.Height - 2; switch (_random.Next(4)) { case 0: WorldGen.PlaceSmallPile(num7, num8, _random.Next(31, 34), 1, 185); break; case 1: WorldGen.PlaceTile(num7, num8, 186, true, false, -1, _random.Next(22, 26)); break; case 2: var index = _random.Next(2, WorldGen.statueList.Length); WorldGen.PlaceTile(num7, num8, WorldGen.statueList[index].X, true, false, -1, WorldGen.statueList[index].Y); if (WorldGen.StatuesWithTraps.Contains(index)) { WorldGen.PlaceStatueTrap(num7, num8); } break; case 3: var point = Utils.SelectRandom(_random, pointArray); WorldGen.PlaceTile(num7, num8, point.X, true, false, -1, point.Y); break; } } } foreach (var room4 in rectangleList1) { buildData.ProcessRoom(room4); } var flag1 = false; foreach (var rectangle in rectangleList1) { var j = rectangle.Height - 1 + rectangle.Y; var Style = j > (int)Main.worldSurface ? buildData.ChestStyle : 0; var num4 = 0; while (num4 < 10 && !(flag1 = WorldGen.AddBuriedChest(_random.Next(2, rectangle.Width - 2) + rectangle.X, j, 0, false, Style))) { ++num4; } if (!flag1) { var i = rectangle.X + 2; while (i <= rectangle.X + rectangle.Width - 2 && !(flag1 = WorldGen.AddBuriedChest(i, j, 0, false, Style))) { ++i; } if (flag1) { break; } } else { break; } } if (!flag1) { foreach (var rectangle in rectangleList1) { var j = rectangle.Y - 1; var Style = j > (int)Main.worldSurface ? buildData.ChestStyle : 0; var num4 = 0; while (num4 < 10 && !(flag1 = WorldGen.AddBuriedChest(_random.Next(2, rectangle.Width - 2) + rectangle.X, j, 0, false, Style))) { ++num4; } if (!flag1) { var i = rectangle.X + 2; while (i <= rectangle.X + rectangle.Width - 2 && !(flag1 = WorldGen.AddBuriedChest(i, j, 0, false, Style))) { ++i; } if (flag1) { break; } } else { break; } } } if (!flag1) { for (var index = 0; index < 1000; ++index) { var i = _random.Next(rectangleList1[0].X - 30, rectangleList1[0].X + 30); var j = _random.Next(rectangleList1[0].Y - 30, rectangleList1[0].Y + 30); var Style = j > (int)Main.worldSurface ? buildData.ChestStyle : 0; if (WorldGen.AddBuriedChest(i, j, 0, false, Style)) { break; } } } if (buildData == BuildData.Jungle && _sharpenerCount < _random.Next(2, 5)) { var flag2 = false; foreach (var rectangle in rectangleList1) { var j = rectangle.Height - 2 + rectangle.Y; for (var index = 0; index < 10; ++index) { var i = _random.Next(2, rectangle.Width - 2) + rectangle.X; WorldGen.PlaceTile(i, j, 377, true, true, -1, 0); if (flag2 = _tiles[i, j].active() && _tiles[i, j].type == 377) { break; } } if (!flag2) { var i = rectangle.X + 2; while (i <= rectangle.X + rectangle.Width - 2 && !(flag2 = WorldGen.PlaceTile(i, j, 377, true, true, -1, 0))) { ++i; } if (flag2) { break; } } else { break; } } if (flag2) { ++_sharpenerCount; } } if (buildData == BuildData.Desert && _extractinatorCount < _random.Next(2, 5)) { var flag2 = false; foreach (var rectangle in rectangleList1) { var j = rectangle.Height - 2 + rectangle.Y; for (var index = 0; index < 10; ++index) { var i = _random.Next(2, rectangle.Width - 2) + rectangle.X; WorldGen.PlaceTile(i, j, 219, true, true, -1, 0); if (flag2 = _tiles[i, j].active() && _tiles[i, j].type == 219) { break; } } if (!flag2) { var i = rectangle.X + 2; while (i <= rectangle.X + rectangle.Width - 2 && !(flag2 = WorldGen.PlaceTile(i, j, 219, true, true, -1, 0))) { ++i; } if (flag2) { break; } } else { break; } } if (flag2) { ++_extractinatorCount; } } return(true); }
public void Execute() { OpenFileDialog openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() == DialogResult.OK) { string fileName; fileName = openFileDialog.FileName; //MessageBox.Show(fileName); List <DrawingObject> DrawingObject = this.canvas.GetListDrawingObject(); DrawingObject.Clear(); List <DrawingObject> temp = new List <DrawingObject>(); Shapes.Rectangle rectangle = new Shapes.Rectangle(); temp = rectangle.Unserialize(fileName); foreach (DrawingObject obj in temp) { DrawingObject.Add(obj); DrawingObject.Add(obj); DrawingObject.Add(obj); } temp.Clear(); List <DrawingObject> temp2 = new List <DrawingObject>(); Shapes.AssociationLine line = new Shapes.AssociationLine(); temp2 = line.Unserialize(fileName); if (temp2.Count > 0) { foreach (Edge obj in temp2) { Shapes.AssociationLine drawLine = new Shapes.AssociationLine(obj.Startpoint, obj.Endpoint); drawLine.ID = obj.ID; drawLine.relationStart = obj.relationStart; drawLine.relationEnd = obj.relationEnd; foreach (DrawingObject obj2 in DrawingObject) { Vertex obj3; if (obj2.ID.ToString().Equals(obj.idStartVertex)) { obj3 = (Vertex)obj2; drawLine.AddVertex(obj3); obj3.Subscribe(drawLine); } } foreach (DrawingObject obj2 in DrawingObject) { Vertex obj3; if (obj2.ID.ToString().Equals(obj.idEndVertex)) { obj3 = (Vertex)obj2; drawLine.AddVertex(obj3); obj3.Subscribe(drawLine); } } temp.Clear(); DrawingObject.Add(drawLine); } } List <DrawingObject> temp3 = new List <DrawingObject>(); Shapes.DependencyLine line1 = new Shapes.DependencyLine(); temp3 = line1.Unserialize(fileName); if (temp3.Count > 0) { foreach (Edge obj in temp3) { Shapes.DependencyLine drawLine = new Shapes.DependencyLine(obj.Startpoint, obj.Endpoint); drawLine.ID = obj.ID; drawLine.relationStart = obj.relationStart; drawLine.relationEnd = obj.relationEnd; foreach (DrawingObject obj2 in DrawingObject) { Vertex obj3; if (obj2.ID.ToString().Equals(obj.idStartVertex)) { obj3 = (Vertex)obj2; drawLine.AddVertex(obj3); obj3.Subscribe(drawLine); } } foreach (DrawingObject obj2 in DrawingObject) { Vertex obj3; if (obj2.ID.ToString().Equals(obj.idEndVertex)) { obj3 = (Vertex)obj2; drawLine.AddVertex(obj3); obj3.Subscribe(drawLine); } } temp.Clear(); DrawingObject.Add(drawLine); } } List <DrawingObject> temp4 = new List <DrawingObject>(); Shapes.DirectedAssociationLine line2 = new Shapes.DirectedAssociationLine(); temp4 = line2.Unserialize(fileName); if (temp4.Count > 0) { foreach (Edge obj in temp4) { Shapes.DirectedAssociationLine drawLine = new Shapes.DirectedAssociationLine(obj.Startpoint, obj.Endpoint); drawLine.ID = obj.ID; drawLine.relationStart = obj.relationStart; drawLine.relationEnd = obj.relationEnd; foreach (DrawingObject obj2 in DrawingObject) { Vertex obj3; if (obj2.ID.ToString().Equals(obj.idStartVertex)) { obj3 = (Vertex)obj2; drawLine.AddVertex(obj3); obj3.Subscribe(drawLine); } } foreach (DrawingObject obj2 in DrawingObject) { Vertex obj3; if (obj2.ID.ToString().Equals(obj.idEndVertex)) { obj3 = (Vertex)obj2; drawLine.AddVertex(obj3); obj3.Subscribe(drawLine); } } temp.Clear(); DrawingObject.Add(drawLine); } } List <DrawingObject> temp5 = new List <DrawingObject>(); Shapes.RealizationLine line3 = new Shapes.RealizationLine(); temp5 = line3.Unserialize(fileName); if (temp5.Count > 0) { foreach (Edge obj in temp5) { Shapes.RealizationLine drawLine = new Shapes.RealizationLine(obj.Startpoint, obj.Endpoint); drawLine.ID = obj.ID; drawLine.relationStart = obj.relationStart; drawLine.relationEnd = obj.relationEnd; foreach (DrawingObject obj2 in DrawingObject) { Vertex obj3; if (obj2.ID.ToString().Equals(obj.idStartVertex)) { obj3 = (Vertex)obj2; drawLine.AddVertex(obj3); obj3.Subscribe(drawLine); } } foreach (DrawingObject obj2 in DrawingObject) { Vertex obj3; if (obj2.ID.ToString().Equals(obj.idEndVertex)) { obj3 = (Vertex)obj2; drawLine.AddVertex(obj3); obj3.Subscribe(drawLine); } } temp.Clear(); DrawingObject.Add(drawLine); } } List <DrawingObject> temp6 = new List <DrawingObject>(); Shapes.GeneralizationLine line4 = new Shapes.GeneralizationLine(); temp6 = line4.Unserialize(fileName); if (temp6.Count > 0) { foreach (Edge obj in temp6) { Shapes.GeneralizationLine drawLine = new Shapes.GeneralizationLine(obj.Startpoint, obj.Endpoint); drawLine.ID = obj.ID; drawLine.relationStart = obj.relationStart; drawLine.relationEnd = obj.relationEnd; foreach (DrawingObject obj2 in DrawingObject) { Vertex obj3; if (obj2.ID.ToString().Equals(obj.idStartVertex)) { obj3 = (Vertex)obj2; drawLine.AddVertex(obj3); obj3.Subscribe(drawLine); } } foreach (DrawingObject obj2 in DrawingObject) { Vertex obj3; if (obj2.ID.ToString().Equals(obj.idEndVertex)) { obj3 = (Vertex)obj2; drawLine.AddVertex(obj3); obj3.Subscribe(drawLine); } } temp.Clear(); DrawingObject.Add(drawLine); } } this.canvas.DeselectAllObjects(); this.canvas.Repaint(); } }
public override void Execute() { using (var SaveFileDialog = new SaveFileDialog()) { SaveFileDialog.Filter = "Pattern Designer Document(*ptd)|*.ptd"; SaveFileDialog.Title = "Save an Document"; if (SaveFileDialog.ShowDialog() == DialogResult.OK) { string path = SaveFileDialog.FileName; List <DrawingObject> listDrawingObject = canvas.GetListDrawingObject(); Debug.WriteLine(listDrawingObject.Count()); XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.NewLineOnAttributes = true; XmlWriter writer = XmlWriter.Create(path, settings); writer.WriteStartDocument(); writer.WriteStartElement("diagram"); writer.WriteEndElement(); writer.WriteEndDocument(); writer.Close(); for (int i = 0; i < listDrawingObject.Count; i++) { DrawingObject obj = listDrawingObject[i]; if (obj is IPersistance) { if (obj is Shapes.Rectangle) { Shapes.Rectangle tempObj = (Shapes.Rectangle)obj; tempObj.Serialize(path); i += 2; } else if (obj is AssociationLine) { AssociationLine tempObj1 = (AssociationLine)obj; tempObj1.Serialize(path); } else if (obj is DependencyLine) { DependencyLine tempObj2 = (DependencyLine)obj; tempObj2.Serialize(path); } else if (obj is DirectedAssociationLine) { DirectedAssociationLine tempObj3 = (DirectedAssociationLine)obj; tempObj3.Serialize(path); } else if (obj is GeneralizationLine) { GeneralizationLine tempObj4 = (GeneralizationLine)obj; tempObj4.Serialize(path); } else if (obj is RealizationLine) { RealizationLine tempObj5 = (RealizationLine)obj; tempObj5.Serialize(path); } } } } } }
public override bool Place(Point origin, StructureMap structures) { Point result1; if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(200), (GenCondition) new Conditions.IsSolid()), out result1) || result1 == origin) { return(false); } Microsoft.Xna.Framework.Rectangle room1 = this.GetRoom(result1); Microsoft.Xna.Framework.Rectangle room2 = this.GetRoom(new Point(room1.Center.X, room1.Y + 1)); Microsoft.Xna.Framework.Rectangle room3 = this.GetRoom(new Point(room1.Center.X, room1.Y + room1.Height + 10)); room3.Y = room1.Y + room1.Height - 1; float num1 = this.RoomSolidPrecentage(room2); float num2 = this.RoomSolidPrecentage(room3); room1.Y += 3; room2.Y += 3; room3.Y += 3; List <Microsoft.Xna.Framework.Rectangle> rectangleList1 = new List <Microsoft.Xna.Framework.Rectangle>(); if ((double)GenBase._random.NextFloat() > (double)num1 + 0.200000002980232) { rectangleList1.Add(room2); } else { room2 = room1; } rectangleList1.Add(room1); if ((double)GenBase._random.NextFloat() > (double)num2 + 0.200000002980232) { rectangleList1.Add(room3); } else { room3 = room1; } foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1) { if (rectangle.Y + rectangle.Height > Main.maxTilesY - 220) { return(false); } } Dictionary <ushort, int> resultsOutput = new Dictionary <ushort, int>(); foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1) { WorldUtils.Gen(new Point(rectangle.X - 10, rectangle.Y - 10), (GenShape) new Shapes.Rectangle(rectangle.Width + 20, rectangle.Height + 20), (GenAction) new Actions.TileScanner(new ushort[12] { (ushort)0, (ushort)59, (ushort)147, (ushort)1, (ushort)161, (ushort)53, (ushort)396, (ushort)397, (ushort)368, (ushort)367, (ushort)60, (ushort)70 }).Output(resultsOutput)); } List <Tuple <CaveHouseBiome.BuildData, int> > tupleList1 = new List <Tuple <CaveHouseBiome.BuildData, int> >(); tupleList1.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Default, resultsOutput[(ushort)0] + resultsOutput[(ushort)1])); tupleList1.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Jungle, resultsOutput[(ushort)59] + resultsOutput[(ushort)60] * 10)); tupleList1.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Mushroom, resultsOutput[(ushort)59] + resultsOutput[(ushort)70] * 10)); tupleList1.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Snow, resultsOutput[(ushort)147] + resultsOutput[(ushort)161])); tupleList1.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Desert, resultsOutput[(ushort)397] + resultsOutput[(ushort)396] + resultsOutput[(ushort)53])); tupleList1.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Granite, resultsOutput[(ushort)368])); tupleList1.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Marble, resultsOutput[(ushort)367])); Comparison <Tuple <CaveHouseBiome.BuildData, int> > comparison = new Comparison <Tuple <CaveHouseBiome.BuildData, int> >(this.SortBiomeResults); tupleList1.Sort(comparison); int index1 = 0; CaveHouseBiome.BuildData buildData = tupleList1[index1].Item1; foreach (Microsoft.Xna.Framework.Rectangle area in rectangleList1) { if (buildData != CaveHouseBiome.BuildData.Granite) { Point result2; if (WorldUtils.Find(new Point(area.X - 2, area.Y - 2), Searches.Chain(new Searches.Rectangle(area.Width + 4, area.Height + 4).RequireAll(false), (GenCondition) new Conditions.HasLava()), out result2)) { return(false); } } if (!structures.CanPlace(area, CaveHouseBiome._blacklistedTiles, 5)) { return(false); } } int val1_1 = room1.X; int val1_2 = room1.X + room1.Width - 1; List <Microsoft.Xna.Framework.Rectangle> rectangleList2 = new List <Microsoft.Xna.Framework.Rectangle>(); foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1) { val1_1 = Math.Min(val1_1, rectangle.X); val1_2 = Math.Max(val1_2, rectangle.X + rectangle.Width - 1); } int num3 = 6; while (num3 > 4 && (val1_2 - val1_1) % num3 != 0) { --num3; } int x1 = val1_1; while (x1 <= val1_2) { for (int index2 = 0; index2 < rectangleList1.Count; ++index2) { Microsoft.Xna.Framework.Rectangle rectangle = rectangleList1[index2]; if (x1 >= rectangle.X && x1 < rectangle.X + rectangle.Width) { int y = rectangle.Y + rectangle.Height; int num4 = 50; for (int index3 = index2 + 1; index3 < rectangleList1.Count; ++index3) { if (x1 >= rectangleList1[index3].X && x1 < rectangleList1[index3].X + rectangleList1[index3].Width) { num4 = Math.Min(num4, rectangleList1[index3].Y - y); } } if (num4 > 0) { Point result2; bool flag = WorldUtils.Find(new Point(x1, y), Searches.Chain((GenSearch) new Searches.Down(num4), (GenCondition) new Conditions.IsSolid()), out result2); if (num4 < 50) { flag = true; result2 = new Point(x1, y + num4); } if (flag) { rectangleList2.Add(new Microsoft.Xna.Framework.Rectangle(x1, y, 1, result2.Y - y)); } } } } x1 += num3; } List <Point> pointList1 = new List <Point>(); foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1) { int exitY; if (this.FindSideExit(new Microsoft.Xna.Framework.Rectangle(rectangle.X + rectangle.Width, rectangle.Y + 1, 1, rectangle.Height - 2), false, out exitY)) { pointList1.Add(new Point(rectangle.X + rectangle.Width - 1, exitY)); } if (this.FindSideExit(new Microsoft.Xna.Framework.Rectangle(rectangle.X, rectangle.Y + 1, 1, rectangle.Height - 2), true, out exitY)) { pointList1.Add(new Point(rectangle.X, exitY)); } } List <Tuple <Point, Point> > tupleList2 = new List <Tuple <Point, Point> >(); for (int index2 = 1; index2 < rectangleList1.Count; ++index2) { Microsoft.Xna.Framework.Rectangle rectangle1 = rectangleList1[index2]; Microsoft.Xna.Framework.Rectangle rectangle2 = rectangleList1[index2 - 1]; if (rectangle2.X - rectangle1.X > rectangle1.X + rectangle1.Width - (rectangle2.X + rectangle2.Width)) { tupleList2.Add(new Tuple <Point, Point>(new Point(rectangle1.X + rectangle1.Width - 1, rectangle1.Y + 1), new Point(rectangle1.X + rectangle1.Width - rectangle1.Height + 1, rectangle1.Y + rectangle1.Height - 1))); } else { tupleList2.Add(new Tuple <Point, Point>(new Point(rectangle1.X, rectangle1.Y + 1), new Point(rectangle1.X + rectangle1.Height - 1, rectangle1.Y + rectangle1.Height - 1))); } } List <Point> pointList2 = new List <Point>(); int exitX; if (this.FindVerticalExit(new Microsoft.Xna.Framework.Rectangle(room2.X + 2, room2.Y, room2.Width - 4, 1), true, out exitX)) { pointList2.Add(new Point(exitX, room2.Y)); } if (this.FindVerticalExit(new Microsoft.Xna.Framework.Rectangle(room3.X + 2, room3.Y + room3.Height - 1, room3.Width - 4, 1), false, out exitX)) { pointList2.Add(new Point(exitX, room3.Y + room3.Height - 1)); } foreach (Microsoft.Xna.Framework.Rectangle area in rectangleList1) { WorldUtils.Gen(new Point(area.X, area.Y), (GenShape) new Shapes.Rectangle(area.Width, area.Height), Actions.Chain((GenAction) new Actions.SetTile(buildData.Tile, false, true), (GenAction) new Actions.SetFrames(true))); WorldUtils.Gen(new Point(area.X + 1, area.Y + 1), (GenShape) new Shapes.Rectangle(area.Width - 2, area.Height - 2), Actions.Chain((GenAction) new Actions.ClearTile(true), (GenAction) new Actions.PlaceWall(buildData.Wall, true))); structures.AddStructure(area, 8); } foreach (Tuple <Point, Point> tuple in tupleList2) { Point origin1 = tuple.Item1; Point point = tuple.Item2; int num4 = point.X > origin1.X ? 1 : -1; ShapeData data = new ShapeData(); for (int y = 0; y < point.Y - origin1.Y; ++y) { data.Add(num4 * (y + 1), y); } WorldUtils.Gen(origin1, (GenShape) new ModShapes.All(data), Actions.Chain((GenAction) new Actions.PlaceTile((ushort)19, buildData.PlatformStyle), (GenAction) new Actions.SetSlope(num4 == 1 ? 1 : 2), (GenAction) new Actions.SetFrames(true))); WorldUtils.Gen(new Point(origin1.X + (num4 == 1 ? 1 : -4), origin1.Y - 1), (GenShape) new Shapes.Rectangle(4, 1), Actions.Chain((GenAction) new Actions.Clear(), (GenAction) new Actions.PlaceWall(buildData.Wall, true), (GenAction) new Actions.PlaceTile((ushort)19, buildData.PlatformStyle), (GenAction) new Actions.SetFrames(true))); } foreach (Point origin1 in pointList1) { WorldUtils.Gen(origin1, (GenShape) new Shapes.Rectangle(1, 3), (GenAction) new Actions.ClearTile(true)); WorldGen.PlaceTile(origin1.X, origin1.Y, 10, true, true, -1, buildData.DoorStyle); } foreach (Point origin1 in pointList2) { Shapes.Rectangle rectangle = new Shapes.Rectangle(3, 1); GenAction action = Actions.Chain((GenAction) new Actions.ClearMetadata(), (GenAction) new Actions.PlaceTile((ushort)19, buildData.PlatformStyle), (GenAction) new Actions.SetFrames(true)); WorldUtils.Gen(origin1, (GenShape)rectangle, action); } foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList2) { if (rectangle.Height > 1 && (int)GenBase._tiles[rectangle.X, rectangle.Y - 1].type != 19) { WorldUtils.Gen(new Point(rectangle.X, rectangle.Y), (GenShape) new Shapes.Rectangle(rectangle.Width, rectangle.Height), Actions.Chain((GenAction) new Actions.SetTile((ushort)124, false, true), (GenAction) new Actions.SetFrames(true))); Tile tile = GenBase._tiles[rectangle.X, rectangle.Y + rectangle.Height]; int num4 = 0; tile.slope((byte)num4); int num5 = 0; tile.halfBrick(num5 != 0); } } Point[] pointArray = new Point[7] { new Point(14, buildData.TableStyle), new Point(16, 0), new Point(18, buildData.WorkbenchStyle), new Point(86, 0), new Point(87, buildData.PianoStyle), new Point(94, 0), new Point(101, buildData.BookcaseStyle) }; foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1) { int num4 = rectangle.Width / 8; int num5 = rectangle.Width / (num4 + 1); int num6 = GenBase._random.Next(2); for (int index2 = 0; index2 < num4; ++index2) { int num7 = (index2 + 1) * num5 + rectangle.X; switch (index2 + num6 % 2) { case 0: int num8 = rectangle.Y + Math.Min(rectangle.Height / 2, rectangle.Height - 5); Vector2 vector2 = WorldGen.randHousePicture(); int x2 = (int)vector2.X; int y = (int)vector2.Y; if (!WorldGen.nearPicture(num7, num8)) { WorldGen.PlaceTile(num7, num8, x2, true, false, -1, y); break; } break; case 1: int j = rectangle.Y + 1; WorldGen.PlaceTile(num7, j, 34, true, false, -1, GenBase._random.Next(6)); for (int index3 = -1; index3 < 2; ++index3) { for (int index4 = 0; index4 < 3; ++index4) { GenBase._tiles[index3 + num7, index4 + j].frameX += (short)54; } } break; } } int num9 = rectangle.Width / 8 + 3; WorldGen.SetupStatueList(); for (; num9 > 0; --num9) { int num7 = GenBase._random.Next(rectangle.Width - 3) + 1 + rectangle.X; int num8 = rectangle.Y + rectangle.Height - 2; switch (GenBase._random.Next(4)) { case 0: WorldGen.PlaceSmallPile(num7, num8, GenBase._random.Next(31, 34), 1, (ushort)185); break; case 1: WorldGen.PlaceTile(num7, num8, 186, true, false, -1, GenBase._random.Next(22, 26)); break; case 2: int index2 = GenBase._random.Next(2, WorldGen.statueList.Length); WorldGen.PlaceTile(num7, num8, (int)WorldGen.statueList[index2].X, true, false, -1, (int)WorldGen.statueList[index2].Y); if (WorldGen.StatuesWithTraps.Contains(index2)) { WorldGen.PlaceStatueTrap(num7, num8); break; } break; case 3: Point point = Utils.SelectRandom <Point>(GenBase._random, pointArray); WorldGen.PlaceTile(num7, num8, point.X, true, false, -1, point.Y); break; } } } foreach (Microsoft.Xna.Framework.Rectangle room4 in rectangleList1) { buildData.ProcessRoom(room4); } bool flag1 = false; foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1) { int j = rectangle.Height - 1 + rectangle.Y; int Style = j > (int)Main.worldSurface ? buildData.ChestStyle : 0; int num4 = 0; while (num4 < 10 && !(flag1 = WorldGen.AddBuriedChest(GenBase._random.Next(2, rectangle.Width - 2) + rectangle.X, j, 0, false, Style))) { ++num4; } if (!flag1) { int i = rectangle.X + 2; while (i <= rectangle.X + rectangle.Width - 2 && !(flag1 = WorldGen.AddBuriedChest(i, j, 0, false, Style))) { ++i; } if (flag1) { break; } } else { break; } } if (!flag1) { foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1) { int j = rectangle.Y - 1; int Style = j > (int)Main.worldSurface ? buildData.ChestStyle : 0; int num4 = 0; while (num4 < 10 && !(flag1 = WorldGen.AddBuriedChest(GenBase._random.Next(2, rectangle.Width - 2) + rectangle.X, j, 0, false, Style))) { ++num4; } if (!flag1) { int i = rectangle.X + 2; while (i <= rectangle.X + rectangle.Width - 2 && !(flag1 = WorldGen.AddBuriedChest(i, j, 0, false, Style))) { ++i; } if (flag1) { break; } } else { break; } } } if (!flag1) { for (int index2 = 0; index2 < 1000; ++index2) { int i = GenBase._random.Next(rectangleList1[0].X - 30, rectangleList1[0].X + 30); int num4 = GenBase._random.Next(rectangleList1[0].Y - 30, rectangleList1[0].Y + 30); int num5 = num4 > (int)Main.worldSurface ? buildData.ChestStyle : 0; int j = num4; int contain = 0; int num6 = 0; int Style = num5; if (WorldGen.AddBuriedChest(i, j, contain, num6 != 0, Style)) { break; } } } if (buildData == CaveHouseBiome.BuildData.Jungle && this._sharpenerCount < GenBase._random.Next(2, 5)) { bool flag2 = false; foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1) { int j = rectangle.Height - 2 + rectangle.Y; for (int index2 = 0; index2 < 10; ++index2) { int i = GenBase._random.Next(2, rectangle.Width - 2) + rectangle.X; WorldGen.PlaceTile(i, j, 377, true, true, -1, 0); if (flag2 = GenBase._tiles[i, j].active() && (int)GenBase._tiles[i, j].type == 377) { break; } } if (!flag2) { int i = rectangle.X + 2; while (i <= rectangle.X + rectangle.Width - 2 && !(flag2 = WorldGen.PlaceTile(i, j, 377, true, true, -1, 0))) { ++i; } if (flag2) { break; } } else { break; } } if (flag2) { this._sharpenerCount = this._sharpenerCount + 1; } } if (buildData == CaveHouseBiome.BuildData.Desert && this._extractinatorCount < GenBase._random.Next(2, 5)) { bool flag2 = false; foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1) { int j = rectangle.Height - 2 + rectangle.Y; for (int index2 = 0; index2 < 10; ++index2) { int i = GenBase._random.Next(2, rectangle.Width - 2) + rectangle.X; WorldGen.PlaceTile(i, j, 219, true, true, -1, 0); if (flag2 = GenBase._tiles[i, j].active() && (int)GenBase._tiles[i, j].type == 219) { break; } } if (!flag2) { int i = rectangle.X + 2; while (i <= rectangle.X + rectangle.Width - 2 && !(flag2 = WorldGen.PlaceTile(i, j, 219, true, true, -1, 0))) { ++i; } if (flag2) { break; } } else { break; } } if (flag2) { this._extractinatorCount = this._extractinatorCount + 1; } } return(true); }
public RectangleAdorner(Shapes.Rectangle shape, IDocument document) { _Document = document; _Shape = shape; }