Exemple #1
0
        /// <summary>
        /// Creates particles when deleted
        /// </summary>
        private void Death()
        {
            if (splash)
            {
                int maxParts = 8;
                int minParts = 4;

                if (shotType == 3)
                {
                    maxParts = 2; minParts = 1;
                }

                for (int i = 0; i <= GM.r.FloatBetween(minParts, maxParts); i++)
                {
                    float          spawnRot = RotationAngle + GM.r.FloatBetween(-15, 15);
                    Vector3        spawnVel = RotationHelper.Direction3DFromAngle(spawnRot, 0) * 200;
                    FadingParticle splash   = new FadingParticle(Position2D, spawnVel, spawnRot, 0.25f);
                    splash.Wash = Color.Aqua;
                    splash.SX   = 1f;
                    splash.SY   = 5f;
                }

                for (int i = 0; i <= GM.r.FloatBetween(0, 5); i++)
                {
                    float          spawnRot = -RotationAngle + GM.r.FloatBetween(-20, 20);
                    Vector3        spawnVel = RotationHelper.Direction3DFromAngle(spawnRot, 0) * -10;
                    FadingParticle splash   = new FadingParticle(Position2D, spawnVel, spawnRot, 0.1f);
                    splash.Wash = Color.Aqua;
                    splash.SX   = 1f;
                    splash.SY   = 2.5f;
                }
            }
        }
        public override void Update(float dt)
        {
            base.Update(dt);

            if (!Placed)
            {
                Done = false;
            }

            if (Hidden)
            {
                return;
            }

            if (lasers.Count > 0)
            {
                spinV += dt;

                foreach (var l in lasers)
                {
                    if (l.Done)
                    {
                        lasers.Clear();
                        break;
                    }

                    l.Angle += spinV * dt * 0.2f * spinDir;
                }
            }

            lastFadingParticle -= dt;

            if (lastFadingParticle <= 0 && !(GetComponent <StateComponent>().StateInstance is FlameAttack))
            {
                lastFadingParticle = 0.2f;

                var particle = new FadingParticle(GetComponent <BkGraphicsComponent>().Animation.GetCurrentTexture(), tint);
                Area.Add(particle);

                particle.Depth  = Depth - 1;
                particle.Center = Center;

                var room = GetComponent <RoomComponent>().Room;

                if (room != null && room.Type == RoomType.Boss)
                {
                    CheckCapture();
                }
                else if (Target != null)
                {
                    room = Target.GetComponent <RoomComponent>().Room;

                    if (room != null && room.Type == RoomType.Boss)
                    {
                        CheckCapture();
                    }
                }
            }
        }
Exemple #3
0
 public static ProjectileUpdateCallback MakeFadingParticles(float time, Color tint)
 {
     return(Make(time, p => {
         var pr = new FadingParticle(p.GetComponent <ProjectileGraphicsComponent>().Sprite, tint);
         p.Area.Add(pr);
         pr.Center = p.Center;
     }));
 }
Exemple #4
0
 /// <summary>
 /// Code to run each tick
 /// </summary>
 private void Tick()
 {
     if (GM.eventM.Elapsed(tiOneSecond))
     {
         OneSecond();
     }
     if (GM.r.FloatBetween(-0.5f, rainAmount) > 0.25f)
     {
         FadingParticle rain = new FadingParticle(GameSetup.PlayerView.Position2D += new Vector2(GM.r.FloatBetween(-2000, 2000), 0), new Vector3(450, 450, 0) * GM.r.FloatBetween(1.5f, 2), 135, 2);
         rain.Wash = Color.Blue;
         rain.SX   = 1f;
         rain.SY   = 5f;
     }
 }
Exemple #5
0
        public override void Update(float dt)
        {
            base.Update(dt);

            if (Target != null)
            {
                GraphicsComponent.Flipped = Target.CenterX < CenterX;
            }

            lastFadingParticle -= dt;

            if (lastFadingParticle <= 0)
            {
                lastFadingParticle = 0.2f;

                var particle = new FadingParticle(GetComponent <MobAnimationComponent>().Animation.GetCurrentTexture(), tint);
                Area.Add(particle);

                particle.Depth  = Depth - 1;
                particle.Center = Center;
            }
        }
