public PhysicObj(Vector2 position, PathFinderNodeType nodeType = PathFinderNodeType.OTHER) : base(OffSet.Center) { velocity = 0; body = BodyFactory.CreateBody(KingOfThePit.ptr.world); body.Position = position * KingOfThePit.pixelToMeter; body.BodyType = BodyType.Dynamic; body.FixedRotation = true; body.LinearDamping = 0.02f; body.AngularDamping = 1; pathNodeType = nodeType; }
public PhysicObj(Body body, Vector2 position) : base(OffSet.Center) { velocity = 0; this.body = body; this.body.Position = position * KingOfThePit.pixelToMeter; this.body.BodyType = BodyType.Dynamic; this.body.FixedRotation = true; this.body.LinearDamping = 1; this.body.AngularDamping = 1; this.length = 0; pathNodeType = PathFinderNodeType.OTHER; }
public PhysicObj(Body body, Vector2 position) : base(OffSet.BottomCenterHorizontal) { velocity = 0; this.body = body; this.body.Position = position * Bloodbender.pixelToMeter; this.body.BodyType = BodyType.Dynamic; this.body.FixedRotation = true; this.body.LinearDamping = 1; this.body.AngularDamping = 1; this.length = 0; pathNodeType = PathFinderNodeType.OTHER; pathFinderNodes = new List <PathFinderNode>(); }
private void PathFinderDebug(int parentX, int parentY, int x, int y, PathFinderNodeType type, int totalCost, int cost) { if (InvokeRequired) { while (mPaused) { Thread.Sleep(100); } Invoke(new PathFinderDebugDelegate(PathFinderDebug), new object[] { parentX, parentY, x, y, type, totalCost, cost }); return; } matrix_Base.DrawDebug(parentX, parentY, x, y, type, totalCost, cost); }
public void DrawGrid(int x, int y, PathFinderNodeType type) { Graphics g = Graphics.FromHwnd(this.Handle); Rectangle inR = new Rectangle(x * gridSize, y * gridSize, gridSize, gridSize); Color c = Color.Empty; switch (type) { case PathFinderNodeType.Close: c = Color.DarkSlateBlue; break; case PathFinderNodeType.Current: c = Color.Red; break; case PathFinderNodeType.End: c = Color.Red; break; case PathFinderNodeType.Open: c = Color.Gray; break; case PathFinderNodeType.Path: c = Color.Blue; break; case PathFinderNodeType.Start: c = Color.Green; break; } using (Brush brush = new SolidBrush(c)) { g.FillRectangle(brush, inR); } c = Color.Black; using (Pen pen = new Pen(c)) { g.DrawLine(pen, x * gridSize, y * gridSize, x * gridSize + gridSize, y * gridSize); g.DrawLine(pen, x * gridSize + gridSize, y * gridSize, x * gridSize + gridSize, y * gridSize + gridSize); g.DrawLine(pen, x * gridSize, y * gridSize, x * gridSize, y * gridSize + gridSize); g.DrawLine(pen, x * gridSize + gridSize, y * gridSize, x * gridSize + gridSize, y * gridSize + gridSize); } g.Dispose(); }
public PhysicObj(Vector2 position, PathFinderNodeType nodeType = PathFinderNodeType.OTHER) : base(OffSet.BottomCenterHorizontal) { velocity = 0; body = BodyFactory.CreateBody(Bloodbender.ptr.world); body.Position = position * Bloodbender.pixelToMeter; body.BodyType = BodyType.Dynamic; body.FixedRotation = true; body.LinearDamping = 0.02f; body.AngularDamping = 1; pathFinderNodes = new List <PathFinderNode>(); pathNodeType = nodeType; if (nodeType == PathFinderNodeType.CENTER) { pathFinderNodes.Add(new PathFinderNode(position, this)); } //foreach (PathFinderNode node in pathFinderNodes) //Bloodbender.ptr.pathFinder.addNode(node); }
public void DebugPathFinder(int fromX, int fromY, int x, int y, PathFinderNodeType type, int totalCost, int cost) { Console.WriteLine("({0},{1}) -> ({2},{3}): Costs {4}", fromX, fromY, x, y, cost); }
public void DrawDebug(int parentX, int parentY, int x, int y, PathFinderNodeType type, int totalCost, int cost) { Color c = Color.Empty; switch (type) { case PathFinderNodeType.Close: c = Color.DarkSlateBlue; break; case PathFinderNodeType.Current: c = Color.Red; break; case PathFinderNodeType.End: c = Color.Red; break; case PathFinderNodeType.Open: c = Color.Green; break; case PathFinderNodeType.Path: c = Color.Blue; break; case PathFinderNodeType.Start: c = Color.Green; break; } try { Graphics g = Graphics.FromHwnd(this.Handle); Rectangle internalRec = new Rectangle((x * mGridSize) + 2, (y * mGridSize) + 2, mGridSize - 4, mGridSize - 4); if (type == PathFinderNodeType.Open) { using (Brush brush = new SolidBrush(Color.FromArgb(255, 240, 240, 240))) g.FillRectangle(brush, internalRec); } using (Pen pen = new Pen(c, 2)) g.DrawRectangle(pen, internalRec); if (type == PathFinderNodeType.Open) { g.DrawLine(Pens.Brown, (parentX * mGridSize) + mGridSize / 2, (parentY * mGridSize) + mGridSize / 2, (x * mGridSize) + mGridSize / 2, (y * mGridSize) + mGridSize / 2); } if (type == PathFinderNodeType.Path) { using (Brush brush = new SolidBrush(c)) g.FillRectangle(brush, internalRec); } if (totalCost != -1) { internalRec.Inflate(new Size(1, 1)); internalRec.Height /= 2; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; using (Font f = new System.Drawing.Font("Verdana", 0.29F * mGridSize, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)))) g.DrawString(totalCost.ToString(), f, Brushes.Black, (RectangleF)internalRec); internalRec.Y += internalRec.Height; using (Font f = new System.Drawing.Font("Verdana", 0.29F * mGridSize, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)))) g.DrawString(cost.ToString(), f, Brushes.HotPink, (RectangleF)internalRec); } g.Dispose(); } catch (Exception) { } }
public void DrawDebug0(int parentX, int parentY, int x, int y, PathFinderNodeType type, int totalCost, int cost) { Color c = Color.Empty; switch(type) { case PathFinderNodeType.Close: c = Color.DarkSlateBlue; break; case PathFinderNodeType.Current: c = Color.Yellow; break; case PathFinderNodeType.End: // if (true) return; c = Color.Red; break; case PathFinderNodeType.Open: c = Color.Green; break; case PathFinderNodeType.Path: c = Color.Blue; break; case PathFinderNodeType.Start: c = Color.Green; break; } try { var g = Graphics.FromHwnd(this.Handle); Rectangle internalRec = new Rectangle((x * mGridSize) + 2, (TRANSPOSE(y) * mGridSize) + 2, mGridSize - 4, mGridSize - 4); if (type == PathFinderNodeType.Open) using (Brush brush = new SolidBrush(Color.FromArgb(255,240,240,240))) g.FillRectangle(brush, internalRec); using (Pen pen = new Pen(c)) g.DrawRectangle(pen, internalRec); // if (type == PathFinderNodeType.Open) // g.DrawLine(Pens.Brown, (parentX * mGridSize) + mGridSize / 2, (TRANSPOSE(parentY) * mGridSize) + mGridSize / 2, (x * mGridSize) + mGridSize / 2, (TRANSPOSE(y) * mGridSize) + mGridSize / 2); if (type == PathFinderNodeType.Path) using (Brush brush = new SolidBrush(c)) g.FillRectangle(brush, internalRec); if (totalCost != -1) { internalRec.Inflate(new Size(1,1)); internalRec.Height /= 2; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; using (Font f = new System.Drawing.Font("Verdana", 0.29F * mGridSize, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)))) g.DrawString(totalCost.ToString(), f, Brushes.Black, (RectangleF) internalRec); internalRec.Y += internalRec.Height; using (Font f = new System.Drawing.Font("Verdana", 0.29F * mGridSize, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)))) g.DrawString(cost.ToString(), f, Brushes.Black, (RectangleF) internalRec); } g.Dispose(); } catch(Exception){} }
void PathFinder_PathFinderDebug(int fromX, int fromY, int x, int y, PathFinderNodeType type, int totalCost, float cost) { // Console.WriteLine("{0}&{1}to{2}&{3} total {4} cost {5}", fromX, fromY, x, y, totalCost, cost); }
public void DebugPathFinder(int fromX, int fromY, int x, int y, PathFinderNodeType type, int totalCost, int cost) { Console.WriteLine("({0},{1}) -> ({2},{3}): Costs {4}",fromX,fromY,x,y,cost); }
protected void OnPathFinderDebug(PathFinderNode node, PathFinderNodeType type) { #if DEBUG _pathFinderDebug?.Invoke(node, type); #endif }
private void PathFinderDebug(int x, int y, PathFinderNodeType type) { grid2.DrawGrid(x, y, type); }
private void PathFinderDebug(int parentX, int parentY, int x, int y, PathFinderNodeType type, int totalCost, int cost) { if (InvokeRequired) { while (mPaused) Thread.Sleep(100); Thread.Sleep(mDelay); Invoke(new PathFinderDebugDelegate(PathFinderDebug), new object[] { parentX, parentY, x, y, type, totalCost, cost }); return; } PnlGUI.DrawDebug0(parentX, parentY, x, y, type, totalCost, cost); }