Exemplo n.º 1
0
 public Mobile(Texture2D model, EntitySide side, Vector2 pos, float rot, float hull, float mass)
     : base(model, side, pos, rot)
 {
     Type    = EntityType.MOBILE;
     Hull    = hull;
     MaxHull = Hull;
     Mass    = mass;
     if (Mass != 0)
     {
         MassInv = 1 / Mass;
     }
     else
     {
         MassInv = 0;
     }
     CanCollide         = true;
     CollideWithOwnSide = false;
     IsDestroyed        = false;
     DampenInnertia     = true;
     RotationWanted     = 0;
     MaxSpeed           = 401;
     ThrustAcceleration = 2000;
     VelocityWanted     = new Vector2(0, 0);
     BoundingBox        = new Rectangle(model.Bounds.X, model.Bounds.Y, model.Bounds.Width, model.Bounds.Height);
     AIRoutine          = new EntityAI(this);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a new instance of the <c>Bullet</c>.
 /// </summary>
 /// <param name="side"></param>
 /// <param name="size"></param>
 /// <param name="ttl"></param>
 public Bullet(EntitySide side, float ttl)
 {
     Side         = side;
     TTL          = ttl;
     InitVelocity = Vector2.Zero;
     IsActive     = true;
 }
Exemplo n.º 3
0
 public Vessel(Texture2D model, EntitySide side, Vector2 pos, float rot, float hull, float mass, float armor = 0)
     : base(model, side, pos, rot, hull, mass)
 {
     RotationSpeed = 6 * (float)Math.PI;
     Armor         = armor;
     Type          = EntityType.VESSEL;
 }
Exemplo n.º 4
0
 public Projectile(Texture2D model, EntitySide side, Vector2 pos, float rot, float hull, float mass)
     : base(model, side, pos, rot, hull, mass)
 {
     Type             = EntityType.PROJECTILE;
     DampenInnertia   = false;
     TimeToLive       = 6;
     InitTime         = Environment.TickCount;
     DeflectionChance = 0.0F;
 }
Exemplo n.º 5
0
 public Entity(Entity toCopy)
 {
     Side         = toCopy.Side;
     Type         = toCopy.Type;
     Model        = toCopy.Model;
     Position     = new Vector2(toCopy.Position.X, toCopy.Position.Y);
     Elasticity   = toCopy.Elasticity;
     Velocity     = new Vector2(toCopy.Velocity.X, toCopy.Velocity.Y);
     Acceleration = new Vector2(toCopy.Acceleration.X, toCopy.Acceleration.Y);
     Rotation     = toCopy.Rotation;
     Origin       = toCopy.Origin;
 }
Exemplo n.º 6
0
 public Entity(EntityInfo info, Vector2 pos, float rot)
 {
     Type         = EntityType.ENTITY;
     Model        = info.Model;
     Elasticity   = info.Elasticity;
     Side         = info.Side;
     Position     = pos;
     Rotation     = rot;
     Acceleration = new Vector2(0, 0);
     if (Model != null)
     {
         Origin = new Vector2(Model.Width / 2, Model.Height / 2);
     }
     else
     {
         Origin = new Vector2(0, 0);
     }
 }
Exemplo n.º 7
0
 public Entity(Texture2D model, EntitySide side, Vector2 pos, float rot)
 {
     Type         = EntityType.ENTITY;
     Model        = model;
     Side         = side;
     Position     = pos;
     Rotation     = rot;
     Velocity     = new Vector2(0, 0);
     Acceleration = new Vector2(0, 0);
     if (Model != null)
     {
         Origin = new Vector2(Model.Width / 2, Model.Height / 2);
     }
     else
     {
         Origin = new Vector2(0, 0);
     }
     Elasticity = 0.8F;
 }
Exemplo n.º 8
0
            private static void DrawAssociationEnd(
                DiagramPaintEventArgs e, IGeometryHost geometryHost,
                NodeShape node, PointD pointOnBorder, PointD endPoint,
                bool many, bool optional, bool id, string predicateText, ref PointF?lineEnd, bool bothOptional)
            {
                Pen                pen;
                ShapeElement       shapeHost;
                IOffsetBorderPoint offsetPointProvider;
                Font               font;
                Brush              brush;
                Graphics           g = e.Graphics;

                if (null != (shapeHost = node) &&
                    null != (offsetPointProvider = shapeHost.ShapeGeometry as IOffsetBorderPoint) &&
                    null != (pen = geometryHost.GeometryStyleSet.GetPen(DiagramPens.ConnectionLine)) &&
                    null != (font = geometryHost.GeometryStyleSet.GetFont(DiagramFonts.ConnectionLine)) &&
                    null != (brush = geometryHost.GeometryStyleSet.GetBrush(DiagramBrushes.ConnectionLineText)))
                {
                    Color restoreColor = pen.Color;
                    pen.Color = geometryHost.UpdateGeometryLuminosity(e.View, pen);
                    double angle       = GeometryUtility.CalculateRadiansRotationAngle(endPoint, pointOnBorder);
                    PointD vertexPoint = pointOnBorder;
                    vertexPoint.Offset(CrowsFootHeight * Math.Cos(angle), CrowsFootHeight * Math.Sin(angle));

                    #region draw the main line

                    Pen mainLinePen = (Pen)pen.Clone();
                    if (optional)
                    {
                        mainLinePen.DashPattern = DashPattern;
                        mainLinePen.DashOffset  = DashPattern[0];
                    }
                    if (many & optional)
                    {
                        if (!bothOptional)
                        {
                            g.DrawLine(mainLinePen, PointD.ToPointF(endPoint), PointD.ToPointF(vertexPoint));
                        }
                        else
                        {
                            lineEnd = PointD.ToPointF(vertexPoint);
                        }
                        g.DrawLine(pen, PointD.ToPointF(vertexPoint), PointD.ToPointF(pointOnBorder));
                    }
                    else
                    {
                        if (!bothOptional)
                        {
                            g.DrawLine(mainLinePen, PointD.ToPointF(endPoint), PointD.ToPointF(pointOnBorder));
                        }
                        else
                        {
                            lineEnd = PointD.ToPointF(pointOnBorder);
                        }
                    }
                    #endregion
                    #region draw crow's foot if necessary
                    if (many)
                    {
                        PointD?offsetBorderPoint = offsetPointProvider.OffsetBorderPoint(shapeHost, pointOnBorder, vertexPoint, CrowsFootHalfWidth, CrowsFootParallelMode);
                        if (offsetBorderPoint.HasValue)
                        {
                            g.DrawLine(pen, PointD.ToPointF(vertexPoint), PointD.ToPointF(offsetBorderPoint.Value));
                        }
                        offsetBorderPoint = offsetPointProvider.OffsetBorderPoint(shapeHost, pointOnBorder, vertexPoint, -CrowsFootHalfWidth, CrowsFootParallelMode);
                        if (offsetBorderPoint.HasValue)
                        {
                            g.DrawLine(pen, PointD.ToPointF(vertexPoint), PointD.ToPointF(offsetBorderPoint.Value));
                        }
                    }
                    #endregion
                    #region draw tick mark if necessary
                    if (id)
                    {
                        PointD oneMarkLeft = vertexPoint;
                        double cosAngle    = Math.Cos(angle);
                        double sinAngle    = Math.Sin(angle);

                        oneMarkLeft.Offset(InfEngInnerOneMarkOffset * cosAngle, InfEngInnerOneMarkOffset * sinAngle);
                        PointD oneMarkRight = oneMarkLeft;
                        oneMarkLeft.Offset(-InfEngMarkerHalfWidth * sinAngle, InfEngMarkerHalfWidth * cosAngle);
                        oneMarkRight.Offset(InfEngMarkerHalfWidth * sinAngle, -InfEngMarkerHalfWidth * cosAngle);

                        g.DrawLine(pen, PointD.ToPointF(oneMarkLeft), PointD.ToPointF(oneMarkRight));
                    }
                    #endregion
                    #region draw text

                    //determine the line's properties
                    double         edgeX = pointOnBorder.X;
                    double         edgeY = pointOnBorder.Y;
                    EntitySideType whichSideShapeIsOn = EntitySide.FindWhichSide(pointOnBorder, shapeHost.GeometryBoundingBox);
                    double         w = 0;            //, y = 0;
                    angle = Math.Atan2(Math.Abs(endPoint.Y - edgeY), Math.Abs(endPoint.X - edgeX));
                    double inDegrees = angle * 180 / Math.PI;
                    if (inDegrees < 0)
                    {
                        inDegrees += 360;
                    }

                    SizeF textSize = g.MeasureString(predicateText, font);
                    w = textSize.Width;
                    //y = Math.Abs(w * Math.Tan(angle));

                    //determine what to offset
                    double textX      = edgeX;
                    double textY      = edgeY;
                    double h          = textSize.Height;
                    bool   lessThan45 = inDegrees < 45;

                    switch (whichSideShapeIsOn)
                    {
                    case EntitySideType.OnBottom:
                        textY -= TextPaddingY + h;
                        if (lessThan45)
                        {
                            textX += TextPaddingX;
                        }
                        else
                        {
                            textX -= TextPaddingX + w;
                        }
                        break;

                    case EntitySideType.OnTop:
                        textY += TextPaddingY;
                        if (lessThan45)
                        {
                            textX -= TextPaddingX + w;
                        }
                        else
                        {
                            textX += TextPaddingX;
                        }
                        break;

                    case EntitySideType.OnLeft:
                        textX += TextPaddingX;
                        if (lessThan45)
                        {
                            textY -= TextPaddingY + h;
                        }
                        else
                        {
                            textY += TextPaddingY;
                        }
                        break;

                    case EntitySideType.OnRight:
                        textX -= TextPaddingX + w;
                        if (lessThan45)
                        {
                            textY += TextPaddingY;
                        }
                        else
                        {
                            textY -= TextPaddingY + h;
                        }
                        break;
                    }

                    //perform the drawing
                    g.DrawString(predicateText, font, brush, new PointF((float)textX, (float)textY));

                    #endregion

                    pen.Color = restoreColor;
                }
            }
Exemplo n.º 9
0
 /// <summary>
 /// Creates a new instance of the <c>SinBullet</c>.
 /// </summary>
 /// <param name="side"></param>
 /// <param name="ttl"></param>
 /// <param name="speed"></param>
 /// <param name="up"></param>
 /// <param name="reversed"></param>
 public SinBullet(EntitySide side, float ttl, float speed, bool up, bool reversed) : base(side, ttl)
 {
     this.reversed = reversed;
     isUp          = up;
     SPEED         = speed;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Creates a new instance of the asteroid
 /// </summary>
 /// <param name="side"></param>
 /// <param name="ttl"></param>
 /// <param name="velocity"></param>
 public Asteroid(EntitySide side, float ttl, Vector2 velocity) : base(side, ttl, velocity)
 {
 }
Exemplo n.º 11
0
 public Ancestor(Texture2D model, EntitySide side, Vector2 pos, float rot, float hull, float mass)
     : base(model, side, pos, rot, hull, mass)
 {
 }
Exemplo n.º 12
0
 public Explosion(AnimatedTexture anim, EntitySide side, Vector2 pos, float rot)
     : base(null, side, pos, rot)
 {
     AnimTexture = anim;
     timeAlive   = 0;
 }
Exemplo n.º 13
0
 public SuicideVessel(Texture2D model, EntitySide side, Vector2 pos, float rot, float hull, float mass, float armor, float expDamage, float expRad)
     : base(model, side, pos, rot, hull, mass, armor)
 {
     ExplosionDamage = expDamage;
     ExplosionRadius = expRad;
 }
Exemplo n.º 14
0
 SeekingProjectile(Texture2D model, EntitySide side, Vector2 pos, float rot, float hull, float mass)
     : base(model, side, pos, rot, hull, mass)
 {
 }
Exemplo n.º 15
0
 public LinearBullet(EntitySide side, float ttl, Vector2 velocity) : base(side, ttl)
 {
     Velocity = velocity;
     Rotation = (float)Math.Atan2(velocity.Y, velocity.X);
 }