ToDegrees() public static method

public static ToDegrees ( float radians ) : float
radians float
return float
Esempio n. 1
0
        /// <summary>
        ///     Rotates the loading wheel endlessly
        /// </summary>
        private void PerformLoadingWheelRotation()
        {
            if (LoadingWheel.Animations.Count != 0)
            {
                return;
            }

            var rotation = MathHelper.ToDegrees(LoadingWheel.Rotation);

            LoadingWheel.ClearAnimations();
            LoadingWheel.Animations.Add(new Animation(AnimationProperty.Rotation, Easing.Linear, rotation, rotation + 360, 1000));
        }
 public override void Draw()
 {
     if (raycast.points != null && inUse && charge > 0)
     {
         for (int i = 0; i < raycast.points.Count; i++)
         {
             if (i < 1)
             {
                 ParticleSystem.AddParticle(raycast.points[i].ToVector2(),
                                            new Systems.Particle(position, 1, 0, 1f, 0, 0, Color.Orange)
                 {
                     fadeRate     = .95f,
                     maxDampening = 99,
                     minDampening = 95,
                     minSpeed     = .01f,
                     minAngle     = MathHelper.ToDegrees(rotation) - 3,
                     maxAngle     = MathHelper.ToDegrees(rotation) + 3,
                     size         = .2f,
                     minSize      = .01f,
                     sizeRate     = .99f,
                     maxSize      = 5,
                     mass         = .3f,
                 });
             }
             ParticleSystem.AddParticle(raycast.points[i].ToVector2(),
                                        new Systems.Particle(position, 1, 0, 1f, 0, 0, Color.Yellow)
             {
                 fadeRate     = .95f,
                 maxDampening = 99,
                 minDampening = 99,
                 minSpeed     = .01f,
                 minAngle     = MathHelper.ToDegrees(rotation) - 90,
                 maxAngle     = MathHelper.ToDegrees(rotation) + 90,
                 size         = .05f,
                 minSize      = .01f,
                 sizeRate     = .95f,
                 maxSize      = 5
             });
             ParticleSystem.AddParticle(raycast.points[i].ToVector2(),
                                        new Systems.Particle(position, 1, 0, 1f, 0, 0, Color.LightBlue)
             {
                 fadeRate     = .95f,
                 maxDampening = 99,
                 minDampening = 99,
                 minSpeed     = .01f,
                 minAngle     = MathHelper.ToDegrees(rotation) - 90,
                 maxAngle     = MathHelper.ToDegrees(rotation) + 90,
                 size         = .09f,
                 minSize      = .01f,
                 sizeRate     = .95f,
                 maxSize      = 5,
                 mass         = 1.2f
             });
             ParticleSystem.AddParticle(raycast.points[i].ToVector2(),
                                        new Systems.Particle(position, 1, 0, 1f, 0, 0, Color.Orange)
             {
                 fadeRate     = .95f,
                 maxDampening = 95,
                 minDampening = 90,
                 minSpeed     = .01f,
                 minAngle     = MathHelper.ToDegrees(rotation) - 3,
                 maxAngle     = MathHelper.ToDegrees(rotation) + 3,
                 size         = .2f,
                 minSize      = .01f,
                 sizeRate     = .99f,
                 maxSize      = 5,
                 mass         = 1.5f,
             });
         }
     }
     //base.Draw(spriteBatch);
 }
