Exemple #1
0
    public Move Clone()
    {
        Move move = new Move();

        move.speed = speed.Clone();
        move.Init();
        return(move);
    }
Exemple #2
0
    public Attack Clone()
    {
        Attack attack = new Attack();

        attack.damage = damage.Clone();
        attack.range  = range.Clone();
        attack.speed  = speed.Clone();
        return(attack);
    }
Exemple #3
0
        /// <inheritdocs/>
        protected override void OnPaintOffScreen(PaintEventArgs e)
        {
            PolarGraphics f = CreatePolarGraphics(e.Graphics);

            // What altitude are we drawing?
#if PocketPC
            Speed SpeedToRender = pSpeed;
#else
            Speed speedToRender = new Speed(_valueInterpolator[_interpolationIndex], _pSpeed.Units);
#endif

            // Cache drawing intervals and such to prevent a race condition
            double minorInterval            = _pMinorTickInterval.Value;
            double majorInterval            = _pMajorTickInterval.Value;
            double cachedSpeedLabelInterval = _pSpeedLabelInterval.ToUnitType(_pMaximumSpeed.Units).Value;
            Speed  maxSpeed  = _pMaximumSpeed.Clone();
            double minorStep = _pMinorTickInterval.ToUnitType(_pMaximumSpeed.Units).Value;
            double majorStep = _pMajorTickInterval.ToUnitType(_pMaximumSpeed.Units).Value;

            // Draw tick marks
            double          angle;
            PolarCoordinate start;
            PolarCoordinate end;

            #region Draw minor tick marks

            if (minorInterval > 0)
            {
                for (double speed = 0; speed < maxSpeed.Value; speed += minorStep)
                {
                    // Convert the speed to an angle
                    angle = speed * _conversionFactor + _pMinimumAngle.DecimalDegrees;
                    // Get the coordinate of the line's start
                    start = new PolarCoordinate(95, angle, Azimuth.South, PolarCoordinateOrientation.Clockwise);
                    end   = new PolarCoordinate(100, angle, Azimuth.South, PolarCoordinateOrientation.Clockwise);
                    // And draw a line
                    Pen p = new Pen(_minorTickPenColor);
                    f.DrawLine(p, start, end);
                    p.Dispose();
                }
            }

            #endregion

            #region Draw major tick marks

            if (majorInterval > 0)
            {
                using (Pen majorPen = new Pen(_majorTickPenColor))
                {
                    for (double speed = 0; speed < maxSpeed.Value; speed += majorStep)
                    {
                        // Convert the speed to an angle
                        angle = speed * _conversionFactor + _pMinimumAngle.DecimalDegrees;
                        // Get the coordinate of the line's start
                        start = new PolarCoordinate(90, angle, Azimuth.South, PolarCoordinateOrientation.Clockwise);
                        end   = new PolarCoordinate(100, angle, Azimuth.South, PolarCoordinateOrientation.Clockwise);
                        // And draw a line

                        f.DrawLine(majorPen, start, end);
                    }

                    #region Draw a major tick mark at the maximum speed

                    // Convert the speed to an angle
                    angle = maxSpeed.Value * _conversionFactor + _pMinimumAngle.DecimalDegrees;
                    // Get the coordinate of the line's start
                    start = new PolarCoordinate(90, angle, Azimuth.South, PolarCoordinateOrientation.Clockwise);
                    end   = new PolarCoordinate(100, angle, Azimuth.South, PolarCoordinateOrientation.Clockwise);
                    // And draw a line
                    f.DrawLine(majorPen, start, end);

                    #endregion
                }
            }

            #endregion

            using (SolidBrush fontBrush = new SolidBrush(_speedLabelBrushColor))
            {
                if (cachedSpeedLabelInterval > 0)
                {
                    for (double speed = 0; speed < maxSpeed.Value; speed += cachedSpeedLabelInterval)
                    {
                        // Convert the speed to an angle
                        angle = speed * _conversionFactor + _pMinimumAngle.DecimalDegrees;
                        // And draw a line
                        f.DrawCenteredString(new Speed(speed, maxSpeed.Units).ToString(_pSpeedLabelFormat, CultureInfo.CurrentCulture), Font, fontBrush,
                                             new PolarCoordinate(75, angle, Azimuth.South, PolarCoordinateOrientation.Clockwise));
                    }

                    // Convert the speed to an angle
                    angle = maxSpeed.Value * _conversionFactor + _pMinimumAngle.DecimalDegrees;

                    // And draw the speed label
                    f.DrawCenteredString(maxSpeed.ToString(_pSpeedLabelFormat, CultureInfo.CurrentCulture), Font, fontBrush,
                                         new PolarCoordinate(75, angle, Azimuth.South, PolarCoordinateOrientation.Clockwise));
                }

                // Draw the units for the speedometer
                if (_pIsUnitLabelVisible)
                {
                    f.DrawCenteredString(_pMaximumSpeed.ToString("u", CultureInfo.CurrentCulture), Font, fontBrush,
                                         new PolarCoordinate(90, Angle.Empty, Azimuth.South, PolarCoordinateOrientation.Clockwise));
                }
            }

            PolarCoordinate[] needle = new PolarCoordinate[_speedometerNeedle.Length];
            for (int index = 0; index < needle.Length; index++)
            {
                needle[index] = _speedometerNeedle[index].Rotate((speedToRender.ToUnitType(_pMaximumSpeed.Units).Value *_conversionFactor) + _pMinimumAngle.DecimalDegrees);
            }

            // Draw an ellipse at the center
            f.DrawEllipse(Pens.Gray, PolarCoordinate.Empty, 10);

#if !PocketPC
            // Now draw a shadow
            f.Graphics.TranslateTransform(_pNeedleShadowSize.Width, _pNeedleShadowSize.Height, MatrixOrder.Append);
            using (Brush b = new SolidBrush(_needleShadowBrushColor)) f.FillPolygon(b, needle);

            f.Graphics.ResetTransform();
#endif

            // Then draw the actual needle
            using (SolidBrush needleFill = new SolidBrush(_needleFillColor)) f.FillPolygon(needleFill, needle);
            using (Pen needlePen = new Pen(_needleOutlineColor)) f.DrawPolygon(needlePen, needle);
        }
