Beispiel #1
0
        public static EmitterSimple Knockout(RoomScene room, string spriteName, int posX, int posY, byte duration = 60)
        {
            int frame = Systems.timer.Frame;

            // Prepare Emnitter
            EmitterSimple emitter = EmitterSimple.NewEmitter(room, Systems.mapper.atlas[(byte)AtlasGroup.Objects], spriteName, new Vector2(posX, posY), new Vector2(0, 0), 0.5f, frame + duration, frame + duration - 25);

            // Randomize Knockout Direction and Rotation
            Vector2 randVelocity = new Vector2(
                CalcRandom.FloatBetween(-4.5f, 4.5f),
                CalcRandom.FloatBetween(-5f, -11f)
                );

            float rotSpeed = CalcRandom.FloatBetween(0.07f, 0.15f) * (CalcRandom.IntBetween(1, 100) >= 51 ? 1 : -1);

            // Add Knockout Particle
            emitter.AddParticle(
                new Vector2(posX, posY),
                randVelocity,
                0,
                rotSpeed
                );

            return(emitter);
        }
Beispiel #2
0
        public static EmitterSimple GravityParticle(RoomScene room, string spriteName, int posX, int posY, byte duration = 8, float ySpeed = -3f, float gravity = 0.5f)
        {
            int frame = Systems.timer.Frame;

            EmitterSimple emitter = EmitterSimple.NewEmitter(room, Systems.mapper.atlas[(byte)AtlasGroup.Tiles], spriteName, new Vector2(posX, posY), new Vector2(0, 0), gravity, frame + duration, frame + duration, 1, 1);

            emitter.AddParticle(new Vector2(posX, posY), new Vector2(0, ySpeed), 0, 0);

            return(emitter);
        }
Beispiel #3
0
        public static EmitterSimple DirectionParticle(RoomScene room, string spriteName, int posX, int posY, byte duration = 8, float xSpeed = 0f, float ySpeed = 0f)
        {
            int frame = Systems.timer.Frame;

            EmitterSimple emitter = EmitterSimple.NewEmitter(room, Systems.mapper.atlas[(byte)AtlasGroup.Objects], spriteName, new Vector2(posX, posY), new Vector2(0, 0), 0, frame + duration, frame + duration, 1, 1);

            emitter.AddParticle(new Vector2(posX, posY), new Vector2(xSpeed, ySpeed), 0, 0);

            return(emitter);
        }
Beispiel #4
0
        public static EmitterSimple AirPuff(RoomScene room, int posX, int posY, sbyte dirHor, sbyte dirVert, byte duration = 8)
        {
            int frame = Systems.timer.Frame;

            // Readjust positions to adjust for midX and midY of AirPuff image.
            posX -= 20;
            posY -= 20;

            float radian = Radians.GetRadiansByCardinalDir((sbyte)-dirHor, (sbyte)-dirVert);

            // Get the Particle Directions based on Cardinal Steps from the original.
            float rad1 = Radians.GetRadiansByCardinalDir((sbyte)-dirHor, (sbyte)-dirVert, -3);
            float rad2 = Radians.GetRadiansByCardinalDir((sbyte)-dirHor, (sbyte)-dirVert, 3);

            float xOffset  = Radians.GetXOffsetFromRotation(radian, 15, -15);
            float xOffset2 = Radians.GetXOffsetFromRotation(radian, 15, 15);
            float yOffset  = Radians.GetYOffsetFromRotation(radian, 15, -15);
            float yOffset2 = Radians.GetYOffsetFromRotation(radian, 15, 15);

            EmitterSimple emitter = EmitterSimple.NewEmitter(room, Systems.mapper.atlas[(byte)AtlasGroup.Objects], "Particles/AirPuff", new Vector2(posX, posY), new Vector2(0, 0), 0f, frame + duration, frame + duration - 25);

            // Launch First Particle
            emitter.AddParticle(
                new Vector2(
                    posX + xOffset,
                    posY + yOffset
                    ),
                new Vector2(
                    dirHor * -1.5f + (xOffset / 16),
                    dirVert * -1.5f + (yOffset / 16)
                    ),
                rad1 - 0.5f,
                0f
                );

            // Launch Second Particle
            emitter.AddParticle(
                new Vector2(
                    posX + xOffset2,
                    posY + yOffset2
                    ),
                new Vector2(
                    dirHor * -1.5f + (xOffset2 / 16),
                    dirVert * -1.5f + (yOffset2 / 16)
                    ),
                rad2 + 0.5f,
                0f
                );

            return(emitter);
        }