Esempio n. 3
0
        public void Draw(UltimaBatcher2D batcher, int x, int y)
        {
            bool removeEffects = false;

            if (Timer < Engine.Ticks)
            {
                if (CurrentCount == 0)
                {
                    return;
                }

                removeEffects = true;
            }
            else if (Type == 0xFF || Type == 0xFE)
            {
                return;
            }

            uint passed = Engine.Ticks - LastTick;

            if (passed > 7000)
            {
                LastTick = Engine.Ticks;
                passed   = 25;
            }

            bool windChanged = false;

            if (WindTimer < Engine.Ticks)
            {
                if (WindTimer == 0)
                {
                    windChanged = true;
                }

                WindTimer = Engine.Ticks + (uint)(RandomHelper.GetValue(7, 13) * 1000);

                sbyte lastWind = Wind;

                Wind = (sbyte)RandomHelper.GetValue(0, 4);

                if (RandomHelper.GetValue(0, 2) != 0)
                {
                    Wind *= -1;
                }

                if (Wind < 0 && lastWind > 0)
                {
                    Wind = 0;
                }
                else if (Wind > 0 && lastWind < 0)
                {
                    Wind = 0;
                }

                if (lastWind != Wind)
                {
                    windChanged = true;
                }
            }

            //switch ((WEATHER_TYPE) Type)
            //{
            //    case WEATHER_TYPE.WT_RAIN:
            //    case WEATHER_TYPE.WT_FIERCE_STORM:
            //        // TODO: set color
            //        break;
            //    case WEATHER_TYPE.WT_SNOW:
            //    case WEATHER_TYPE.WT_STORM:
            //        // TODO: set color
            //        break;
            //    default:
            //        break;
            //}

            Point winpos  = Engine.Profile.Current.GameWindowPosition;
            Point winsize = Engine.Profile.Current.GameWindowSize;

            for (int i = 0; i < Effects.Count; i++)
            {
                var effect = Effects[i];

                if (effect.X < x || effect.X > x + winsize.X ||
                    effect.Y < y || effect.Y > y + winsize.Y)
                {
                    if (removeEffects)
                    {
                        Effects.RemoveAt(i--);

                        if (CurrentCount > 0)
                        {
                            CurrentCount--;
                        }
                        else
                        {
                            CurrentCount = 0;
                        }

                        continue;
                    }

                    effect.X = x + RandomHelper.GetValue(0, winsize.X);
                    effect.Y = y + RandomHelper.GetValue(0, winsize.Y);
                }


                switch ((WEATHER_TYPE)Type)
                {
                case WEATHER_TYPE.WT_RAIN:
                    float scaleRation = effect.ScaleRatio;
                    effect.SpeedX = -4.5f - scaleRation;
                    effect.SpeedY = 5.0f + scaleRation;
                    break;

                case WEATHER_TYPE.WT_FIERCE_STORM:
                    effect.SpeedX = Wind;
                    effect.SpeedY = 6.0f;
                    break;

                case WEATHER_TYPE.WT_SNOW:
                case WEATHER_TYPE.WT_STORM:

                    if (Type == (byte)WEATHER_TYPE.WT_SNOW)
                    {
                        effect.SpeedX = Wind;
                        effect.SpeedY = 1.0f;
                    }
                    else
                    {
                        effect.SpeedX = Wind * 1.5f;
                        effect.SpeedY = 1.5f;
                    }

                    if (windChanged)
                    {
                        effect.SpeedAngle     = MathHelper.ToDegrees((float)Math.Atan2(effect.SpeedX, effect.SpeedY));
                        effect.SpeedMagnitude =
                            (float)Math.Sqrt(Math.Pow(effect.SpeedX, 2) + Math.Pow(effect.SpeedY, 2));
                    }

                    float speed_angle     = effect.SpeedAngle;
                    float speed_magnitude = effect.SpeedMagnitude;

                    speed_magnitude += effect.ScaleRatio;

                    speed_angle += SinOscillate(0.4f, 20, Engine.Ticks + effect.ID);

                    var rad = MathHelper.ToRadians(speed_angle);
                    effect.SpeedX = speed_magnitude * (float)Math.Sin(rad);
                    effect.SpeedY = speed_magnitude * (float)Math.Cos(rad);

                    break;

                default:
                    break;
                }

                float speedOffset = passed / SimulationRation;

                switch ((WEATHER_TYPE)Type)
                {
                case WEATHER_TYPE.WT_RAIN:
                case WEATHER_TYPE.WT_FIERCE_STORM:

                    int oldX = (int)effect.X;
                    int oldY = (int)effect.Y;

                    float ofsx = effect.SpeedX * speedOffset;
                    float ofsy = effect.SpeedY * speedOffset;

                    effect.X += ofsx;
                    effect.Y += ofsy;

                    const float MAX_OFFSET_XY = 5.0f;

                    if (ofsx >= MAX_OFFSET_XY)
                    {
                        oldX = (int)(effect.X - MAX_OFFSET_XY);
                    }
                    else if (ofsx <= -MAX_OFFSET_XY)
                    {
                        oldX = (int)(effect.X + MAX_OFFSET_XY);
                    }

                    if (ofsy >= MAX_OFFSET_XY)
                    {
                        oldY = (int)(effect.Y - MAX_OFFSET_XY);
                    }
                    else if (oldY <= -MAX_OFFSET_XY)
                    {
                        oldY = (int)(effect.Y + MAX_OFFSET_XY);
                    }

                    batcher.DrawLine(Textures.GetTexture(Color.Gray), x + oldX, y + oldY,
                                     x + (int)effect.X, y + (int)effect.Y, 0, 0);
                    break;

                case WEATHER_TYPE.WT_SNOW:
                case WEATHER_TYPE.WT_STORM:

                    effect.X += effect.SpeedX * speedOffset;
                    effect.Y += effect.SpeedY * speedOffset;

                    batcher.Draw2D(Textures.GetTexture(Color.White),
                                   x + (int)effect.X, y + (int)effect.Y, 2, 2, ref _hueVector);

                    break;

                default:
                    break;
                }
            }

            LastTick = Engine.Ticks;
        }
Esempio n. 4
0
        /// <summary>
        /// Calcula el angulo entre dos puntos.
        /// </summary>
        /// <param name="A">Punto A.</param>
        /// <param name="B">Punto B.</param>
        /// <returns>Devuelve el angulo en grados en los dos puntos.</returns>
        public static float GetAngle(Vector2 A, Vector2 B)
        {
            float angle = XNAMathHelper.ToDegrees((float)Math.Atan2(B.Y - A.Y, B.X - A.X));

            return(angle < 0 ? angle + 360 : angle);
        }