void Reborn() { Position = new CoordPoint(-12100, 12100); //acceleration = 0; direction = new CoordPoint(1, 0); Velosity = new CoordPoint(-50,-50); Calculator= new TrajectoryCalculator(this); }
protected internal override void Step() { if(starRotation >= 2 * Math.PI) starRotation = 0; Position = new CoordPoint((float)(DistanceToSun * Math.Cos(starRotation) + RotateCenter.Position.X), (float)(DistanceToSun * Math.Sin(starRotation) + RotateCenter.Position.Y)); starRotation += clockwise ? .0001f : -.0001f; selfRotation += .005f; }
void TaskLeaveDeathZone(GameObject obj) { // set target location as end of vector, normal to strait vector from center of danger obj CoordPoint toTarget = targetObject.Position - owner.Position; CoordPoint leaveVector = (owner.Position - obj.Position) * 2; if(Math.Abs(leaveVector.AngleTo(toTarget)) < Math.PI / 8) targetLocation = targetObject.Position; else { CoordPoint v1 = new CoordPoint(-leaveVector.Y, leaveVector.X); CoordPoint v2 = new CoordPoint(leaveVector.Y, -leaveVector.X); float a1 = Math.Abs(v1.AngleTo(toTarget)); float a2 = Math.Abs(v2.AngleTo(toTarget)); CoordPoint normalVector = a1 < a2 ? v1 : v2; targetLocation = leaveVector + normalVector + owner.Position; } }
public static void Pressed(CoordPoint coordPoint) { if(pressCoolDown < 0) pressCoolDown++; else { pressCoolDown = -10; // var ship = new Ship(instance.ships[0], instance.StarSystems[0]); //ship.Position = coordPoint; //instance.ships.Add(ship); } }
public CoordPoint World2ScreenPoint(CoordPoint wrlPoint) { double unitFactorX = Bounds.Width > 0 ? PxlWidth / Bounds.Width : 0; double unitFactorY = Bounds.Height > 0 ? PxlHeight / Bounds.Height : 0; return new CoordPoint((wrlPoint.X - Bounds.LeftTop.X) * unitFactorX, (wrlPoint.Y - Bounds.LeftTop.Y) * unitFactorY); }
public Slot(CoordPoint relativeLocation, ShipHull hull, SlotType type) { this.relativeLocation = relativeLocation; Hull = hull; Type = type; }
public float AngleTo(CoordPoint vector) { var x2 = vector.X; var y2 = vector.Y; var dot = X * x2 + Y * y2; var det = X * y2 - Y * x2; var angle = Math.Atan2(det, dot); //var angle = (Math.Atan2(0 - X, Y - (-1))); return -(float)angle; }
public CoordPoint(CoordPoint vector) { X = vector.X; Y = vector.Y; }
protected internal virtual void Step() { Position += Velosity; }
//public bool isIntersect(Bounds obj) { // return (Math.Abs(LeftTop.X - obj.LeftTop.X) * 2 < (Width + obj.Width)) && // (Math.Abs(LeftTop.Y - obj.LeftTop.Y) * 2 < (Height + obj.Height)); //} public bool Contains(CoordPoint p) { return this.LeftTop.X <= p.X && LeftTop.Y <= p.Y && RightBottom.X >= p.X && RightBottom.Y > p.Y; }
public Bounds(float x, float y, float w, float h) { LeftTop = new CoordPoint(x, y); RightBottom = new CoordPoint(x + w, y + h); }
public Bounds(CoordPoint lt, CoordPoint rb) { LeftTop = lt; RightBottom = rb; }
public Body(CoordPoint location, float radius, StarSystem system) : base(system) { this.radius = radius; Position = location; Mass = radius * 2; }
public static CoordPoint GetSummaryAttractingForce(List<Body> objects, GameObject subject) { var vector = new CoordPoint(); foreach(var obj in objects) vector += GravitationForceVector(subject, obj); return vector; }
void TaskDecreaseSpeed() { targetLocation = owner.Position - owner.Velosity.UnaryVector; }
void TaskGoToTarget() { targetLocation = targetObject.Position; }
public AttachedItem(CoordPoint size, CoordPoint origin) : base(size, origin) { }
public Item(CoordPoint size, CoordPoint origin) { //TODO implement in children Size = size; Origin = origin; }
internal static Vector2 CoordPoint2Vector(CoordPoint point) { return new Vector2(point.X, point.Y); }
public Circle(CoordPoint position, float radius) { Position = position; this.radius = radius; }
public Viewport(float x, float y, float w, float h) { Centerpoint = new CoordPoint(x, y); pxlWidth = w; pxlHeight = h; }
internal CoordPoint GetRotated(float angle) { CoordPoint res = new CoordPoint(X, Y); res.Rotate(angle); return res; }
public CoordPoint Screen2WorldPoint(CoordPoint scrPoint) { double pixelFactorX = PxlWidth > 0 ? Bounds.Width / PxlWidth : 0; double pixelFactorY = PxlHeight > 0 ? Bounds.Width / PxlWidth : 0; return new CoordPoint(scrPoint.X * pixelFactorX + Bounds.LeftTop.X, scrPoint.Y * pixelFactorY + Bounds.LeftTop.Y); }
public static float Distance(CoordPoint p1, CoordPoint p2) { return (float)Math.Sqrt(Math.Pow(p1.X - p2.X, 2) + Math.Pow(p1.Y - p2.Y, 2)); }
public VirtualObject(StarSystem system, float mass, CoordPoint position, CoordPoint velosity) : base(system) { Position = position; Mass = mass; Velosity = velosity; }