Exemple #4
0
        protected override void OnPaintOffScreen(PaintEventArgs e)
        {
            PolarGraphics f = base.CreatePolarGraphics(e.Graphics);


            // What altitude are we drawing?
#if PocketPC
            Speed SpeedToRender = pSpeed;
#else
            Speed SpeedToRender = new Speed(ValueInterpolator[InterpolationIndex], pSpeed.Units);
#endif

            // Cache drawing intervals and such to prevent a race condition
            double MinorInterval            = pMinorTickInterval.Value;
            double MajorInterval            = pMajorTickInterval.Value;
            double CachedSpeedLabelInterval = pSpeedLabelInterval.ToUnitType(pMaximumSpeed.Units).Value;
            Speed  MaxSpeed  = pMaximumSpeed.Clone();
            double MinorStep = pMinorTickInterval.ToUnitType(pMaximumSpeed.Units).Value;
            double MajorStep = pMajorTickInterval.ToUnitType(pMaximumSpeed.Units).Value;

            // Draw tick marks
            double          angle;
            PolarCoordinate start;
            PolarCoordinate end;

            #region Draw minor tick marks

            if (MinorInterval > 0)
            {
                for (double speed = 0; speed < MaxSpeed.Value; speed += MinorStep)
                {
                    // Convert the speed to an angle
                    angle = speed * ConversionFactor + pMinimumAngle.DecimalDegrees;
                    // Get the coordinate of the line's start
                    start = new PolarCoordinate(95, angle, Azimuth.South, PolarCoordinateOrientation.Clockwise);
                    end   = new PolarCoordinate(100, angle, Azimuth.South, PolarCoordinateOrientation.Clockwise);
                    // And draw a line
                    f.DrawLine(pMinorTickPen, start, end);
                }
            }

            #endregion

            #region Draw major tick marks

            if (MajorInterval > 0)
            {
                for (double speed = 0; speed < MaxSpeed.Value; speed += MajorStep)
                {
                    // Convert the speed to an angle
                    angle = speed * ConversionFactor + pMinimumAngle.DecimalDegrees;
                    // Get the coordinate of the line's start
                    start = new PolarCoordinate(90, angle, Azimuth.South, PolarCoordinateOrientation.Clockwise);
                    end   = new PolarCoordinate(100, angle, Azimuth.South, PolarCoordinateOrientation.Clockwise);
                    // And draw a line
                    f.DrawLine(pMajorTickPen, start, end);
                }

                #region Draw a major tick mark at the maximum speed

                // Convert the speed to an angle
                angle = MaxSpeed.Value * ConversionFactor + pMinimumAngle.DecimalDegrees;
                // Get the coordinate of the line's start
                start = new PolarCoordinate(90, angle, Azimuth.South, PolarCoordinateOrientation.Clockwise);
                end   = new PolarCoordinate(100, angle, Azimuth.South, PolarCoordinateOrientation.Clockwise);
                // And draw a line
                f.DrawLine(pMajorTickPen, start, end);

                #endregion
            }

            #endregion

            if (CachedSpeedLabelInterval > 0)
            {
                for (double speed = 0; speed < MaxSpeed.Value; speed += CachedSpeedLabelInterval)
                {
                    // Convert the speed to an angle
                    angle = speed * ConversionFactor + pMinimumAngle.DecimalDegrees;
                    // And draw a line
                    f.DrawCenteredString(new Speed(speed, MaxSpeed.Units).ToString(pSpeedLabelFormat, CultureInfo.CurrentCulture), pSpeedLabelFont, pSpeedLabelBrush,
                                         new PolarCoordinate(75, angle, Azimuth.South, PolarCoordinateOrientation.Clockwise));
                }

                // Convert the speed to an angle
                angle = MaxSpeed.Value * ConversionFactor + pMinimumAngle.DecimalDegrees;

                // And draw the speed label
                f.DrawCenteredString(MaxSpeed.ToString(pSpeedLabelFormat, CultureInfo.CurrentCulture), pSpeedLabelFont, pSpeedLabelBrush,
                                     new PolarCoordinate(75, angle, Azimuth.South, PolarCoordinateOrientation.Clockwise));
            }

            // Draw the units for the speedometer
            if (pIsUnitLabelVisible)
            {
                f.DrawCenteredString(pMaximumSpeed.ToString("u", CultureInfo.CurrentCulture), pSpeedLabelFont, pSpeedLabelBrush,
                                     new PolarCoordinate(90, Angle.Empty, Azimuth.South, PolarCoordinateOrientation.Clockwise));
            }

            PolarCoordinate[] Needle = new PolarCoordinate[SpeedometerNeedle.Length];
            for (int index = 0; index < Needle.Length; index++)
            {
                Needle[index] = SpeedometerNeedle[index].Rotate((SpeedToRender.ToUnitType(pMaximumSpeed.Units).Value *this.ConversionFactor) + pMinimumAngle.DecimalDegrees);
            }

            // Draw an ellipse at the center
            f.DrawEllipse(pCenterPen, PolarCoordinate.Empty, 10);

#if !PocketPC
            // Now draw a shadow
            f.Graphics.TranslateTransform(pNeedleShadowSize.Width, pNeedleShadowSize.Height, MatrixOrder.Append);
            f.FillPolygon(pNeedleShadowBrush, Needle);
            f.Graphics.ResetTransform();
#endif

            // Then draw the actual needle
            f.FillPolygon(pNeedleFillBrush, Needle);
            f.DrawPolygon(pNeedleOutlinePen, Needle);
        }