Beispiel #1
0
 private LaserBullet(double mass, double angularMass, double power, TimeSpan timeToLive)
     : base(
         mass,
         angularMass,
         PolygonGeometry.FromRectangle(new Rect(Vector.Zero, new Size(0.35, 0.35))),
         new ReferenceArea(0.0),
         power,
         timeToLive)
 {
 }
Beispiel #2
0
        public HomingRocket(Plane target)
            : base(
                20,
                50,
                PolygonGeometry.FromRectangle(new Rect(Vector.Zero, new Size(2, 6.4))),
                null,
                200,
                TimeSpan.FromSeconds(30))
        {
            Target = target;

            m_maxRotationVelocity = 10;
        }
Beispiel #3
0
        private void DrawDebugInfo()
        {
            GeometryDrawer debugGeomertyDrawer =
                new GeometryDrawer(
                    //Game.Content.Load<Texture2D>("Debug/line"),
                    Game.Content.Load <Texture2D>("Debug/pixel"),
                    Game.Content.Load <Texture2D>("Debug/point2"),
                    Game.Content.Load <SpriteFont>("Fonts/debug"));

            using (var handle = m_safeDrawableGameComponents.SafeRead())
            {
                foreach (var drawableObj in handle.Items)
                {
                    if (drawableObj is DrawableGameObject)
                    {
                        GameObject gameObject = ((DrawableGameObject)drawableObj).GameObject;

                        debugGeomertyDrawer.Draw(m_spriteBatch, m_coordinatesTransformer, gameObject.CalculateAbsoluteGeometry());

                        if (gameObject is Plane && gameObject is IHaveEquipment <PlaneEquipment> )
                        {
                            foreach (var equipment in ((IHaveEquipment <PlaneEquipment>)gameObject).AllEquipment)
                            {
                                var equipmentGeometry = PolygonGeometry.FromRectangle(new Rect(Vector.Zero, equipment.Size));
                                equipmentGeometry.Rotate(equipment.GetAbsoluteRotation());
                                equipmentGeometry.Translate(equipment.GetAbsolutePosition());

                                debugGeomertyDrawer.Draw(m_spriteBatch, m_coordinatesTransformer, equipmentGeometry, drawCenter: false);
                            }
                        }
                    }
                    else if (drawableObj is DrawableStaticObject)
                    {
                        StaticObject staticObject = ((DrawableStaticObject)drawableObj).StaticObject;

                        debugGeomertyDrawer.Draw(m_spriteBatch, m_coordinatesTransformer, staticObject.AbsoluteGeometry);
                    }
                }
            }
        }
Beispiel #4
0
        public void Draw(SpriteBatch spriteBatch, CoordinatesTransformer coordinatesTransformer, Geometry geometry, bool drawCenter = true)
        {
            if (drawCenter)
            {
                spriteBatch.DrawString(
                    m_font,
                    geometry.Center.ToString(),
                    coordinatesTransformer.Transform(geometry.Center).Round(),
                    Color.Yellow);

                spriteBatch.Draw(
                    m_point,
                    coordinatesTransformer.Transform(geometry.Center),
                    null,
                    Color.White,
                    0,
                    new Vector2(m_point.Width / 2.0f, m_point.Height / 2.0f),
                    1.0f,
                    SpriteEffects.None,
                    0f);
            }

            foreach (var segment in PolygonGeometry.FromRectangle(geometry.BoundingRectangle).Segments)
            {
                Vector  centerSegment = (segment.Start + segment.End) / 2.0;
                double  rotation      = segment.Offset.Angle();
                Vector2 scale         = coordinatesTransformer.CreateScaleVector(new Size(1.0, segment.Length), new Size(m_line.Width, m_line.Height));
                Vector2 origin        = new Vector2(m_line.Width / 2.0f, m_line.Height / 2.0f);

                spriteBatch.Draw(
                    m_line,
                    coordinatesTransformer.Transform(centerSegment),
                    null,
                    Color.White * 0.8f,
                    (float)Helper.ToRadians(rotation),
                    origin,
                    new Vector2(1, scale.Y),
                    SpriteEffects.None,
                    0);
            }

            if (geometry is PolygonGeometry)
            {
                var polygon = geometry as PolygonGeometry;

                foreach (var segment in polygon.Segments)
                {
                    Vector  centerSegment = (segment.Start + segment.End) / 2.0;
                    double  rotation      = segment.Offset.Angle();
                    Vector2 scale         = coordinatesTransformer.CreateScaleVector(new Size(1.0, segment.Length), new Size(m_line.Width, m_line.Height));
                    Vector2 origin        = new Vector2(m_line.Width / 2.0f, m_line.Height / 2.0f);

                    spriteBatch.Draw(
                        m_line,
                        coordinatesTransformer.Transform(centerSegment),
                        null,
                        Color.White * 0.8f,
                        (float)Helper.ToRadians(rotation),
                        origin,
                        new Vector2(1, scale.Y),
                        SpriteEffects.None,
                        0);
                }
            }
        }