Exemple #6
0
        private static void Spawn_Keybrand(ParticleOrchestraSettings settings)
        {
            float   num    = Main.rand.NextFloat() * ((float)Math.PI * 2f);
            float   num2   = 3f;
            Vector2 vector = new Vector2(0.7f);

            for (float num3 = 0f; num3 < 1f; num3 += 1f / num2)
            {
                float   num4    = (float)Math.PI * 2f * num3 + num + Main.rand.NextFloatDirection() * 0.1f;
                Vector2 vector2 = 1.5f * vector;
                float   divider = 60f;
                Vector2 value   = Main.rand.NextVector2Circular(4f, 4f) * vector;
                PrettySparkleParticle prettySparkleParticle = _poolPrettySparkle.RequestParticle();
                prettySparkleParticle.Velocity             = num4.ToRotationVector2() * vector2;
                prettySparkleParticle.AccelerationPerFrame = num4.ToRotationVector2() * -(vector2 / divider);
                prettySparkleParticle.ColorTint            = Color.Lerp(Color.Gold, Color.OrangeRed, Main.rand.NextFloat());
                prettySparkleParticle.LocalPosition        = settings.PositionInWorld + value;
                prettySparkleParticle.Rotation             = num4;
                prettySparkleParticle.Scale = vector * 0.8f;
                Main.ParticleSystem_World_OverPlayers.Add(prettySparkleParticle);
            }
            num += 1f / num2 / 2f * ((float)Math.PI * 2f);
            num  = Main.rand.NextFloat() * ((float)Math.PI * 2f);
            for (float num5 = 0f; num5 < 1f; num5 += 1f / num2)
            {
                float   num6    = (float)Math.PI * 2f * num5 + num + Main.rand.NextFloatDirection() * 0.1f;
                Vector2 vector3 = 1f * vector;
                float   num7    = 30f;
                Color   value2  = Color.Lerp(Color.Gold, Color.OrangeRed, Main.rand.NextFloat());
                value2   = Color.Lerp(Color.White, value2, 0.5f);
                value2.A = 0;
                Vector2        value3         = Main.rand.NextVector2Circular(4f, 4f) * vector;
                FadingParticle fadingParticle = _poolFading.RequestParticle();
                fadingParticle.SetBasicInfo(TextureAssets.Extra[98], null, Vector2.Zero, Vector2.Zero);
                fadingParticle.SetTypeInfo(num7);
                fadingParticle.Velocity              = num6.ToRotationVector2() * vector3;
                fadingParticle.AccelerationPerFrame  = num6.ToRotationVector2() * -(vector3 / num7);
                fadingParticle.ColorTint             = value2;
                fadingParticle.LocalPosition         = settings.PositionInWorld + num6.ToRotationVector2() * vector3 * vector * num7 * 0.2f + value3;
                fadingParticle.Rotation              = num6 + (float)Math.PI / 2f;
                fadingParticle.FadeInNormalizedTime  = 0.3f;
                fadingParticle.FadeOutNormalizedTime = 0.4f;
                fadingParticle.Scale = new Vector2(0.5f, 1.2f) * 0.8f * vector;
                Main.ParticleSystem_World_OverPlayers.Add(fadingParticle);
            }
            num2 = 1f;
            num  = Main.rand.NextFloat() * ((float)Math.PI * 2f);
            for (float num8 = 0f; num8 < 1f; num8 += 1f / num2)
            {
                float num9      = (float)Math.PI * 2f * num8 + num;
                float typeInfo  = 30f;
                Color colorTint = Color.Lerp(Color.CornflowerBlue, Color.White, Main.rand.NextFloat());
                colorTint.A = 127;
                Vector2        value4          = Main.rand.NextVector2Circular(4f, 4f) * vector;
                Vector2        value5          = Main.rand.NextVector2Square(0.7f, 1.3f);
                FadingParticle fadingParticle2 = _poolFading.RequestParticle();
                fadingParticle2.SetBasicInfo(TextureAssets.Extra[174], null, Vector2.Zero, Vector2.Zero);
                fadingParticle2.SetTypeInfo(typeInfo);
                fadingParticle2.ColorTint             = colorTint;
                fadingParticle2.LocalPosition         = settings.PositionInWorld + value4;
                fadingParticle2.Rotation              = num9 + (float)Math.PI / 2f;
                fadingParticle2.FadeInNormalizedTime  = 0.1f;
                fadingParticle2.FadeOutNormalizedTime = 0.4f;
                fadingParticle2.Scale             = new Vector2(0.1f, 0.1f) * vector;
                fadingParticle2.ScaleVelocity     = value5 * 1f / 60f;
                fadingParticle2.ScaleAcceleration = value5 * -0.0166666675f / 60f;
                Main.ParticleSystem_World_OverPlayers.Add(fadingParticle2);
            }
        }
        private static void Spawn_Keybrand(ParticleOrchestraSettings settings)
        {
            float   num1      = Main.rand.NextFloat() * 6.283185f;
            float   num2      = 3f;
            Vector2 vector2_1 = new Vector2(0.7f);

            for (float num3 = 0.0f; (double)num3 < 1.0; num3 += 1f / num2)
            {
                float   f         = (float)(6.28318548202515 * (double)num3 + (double)num1 + (double)Main.rand.NextFloatDirection() * 0.100000001490116);
                Vector2 vector2_2 = 1.5f * vector2_1;
                float   num4      = 60f;
                Vector2 vector2_3 = Main.rand.NextVector2Circular(4f, 4f) * vector2_1;
                PrettySparkleParticle prettySparkleParticle = ParticleOrchestrator._poolPrettySparkle.RequestParticle();
                prettySparkleParticle.Velocity             = f.ToRotationVector2() * vector2_2;
                prettySparkleParticle.AccelerationPerFrame = f.ToRotationVector2() * -(vector2_2 / num4);
                prettySparkleParticle.ColorTint            = Color.Lerp(Color.Gold, Color.OrangeRed, Main.rand.NextFloat());
                prettySparkleParticle.LocalPosition        = settings.PositionInWorld + vector2_3;
                prettySparkleParticle.Rotation             = f;
                prettySparkleParticle.Scale = vector2_1 * 0.8f;
                Main.ParticleSystem_World_OverPlayers.Add((IParticle)prettySparkleParticle);
            }
            float num5 = num1 + (float)(1.0 / (double)num2 / 2.0 * 6.28318548202515);
            float num6 = Main.rand.NextFloat() * 6.283185f;

            for (float num3 = 0.0f; (double)num3 < 1.0; num3 += 1f / num2)
            {
                float   f          = (float)(6.28318548202515 * (double)num3 + (double)num6 + (double)Main.rand.NextFloatDirection() * 0.100000001490116);
                Vector2 vector2_2  = 1f * vector2_1;
                float   timeToLive = 30f;
                Color   color      = Color.Lerp(Color.White, Color.Lerp(Color.Gold, Color.OrangeRed, Main.rand.NextFloat()), 0.5f);
                color.A = (byte)0;
                Vector2        vector2_3      = Main.rand.NextVector2Circular(4f, 4f) * vector2_1;
                FadingParticle fadingParticle = ParticleOrchestrator._poolFading.RequestParticle();
                fadingParticle.SetBasicInfo(TextureAssets.Extra[98], new Rectangle?(), Vector2.Zero, Vector2.Zero);
                fadingParticle.SetTypeInfo(timeToLive);
                fadingParticle.Velocity              = f.ToRotationVector2() * vector2_2;
                fadingParticle.AccelerationPerFrame  = f.ToRotationVector2() * -(vector2_2 / timeToLive);
                fadingParticle.ColorTint             = color;
                fadingParticle.LocalPosition         = settings.PositionInWorld + f.ToRotationVector2() * vector2_2 * vector2_1 * timeToLive * 0.2f + vector2_3;
                fadingParticle.Rotation              = f + 1.570796f;
                fadingParticle.FadeInNormalizedTime  = 0.3f;
                fadingParticle.FadeOutNormalizedTime = 0.4f;
                fadingParticle.Scale = new Vector2(0.5f, 1.2f) * 0.8f * vector2_1;
                Main.ParticleSystem_World_OverPlayers.Add((IParticle)fadingParticle);
            }
            float num7 = 1f;
            float num8 = Main.rand.NextFloat() * 6.283185f;

            for (float num3 = 0.0f; (double)num3 < 1.0; num3 += 1f / num7)
            {
                float num4       = 6.283185f * num3 + num8;
                float timeToLive = 30f;
                Color color      = Color.Lerp(Color.CornflowerBlue, Color.White, Main.rand.NextFloat());
                color.A = (byte)127;
                Vector2        vector2_2      = Main.rand.NextVector2Circular(4f, 4f) * vector2_1;
                Vector2        vector2_3      = Main.rand.NextVector2Square(0.7f, 1.3f);
                FadingParticle fadingParticle = ParticleOrchestrator._poolFading.RequestParticle();
                fadingParticle.SetBasicInfo(TextureAssets.Extra[174], new Rectangle?(), Vector2.Zero, Vector2.Zero);
                fadingParticle.SetTypeInfo(timeToLive);
                fadingParticle.ColorTint             = color;
                fadingParticle.LocalPosition         = settings.PositionInWorld + vector2_2;
                fadingParticle.Rotation              = num4 + 1.570796f;
                fadingParticle.FadeInNormalizedTime  = 0.1f;
                fadingParticle.FadeOutNormalizedTime = 0.4f;
                fadingParticle.Scale             = new Vector2(0.1f, 0.1f) * vector2_1;
                fadingParticle.ScaleVelocity     = vector2_3 * 1f / 60f;
                fadingParticle.ScaleAcceleration = vector2_3 * -0.01666667f / 60f;
                Main.ParticleSystem_World_OverPlayers.Add((IParticle)fadingParticle);
            }
        }
