public SecretRoomCommand(PointReceiver pointReceiver) : base(pointReceiver) { AddCommand(new SecretBumperCommand(_pointReceiver)); AddCommand(new SecretBumperCommand(_pointReceiver)); AddCommand(new SecretBumperCommand(_pointReceiver)); AddCommand(new ShooterCommand(_pointReceiver)); }
public override void ComputeLinePoints(PointReceiver output) { int pixels = (int)(Length / output.SampleDistance); if (pixels <= 0) { pixels = 1; } // Run along the line as a 0-1 progression value. float deltaProgress = 1f / (float)pixels; float c = deltaProgress; // Step pixel count times: for (int i = 0; i < pixels; i++) { // From http://www.w3.org/TR/SVG/implnote.html#ArcParameterizationAlternatives float angle = StartAngle + (SweepAngle * c); float ellipseComponentX = RadiusX * (float)Math.Cos(angle); float ellipseComponentY = RadiusY * (float)Math.Sin(angle); float x = CosXAxis * ellipseComponentX - SinXAxis * ellipseComponentY + CenterX; float y = SinXAxis * ellipseComponentX + CosXAxis * ellipseComponentY + CenterY; output.AddPoint(x, y); c += deltaProgress; } }
public override void ComputeLinePoints(PointReceiver output) { // Get previous: float previousX = Previous.X; float previousY = Previous.Y; // Get deltas: float dx; float dy; float extrudeBy = output.ExtrudeBy; if (extrudeBy == 0f) { dx = X - previousX; dy = Y - previousY; } else { previousX += Previous.NormalX * extrudeBy; previousY += Previous.NormalY * extrudeBy; dx = X + (NormalX * extrudeBy) - previousX; dy = Y + (NormalY * extrudeBy) - previousY; } // Divide length by the amount we advance per pixel to get the number of pixels on this line: int pixels = (int)(Length / output.SampleDistance); if (pixels <= 0) { pixels = 1; } // Run along the line as a 0-1 progression value. float deltaProgress = 1f / (float)pixels; // From but not including previous: float progressX = deltaProgress * dx; float progressY = deltaProgress * dy; // Figure out the first point: float pointX = previousX + progressX; float pointY = previousY + progressY; // For each of the pixels: for (int i = 0; i < pixels; i++) { // Add it: output.AddPoint(pointX, pointY); // Move: pointX += progressX; pointY += progressY; } }
public override void ComputeLinePoints(PointReceiver output) { // Divide length by the amount we advance per pixel to get the number of pixels on this line: int pixels = (int)(Length / output.SampleDistance); if (pixels <= 0) { pixels = 1; } // Run along the line as a 0-1 progression value. float deltaProgress = 1f / (float)pixels; // From but not including previous: float t = deltaProgress; float x = X; float y = Y; float previousX = Previous.X; float previousY = Previous.Y; float control1X3 = Control1X * 3f; float control2X3 = Control2X * 3f; float control1Y3 = Control1Y * 3f; float control2Y3 = Control2Y * 3f; float previousX3 = previousX * 3f; float previousY3 = previousY * 3f; // For each of the pixels: for (int i = 0; i < pixels; i++) { float tSquare = t * t; float tCube = tSquare * t; float pointX = previousX + (-previousX3 + t * (previousX3 - previousX * t)) * t + (control1X3 + t * (-2f * control1X3 + control1X3 * t)) * t + (control2X3 - control2X3 * t) * tSquare + x * tCube; float pointY = previousY + (-previousY3 + t * (previousY3 - previousY * t)) * t + (control1Y3 + t * (-2f * control1Y3 + control1Y3 * t)) * t + (control2Y3 - control2Y3 * t) * tSquare + y * tCube; // Add it: output.AddPoint(pointX, pointY); // Move progress: t += deltaProgress; } }
/// <summary>Steps along the line between this point and previous point at a fixed step, adding the points to the scanner as it goes.</summary> public override void ComputeLinePoints(PointReceiver output) { float extrudeBy = output.ExtrudeBy; // Let the scanner know this is a MoveTo: if (extrudeBy == 0f) { output.MoveTo(X, Y); } else { output.MoveTo(X + (NormalX * extrudeBy), Y + (NormalY * extrudeBy)); } }
public override void ComputeLinePoints(PointReceiver output) { // Get previous: float x = X; float y = Y; float previousX = Previous.X; float previousY = Previous.Y; float control1X2 = Control1X * 2f; float control1Y2 = Control1Y * 2f; // Divide length by the amount we advance per pixel to get the number of pixels on this line: int pixels = (int)(Length / output.SampleDistance); if (pixels <= 0) { pixels = 1; } // Run along the line as a 0-1 progression value. float deltaProgress = 1f / (float)pixels; // From but not including previous: float t = deltaProgress; float invert = (1f - t); // For each of the pixels: for (int i = 0; i < pixels; i++) { float tSquare = t * t; float controlFactor = t * invert; float invertSquare = invert * invert; // Figure out the point: float pointX = invertSquare * previousX + controlFactor * control1X2 + tSquare * x; float pointY = invertSquare * previousY + controlFactor * control1Y2 + tSquare * y; // Add it: output.AddPoint(pointX, pointY); // Move progress: t += deltaProgress; invert -= deltaProgress; } }
public override void ComputeLinePoints(PointReceiver output) { float radius = Radius; // How much must we rotate through overall? float angleToRotateThrough = EndAngle - StartAngle; // So arc length is how many pixels long the arc is. // Thus to step that many times, our delta angle is.. float deltaAngle = angleToRotateThrough / Length; // The current angle: float currentAngle = StartAngle; // The number of pixels: int pixelCount = (int)Math.Ceiling(Length); if (pixelCount < 0) { // Going anti-clockwise. Invert deltaAngle and the pixel count: deltaAngle = -deltaAngle; pixelCount = -pixelCount; } // Step pixel count times: for (int i = 0; i < pixelCount; i++) { // Map from polar angle to coords: float x = radius * (float)Math.Cos(currentAngle); float y = radius * (float)Math.Sin(currentAngle); x += CircleCenterX; y += CircleCenterY; output.AddPoint(x, y); // Rotate the angle: currentAngle += deltaAngle; } }
/// <summary>Steps along the line between this point and previous point at a fixed step, adding the points to the scanner as it goes.</summary> public virtual void ComputeLinePoints(PointReceiver output) { }
public UndergroundTargetCommand(PointReceiver pointReceiver) { _pointReceiver = pointReceiver; }
//--------------------------------------
public ShooterCommand(PointReceiver pointReceiver) { _pointReceiver = pointReceiver; }
public override void ComputeLinePoints(PointReceiver output){ // Get previous: float previousX=Previous.X; float previousY=Previous.Y; // Get deltas: float dx; float dy; float extrudeBy=output.ExtrudeBy; if(extrudeBy==0f){ dx=X-previousX; dy=Y-previousY; }else{ previousX+=Previous.NormalX * extrudeBy; previousY+=Previous.NormalY * extrudeBy; dx=X + (NormalX * extrudeBy) - previousX; dy=Y + (NormalY * extrudeBy) - previousY; } // Divide length by the amount we advance per pixel to get the number of pixels on this line: int pixels=(int)(Length/output.SampleDistance); if(pixels<=0){ pixels=1; } // Run along the line as a 0-1 progression value. float deltaProgress=1f/(float)pixels; // From but not including previous: float progressX=deltaProgress * dx; float progressY=deltaProgress * dy; // Figure out the first point: float pointX=previousX + progressX; float pointY=previousY + progressY; // For each of the pixels: for(int i=0;i<pixels;i++){ // Add it: output.AddPoint(pointX,pointY); // Move: pointX+=progressX; pointY+=progressY; } }
protected CompositeCommand(PointReceiver pointReceiver) { _commands = new List <ICommand>(); _pointReceiver = pointReceiver; }
public RampCommand(PointReceiver pointReceiver) { _pointReceiver = pointReceiver; }
public override void ComputeLinePoints(PointReceiver output){ float radius=Radius; // How much must we rotate through overall? float angleToRotateThrough=EndAngle-StartAngle; // So arc length is how many pixels long the arc is. // Thus to step that many times, our delta angle is.. float deltaAngle=angleToRotateThrough/Length; // The current angle: float currentAngle=StartAngle; // The number of pixels: int pixelCount=(int)Math.Ceiling(Length); if(pixelCount<0){ // Going anti-clockwise. Invert deltaAngle and the pixel count: deltaAngle=-deltaAngle; pixelCount=-pixelCount; } // Step pixel count times: for(int i=0;i<pixelCount;i++){ // Map from polar angle to coords: float x=radius * (float) Math.Cos(currentAngle); float y=radius * (float) Math.Sin(currentAngle); x+=CircleCenterX; y+=CircleCenterY; output.AddPoint(x,y); // Rotate the angle: currentAngle+=deltaAngle; } }
public BumperCommand(PointReceiver pointReceiver) { _pointReceiver = pointReceiver; }
public HoleCommand(PointReceiver pointReceiver) : base(pointReceiver) { AddCommand(new UndergroundTargetCommand(_pointReceiver)); AddCommand(new ShooterCommand(_pointReceiver)); }
public TargetCommand(PointReceiver pointReceiver) { _pointReceiver = pointReceiver; }
public override void ComputeLinePoints(PointReceiver output){ // Divide length by the amount we advance per pixel to get the number of pixels on this line: int pixels=(int)(Length/output.SampleDistance); if(pixels<=0){ pixels=1; } // Run along the line as a 0-1 progression value. float deltaProgress=1f/(float)pixels; // From but not including previous: float t=deltaProgress; float x; float y; float previousX; float previousY; float control1X3=Control1X*3f; float control2X3=Control2X*3f; float control1Y3=Control1Y*3f; float control2Y3=Control2Y*3f; float extrudeBy=output.ExtrudeBy; if(extrudeBy==0f){ x=X; y=Y; previousX=Previous.X; previousY=Previous.Y; }else{ x=X + (NormalX * extrudeBy); y=Y + (NormalY * extrudeBy); previousX=Previous.X + (Previous.NormalX * extrudeBy); previousY=Previous.Y + (Previous.NormalY * extrudeBy); extrudeBy*=3f; control1X3+=(NormalC1X * extrudeBy); control1Y3+=(NormalC1Y * extrudeBy); control2X3+=(NormalC2X * extrudeBy); control2Y3+=(NormalC2Y * extrudeBy); } float previousX3=previousX*3f; float previousY3=previousY*3f; // For each of the pixels: for(int i=0;i<pixels;i++){ float tSquare=t*t; float tCube=tSquare*t; float pointX = previousX + (-previousX3 + t * (previousX3 - previousX * t)) * t + (control1X3 + t * (-2f * control1X3 + control1X3 * t)) * t + (control2X3 - control2X3 * t) * tSquare + x * tCube; float pointY = previousY + (-previousY3 + t * (previousY3 - previousY * t)) * t + (control1Y3 + t * (-2f * control1Y3 + control1Y3 * t)) * t + (control2Y3 - control2Y3 * t) * tSquare + y * tCube; // Add it: output.AddPoint(pointX,pointY); // Move progress: t+=deltaProgress; } }
/// <summary>Steps along the line between this point and previous point at a fixed step, adding the points to the scanner as it goes.</summary> public override void ComputeLinePoints(PointReceiver output) { output.MoveTo(X, Y); }
public override void ComputeLinePoints(PointReceiver output){ // Get previous: float x; float y; float previousX; float previousY; float control1X2=Control1X * 2f; float control1Y2=Control1Y * 2f; float extrudeBy=output.ExtrudeBy; if(extrudeBy==0f){ x=X; y=Y; previousX=Previous.X; previousY=Previous.Y; }else{ x=X + (NormalX * extrudeBy); y=Y + (NormalY * extrudeBy); previousX=Previous.X + (Previous.NormalX * extrudeBy); previousY=Previous.Y + (Previous.NormalY * extrudeBy); extrudeBy*=2f; control1X2+=(NormalC1X * extrudeBy); control1Y2+=(NormalC1Y * extrudeBy); } // Divide length by the amount we advance per pixel to get the number of pixels on this line: int pixels=(int)(Length/output.SampleDistance); if(pixels<=0){ pixels=1; } // Run along the line as a 0-1 progression value. float deltaProgress=1f/(float)pixels; // From but not including previous: float t=deltaProgress; float invert=(1f-t); // For each of the pixels: for(int i=0;i<pixels;i++){ float tSquare=t*t; float controlFactor=t*invert; float invertSquare=invert*invert; // Figure out the point: float pointX=invertSquare*previousX + controlFactor*control1X2 + tSquare*x; float pointY=invertSquare*previousY + controlFactor*control1Y2 + tSquare*y; // Add it: output.AddPoint(pointX,pointY); // Move progress: t+=deltaProgress; invert-=deltaProgress; } }