Пример #1
0
 void Reborn() {
     Position = new CoordPoint(-12100, 12100);
     //acceleration = 0;
     direction = new CoordPoint(1, 0);
     Velosity = new CoordPoint(-50,-50);
     Calculator= new TrajectoryCalculator(this);
 }
Пример #2
0
        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;

        }
Пример #3
0
        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;
            }
        }
Пример #4
0
 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);
     }
 }
Пример #5
0
 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);
 }
Пример #6
0
 public Slot(CoordPoint relativeLocation, ShipHull hull, SlotType type) {
     this.relativeLocation = relativeLocation;
     Hull = hull;
     Type = type;
 }
Пример #7
0
        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;
        }
Пример #8
0
 public CoordPoint(CoordPoint vector) {
     X = vector.X;
     Y = vector.Y;
 }
Пример #9
0
 protected internal virtual void Step() {
     Position += Velosity;
 }
Пример #10
0
 //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;
 }
Пример #11
0
 public Bounds(float x, float y, float w, float h) {
     LeftTop = new CoordPoint(x, y);
     RightBottom = new CoordPoint(x + w, y + h);
 }
Пример #12
0
 public Bounds(CoordPoint lt, CoordPoint rb) {
     LeftTop = lt;
     RightBottom = rb;
 }
Пример #13
0
 public Body(CoordPoint location, float radius, StarSystem system) : base(system) {
     this.radius = radius;
     Position = location;
     Mass = radius * 2;
 }
Пример #14
0
 public static CoordPoint GetSummaryAttractingForce(List<Body> objects, GameObject subject) {
     var vector = new CoordPoint();
     foreach(var obj in objects)
         vector += GravitationForceVector(subject, obj);
     return vector;
 }
Пример #15
0
        void TaskDecreaseSpeed() {

            targetLocation = owner.Position - owner.Velosity.UnaryVector;
        }
Пример #16
0
 void TaskGoToTarget() {
     targetLocation = targetObject.Position;
 }
Пример #17
0
        public AttachedItem(CoordPoint size, CoordPoint origin) : base(size, origin) {

        }
Пример #18
0
 public Item(CoordPoint size, CoordPoint origin) { //TODO implement in children
     Size = size;
     Origin = origin;
 }
Пример #19
0
 internal static Vector2 CoordPoint2Vector(CoordPoint point) {
     return new Vector2(point.X, point.Y);
 }
Пример #20
0
 public Circle(CoordPoint position, float radius) {
     Position = position;
     this.radius = radius;
 }
Пример #21
0
 public Viewport(float x, float y, float w, float h) {
     Centerpoint = new CoordPoint(x, y);
     pxlWidth = w;
     pxlHeight = h;
 }
Пример #22
0
 internal CoordPoint GetRotated(float angle) {
     CoordPoint res = new CoordPoint(X, Y);
     res.Rotate(angle);
     return res;
 }
Пример #23
0
 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);
 }
Пример #24
0
 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));
 }
Пример #25
0
 public VirtualObject(StarSystem system, float mass, CoordPoint position, CoordPoint velosity) : base(system) {
     Position = position;
     Mass = mass;
     Velosity = velosity;
 }