Exemple #8
0
        /// <summary>
        /// Code to run upon hitting a sprite
        /// </summary>
        /// <param name="hit">The sprite collided with</param>
        private void Hit(Sprite hit)
        {
            if (hit is HitBox && GM.r.FloatBetween(0, 1) > 0.75)
            {
                HitBox hitBox = (HitBox)hit;
                //If the HitBox is a child, get its owner
                if (hitBox.Owner is HitBox)
                {
                    hitBox = (HitBox)hitBox.Owner;
                }
                //Check if the HitBox's ship is the ship that fired this CannonBall
                if (hitBox.Owner == owner)
                {
                    CollisionAbandonResponse = true;
                }
                else
                {
                    Ship ship = (Ship)hitBox.Owner;

                    //Debris
                    for (int i = 0; i <= GM.r.FloatBetween(0, 5); i++)
                    {
                        //float spawnRot = RotationAngle + 90 + GM.r.FloatBetween(-20, 20);
                        float          spawnRot = RotationHelper.AngleFromDirection(RotationHelper.MyDirection(this, 0)) + GM.r.FloatBetween(-40, 40);
                        Vector3        spawnVel = RotationHelper.Direction3DFromAngle(spawnRot, 0) * -200;
                        FadingParticle debris   = new FadingParticle(Position2D, spawnVel, spawnRot, 0.1f);
                        debris.Wash = Color.Brown;
                        debris.SX   = 3f + GM.r.FloatBetween(-2f, 2f);
                        debris.SY   = 3f + GM.r.FloatBetween(-2f, 2f);
                    }

                    if (hitBox.DamageType == 0) //Hull
                    {
                        if (shotType == 0)      //Ball
                        {
                            hitBox.Health -= (int)(10 * hitBox.DamageMul);
                            if (GM.r.FloatBetween(0, 1) > 0.5)
                            {
                                ship.CrewNum -= 1;
                            }
                        }
                        else if (shotType == 2)//Carcass
                        {
                            hitBox.Health -= (int)(2.5f * hitBox.DamageMul);
                            if (GM.r.FloatBetween(0, 1) > 0.80)
                            {
                                hitBox.IsBurning = true;
                            }
                            if (GM.r.FloatBetween(0, 1) > 0.5)
                            {
                                ship.CrewNum -= 1;
                            }
                        }
                        else if (shotType == 4 && GM.r.FloatBetween(0, 1) > 0.5f)//Grapple
                        {
                            Ship firedFrom = (Ship)owner;
                            if (!firedFrom.isBoarding && !firedFrom.isBoarded)
                            {
                                firedFrom.Board(ship);
                            }
                        }
                        else
                        {
                            hitBox.Health -= (int)(1 * hitBox.DamageMul);
                        }
                        if (shotType == 3 && GM.r.FloatBetween(0, 1) > 0.4f) //Grape
                        {
                            ship.CrewNum -= (int)GM.r.FloatBetween(1, 2);
                        }
                    }
                    else if (hitBox.DamageType == 1) //Sail
                    {
                        if (shotType == 1)           //Bar
                        {
                            hitBox.Health -= (int)(25 * hitBox.DamageMul);
                        }
                        else if (shotType == 2)//Carcass
                        {
                            hitBox.Health -= (int)(5 * hitBox.DamageMul);
                            if (GM.r.FloatBetween(0, 1) > 0.5)
                            {
                                hitBox.IsBurning = true;
                            }
                        }
                        else
                        {
                            //CollisionAbandonResponse = true;
                            hitBox.Health -= 1;
                        }
                    }
                }
            }
        }