Beispiel #5
0
        public static EmitterSimple BoxExplosion(RoomScene room, string spriteName, int posX, int posY, sbyte xSpread = 3, sbyte ySpread = 3, byte duration = 55)
        {
            int frame = Systems.timer.Frame;

            EmitterSimple emitter = EmitterSimple.NewEmitter(room, Systems.mapper.atlas[(byte)AtlasGroup.Objects], spriteName, new Vector2(posX, posY), new Vector2(0, 0), 0.5f, frame + duration, frame + duration - 25);

            float radianUpLeft  = -1.82f;            // -5, -20
            float radianUpRight = -1.32f;            // 5, -20

            // Launch Up-Left Particle
            emitter.AddParticle(
                new Vector2(
                    posX - (int)Math.Floor(xSpread * CalcRandom.FloatBetween(0.5f, 2f)),
                    posY - (int)Math.Floor(ySpread * CalcRandom.FloatBetween(0.5f, 2f))
                    ),
                new Vector2(
                    CalcRandom.FloatBetween(-0.25f, -1.5f),
                    CalcRandom.FloatBetween(-9f, -13f)
                    ),
                radianUpLeft + CalcRandom.FloatBetween(-0.6f, 0.6f),
                -0.08f + CalcRandom.FloatBetween(-0.12f, 0.12f)
                );

            // Launch Up-Right Particle
            emitter.AddParticle(
                new Vector2(
                    posX + (int)Math.Floor(xSpread * CalcRandom.FloatBetween(0.5f, 2f)),
                    posY - (int)Math.Floor(ySpread * CalcRandom.FloatBetween(0.5f, 2f))
                    ),
                new Vector2(
                    CalcRandom.FloatBetween(0.25f, 1.5f),
                    CalcRandom.FloatBetween(-9f, -13f)
                    ),
                radianUpRight + CalcRandom.FloatBetween(-0.6f, 0.6f),
                0.08f + CalcRandom.FloatBetween(-0.12f, 0.12f)
                );

            // Launch Down-Left Particle
            emitter.AddParticle(
                new Vector2(
                    posX - (int)Math.Floor(xSpread * CalcRandom.FloatBetween(0.5f, 2f)),
                    posY + (int)Math.Floor(ySpread * CalcRandom.FloatBetween(0.5f, 2f))
                    ),
                new Vector2(
                    CalcRandom.FloatBetween(-0.25f, -1.5f),
                    CalcRandom.FloatBetween(-4f, -7f)
                    ),
                radianUpLeft + CalcRandom.FloatBetween(-0.6f, 0.6f),
                -0.08f + CalcRandom.FloatBetween(-0.12f, 0.12f)
                );

            // Launch Down-Right Particle
            emitter.AddParticle(
                new Vector2(
                    posX + (int)Math.Floor(xSpread * CalcRandom.FloatBetween(0.5f, 2f)),
                    posY + (int)Math.Floor(ySpread * CalcRandom.FloatBetween(0.5f, 2f))
                    ),
                new Vector2(
                    CalcRandom.FloatBetween(0.25f, 1.5f),
                    CalcRandom.FloatBetween(-4f, -7f)
                    ),
                radianUpRight + CalcRandom.FloatBetween(-0.6f, 0.6f),
                0.08f + CalcRandom.FloatBetween(-0.12f, 0.12f)
                );

            return(emitter);
        }