Ejemplo n.º 1
0
        public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
        {
            Color color = Color.White * (float)Math.Sin(StarlightWorld.rottime);

            spriteBatch.Draw(Glow, position, new Rectangle(0, 0, 32, 32), color, 0, origin, scale, SpriteEffects.None, 0);

            Vector2 pos = position + frame.Size() / 4 - Vector2.One + (Vector2.One * Main.rand.Next(12)).RotatedBy(Main.rand.NextFloat(0, 6.28f)) + new Vector2(0, 10);

            CursedSystem.AddParticle(new Particle(pos, new Vector2(0, -0.4f), 0, 1.25f, Color.White * 0.1f, 60, Vector2.Zero));

            drawpos = position + frame.Size() / 4;
        }
        public void OnHit()
        {
            Transform transform    = new Transform(m_transform, true);
            Sprite    impactSprite = new Sprite(Globals.TheGame, TextureLibrary.GetSpriteSheet("shuriken_impact"), transform);

            transform.Position  = m_shurikenBounds.GetRandomPoint(Globals.Random) - m_transform.PositionGlobal;
            transform.Direction = m_helper.GetAngle(m_shurikenBounds.Transform, transform);
            //transform.Direction += Globals.Random.NextDouble() - 0.5;

            Transform impactEffectTransform = new Transform(transform);

            impactEffectTransform.ScaleUniform = 6;
            impactEffectTransform.Direction   += 0.5f;
            m_hitParticles.AddParticle(new ImpactEffect(impactEffectTransform, ImpactTexture, 0.15f));

            double distance = m_helper.GetDistance(m_shurikenBounds.Transform.PositionGlobal, transform.PositionGlobal);

            transform.SclX = (float)(distance / m_shurikenBounds.Radius) + 0.2f;
            transform.SclY = 1 + (float)(Globals.Random.NextDouble() * 0.5);

            if (currentIndex == m_impacts.Length)
            {
                currentIndex = 0;
            }
            m_impacts[currentIndex] = impactSprite;
            currentIndex++;
        }
        public override void Draw(SpriteBatch spriteBatch, float opacity)
        {
            ParticleSystem.AddParticle(new Particle(Vector2.Zero, new Vector2(Main.rand.NextFloat(1.4f, 2.6f), Main.rand.NextFloat(-1.4f, -0.8f)), 0, Main.rand.NextFloat(1, 2), Color.White,
                                                    1500, new Vector2((StarlightWorld.permafrostCenter + Main.rand.Next(-400, 400)) * 16, 16 * (Main.maxTilesY - 40))));

            ParticleSystem.DrawParticles(Main.spriteBatch);
        }
        public void TestAsynchronousPrune()
        {
            using (
                ParticleSystemManager manager = new ParticleSystemManager(
                    this.mockedGraphicsDeviceService
                    )
                ) {
                // Add one particle system where there's stuff to do
                ParticleSystem <SimpleParticle> test = new ParticleSystem <SimpleParticle>(16);
                for (int index = 0; index < test.Capacity; ++index)
                {
                    test.AddParticle(new SimpleParticle());
                }
                manager.AddParticleSystem(test, slowPrune, new DummyRenderer <SimpleParticle>());

                // Add 16 other particle systems
                for (int index = 0; index < 16; ++index)
                {
                    manager.AddParticleSystem(
                        new ParticleSystem <SimpleParticle>(100),
                        dontPrune, new DummyRenderer <SimpleParticle>()
                        );
                }

                // Now update everything
                for (int repetition = 0; repetition < 2; ++repetition)
                {
                    IAsyncResult asyncResult = manager.BeginPrune(null, null);
                    manager.EndPrune(asyncResult);
                }
            }
        }
    void createPendulum(ParticleSystem a_ParticleSystem, float x, float y, float length, int n)
    {
        Particle prev = new Particle(1f);

        prev.Position = new Vector2(x, y);
        a_ParticleSystem.AddParticle(prev);
        new FixedPointConstraint(prev, a_ParticleSystem);
        for (int i = 1; i < n; i++)
        {
            Particle next = new Particle(1f);
            next.Position = new Vector2(x + length * i, y);
            a_ParticleSystem.AddParticle(next);
            new RodConstraint(prev, next, a_ParticleSystem);
            prev = next;
        }
    }
Ejemplo n.º 6
0
    public void CreateScenario(ParticleSystem a_ParticleSystem)
    {
        const int internalParticles = 8; //amount of particles in hair is this + 2
        Vector2   start             = new Vector2(-4f, 0f);
        Vector2   end = new Vector2(4f, 0f);

        Vector2 step = (end - start) / (internalParticles + 1);

        for (int i = 0; i <= internalParticles + 1; i++)
        {
            Particle p = new Particle(1f);
            p.Position = start + step * i;
            a_ParticleSystem.AddParticle(p);
        }

        //m_ParticleSystem.AddForce(new GravityForce(0.1f));
        float rest = step.magnitude;
        float ks   = 2f;
        float kd   = 1f;

        for (int i = 0; i <= internalParticles; i++)
        {
            a_ParticleSystem.AddForce(new HooksLawSpring(a_ParticleSystem.Particles[i], a_ParticleSystem.Particles[i + 1], rest, ks, kd));
        }
        ks = 2f;
        kd = 1f;
        float angle = 3 * Mathf.PI / 4;

        for (int i = 1; i <= internalParticles; i++)
        {
            a_ParticleSystem.AddForce(new AngularSpringForce(a_ParticleSystem.Particles[i], a_ParticleSystem.Particles[i - 1],
                                                             a_ParticleSystem.Particles[i + 1], angle, ks, kd));
        }
        a_ParticleSystem.AddForce(new ViscousDragForce(1f));
    }
        public void TestThrowDuringAsynchronousPrune()
        {
            using (
                ParticleSystemManager manager = new ParticleSystemManager(
                    this.mockedGraphicsDeviceService
                    )
                ) {
                ParticleSystem <SimpleParticle> test = new ParticleSystem <SimpleParticle>(4096);
                for (int index = 0; index < test.Capacity; ++index)
                {
                    test.AddParticle(new SimpleParticle());
                }

                manager.AddParticleSystem(
                    test,
                    delegate(ref SimpleParticle particle) { throw new ArithmeticException(); },
                    new DummyRenderer <SimpleParticle>()
                    );

                IAsyncResult asyncResult = manager.BeginPrune(null, null);
                Assert.Throws <ArithmeticException>(
                    delegate() { manager.EndPrune(asyncResult); }
                    );
            }
        }
Ejemplo n.º 8
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }
            input.ProcessInput(this, water, terrain);

            // Generate a direction within 15 degrees of (0, 1, 0)
            Vector3 offset    = new Vector3(MathHelper.ToRadians(10.0f));
            Vector3 randAngle = Vector3.Up + randVec3(-offset, offset);

            // Generate a position between (-400, 0, -400) and (400, 0, 400)
            Vector3 randPosition = randVec3(new Vector3(-400), new Vector3(400));

            // Generate a speed between 600 and 900
            float randSpeed = (float)r.NextDouble() * 300 + 600;

            ps.AddParticle(randPosition, randAngle, randSpeed);
            ps.Update();

            smoke.AddParticle(randPosition + new Vector3(0, 1200, 0), randAngle, randSpeed);
            smoke.Update();


            base.Update(gameTime);
        }
Ejemplo n.º 9
0
        public override void Update(GameTime gameTime)
        {
            float deltaSeconds = (float)gameTime.ElapsedGameTime.TotalSeconds;

            for (int i = 0; i < ParticlesPerFrame; i++)
            {
                particles.AddParticle(this.position, Vector3.Zero);
            }

            lastposition = position;

            this.Gravity(deltaSeconds);
            this.Move(deltaSeconds);
            this.windBlowing = ThumbstickOutOfDeadzone();

            this.position       += this.velocity;
            this.timeTillSpread -= deltaSeconds;
            if (this.currentState == Flames.NORMAL && this.windBlowing && timeTillSpread <= 0)
            {
                this.spreadManager.addSpread(this.position, this.flameSize);
                this.timeTillSpread = SPREADTIME;
            }

            base.Update(gameTime);
        }
Ejemplo n.º 10
0
        public static void Emit(Main main, string type, Vector3 position, float jitter, int amount)
        {
            ParticleSystem particleSystem = ParticleSystem.Get(main, type);

            for (int i = 0; i < amount; i++)
            {
                particleSystem.AddParticle(position + new Vector3(2.0f * ((float)random.NextDouble() - 0.5f) * jitter, 2.0f * ((float)random.NextDouble() - 0.5f) * jitter, 2.0f * ((float)random.NextDouble() - 0.5f) * jitter), Vector3.Zero);
            }
        }
Ejemplo n.º 11
0
        public static void Emit(Main main, string type, IEnumerable <Vector3> positions)
        {
            ParticleSystem particleSystem = ParticleSystem.Get(main, type);

            foreach (Vector3 pos in positions)
            {
                particleSystem.AddParticle(pos, Vector3.Zero);
            }
        }
Ejemplo n.º 12
0
        private void SpawnParticles()
        {
            if (craftTime < 40)
            {
                var p = new Particle(Vector2.Zero, Vector2.Zero, Main.rand.NextFloat(6.28f), 0, Color.White, 20, basePos + new Vector2(66, 16));
                particles.AddParticle(p);
            }

            if (craftTime == 60)
            {
                Main.PlaySound(SoundID.DD2_BetsyFireballImpact);
                for (int k = 0; k < 100; k++)
                {
                    var p = new Particle(Vector2.Zero, Vector2.Zero, Main.rand.NextFloat(6.28f), 0, Color.White, 40, basePos + new Vector2(128, 16));
                    particles.AddParticle(p);
                }
            }
        }
    public void CreateScenario(ParticleSystem a_ParticleSystem)
    {
        Particle prev = new Particle(1f);

        prev.Position = new Vector2(0, 1);
        a_ParticleSystem.AddParticle(prev);
        prev.Velocity = Vector2.right * 40;
        new EllipticalWireConstraint(prev, Vector2.left * Mathf.Sqrt(3), Vector2.right * Mathf.Sqrt(3), a_ParticleSystem); // 2x4 ellipse
        //a_ParticleSystem.AddForce(new ViscousDragForce(0.01f));
    }
Ejemplo n.º 14
0
        //#################################
        // Helper Update - Smoke
        //#################################

        /**
         * void UpdateSmoke(GameTime gameTime)
         * {
         *  // This is trivial: we just create one new smoke particle per frame.
         *  SmokeParticles.AddParticle(Vector3.Zero, Vector3.Zero);
         *  SmokeParticles.Update(gameTime);
         * }
         **/

        //#################################
        // Helper Update - Border
        //#################################
        void UpdateBorder(GameTime gameTime)
        {
            const int borderParticlesPerFrame = 50;

            // Create a number of border particles, randomly positioned around a circle.
            for (int i = 0; i < borderParticlesPerFrame; i++)
            {
                borderParticles.AddParticle(RandomPointOnCircle(Global.MapRingRadius), Vector3.Zero);
            }
            borderParticles.Update(gameTime);
        }
Ejemplo n.º 15
0
        public void Update(GameTime gameTime)
        {
            Instrument.Begin(InstrumentUpdate);

            //----------------------------------------------------------------
            // シーン設定

            SceneSettings.Update(gameTime);

            //----------------------------------------------------------------
            // 降雪パーティクル

            // TODO
            if (snowParticleSystem.Enabled)
            {
                int boundsX = 128 * 2;
                int boundsZ = 128 * 2;
                int minY    = 32;
                int maxY    = 64;

                for (int i = 0; i < 40; i++)
                {
                    var randomX  = random.Next(boundsX) - boundsX / 2;
                    var randomY  = random.Next(maxY - minY) + minY;
                    var randomZ  = random.Next(boundsZ) - boundsZ / 2;
                    var position = new Vector3(randomX, randomY, randomZ) + sceneManager.ActiveCamera.View.Position;
                    snowParticleSystem.AddParticle(position, Vector3.Zero);
                }
            }

            //----------------------------------------------------------------
            // 降雨パーティクル

            // TODO
            if (rainParticleSystem.Enabled)
            {
                int boundsX = 128 * 2;
                int boundsZ = 128 * 2;
                int minY    = 32;
                int maxY    = 64;

                for (int i = 0; i < 80; i++)
                {
                    var randomX  = random.Next(boundsX) - boundsX / 2;
                    var randomY  = random.Next(maxY - minY) + minY;
                    var randomZ  = random.Next(boundsZ) - boundsZ / 2;
                    var position = new Vector3(randomX, randomY, randomZ) + sceneManager.ActiveCamera.View.Position;
                    rainParticleSystem.AddParticle(position, Vector3.Zero);
                }
            }

            Instrument.End();
        }
        public override void Update(GameTime gameTime)
        {
            if (active)
            {
                for (int i = 0; i < intensity; i++)
                {
                    int index = Game1.random.Next(0, particles.Count);

                    ParticleSystem.AddParticle(position, particles[index]);
                }
            }
        }
Ejemplo n.º 17
0
    public void CreateScenario(ParticleSystem a_ParticleSystem)
    {
        Particle p1 = new Particle(1f);

        p1.Position = new Vector2(3, 4);
        Particle p2 = new Particle(1f);

        p2.Position = new Vector2(-3, 4);
        a_ParticleSystem.AddParticle(p1);
        a_ParticleSystem.AddParticle(p2);
        new CircularWireConstraint(p1, p1.Position + Vector2.right, a_ParticleSystem);
        new CircularWireConstraint(p2, p2.Position + Vector2.left, a_ParticleSystem);
        Particle p3 = new Particle(1);

        p3.Position = new Vector2(3, 2);
        Particle p4 = new Particle(1);

        p4.Position = new Vector2(-3, 2);
        Particle p5 = new Particle(1);

        p5.Position = new Vector2(-4, 0);
        Particle p6 = new Particle(1);

        p6.Position = new Vector2(0, 0);
        Particle p7 = new Particle(1);

        p7.Position = new Vector2(4, 0);
        a_ParticleSystem.AddParticle(p3);
        a_ParticleSystem.AddParticle(p4);
        a_ParticleSystem.AddParticle(p5);
        a_ParticleSystem.AddParticle(p6);
        a_ParticleSystem.AddParticle(p7);

        Force f1 = new HooksLawSpring(p1, p3, 1, 1, 1f);
        Force f2 = new HooksLawSpring(p2, p4, 1, 1, 1f);
        Force f3 = new HooksLawSpring(p3, p7, 1, 1, 1f);
        Force f4 = new HooksLawSpring(p3, p6, 1, 1, 1f);
        Force f5 = new HooksLawSpring(p4, p6, 1, 1, 1f);
        Force f6 = new HooksLawSpring(p4, p5, 1, 1, 1f);
        Force f7 = new HooksLawSpring(p7, p6, 3, 1, 1f);
        Force f8 = new HooksLawSpring(p7, p5, 3, 1, 1f);
        Force f9 = new HooksLawSpring(p6, p5, 3, 1, 1f);

        a_ParticleSystem.AddForce(f1);
        a_ParticleSystem.AddForce(f2);
        a_ParticleSystem.AddForce(f3);
        a_ParticleSystem.AddForce(f4);
        a_ParticleSystem.AddForce(f5);
        a_ParticleSystem.AddForce(f6);
        a_ParticleSystem.AddForce(f7);
        a_ParticleSystem.AddForce(f8);
        a_ParticleSystem.AddForce(f9);

        a_ParticleSystem.AddForce(new GravityForce(.1f));
    }
Ejemplo n.º 18
0
        public override void Update(GameTime gameTime)
        {
            Recalculate();

            if (tracked is null || tracked.life <= 0 || !tracked.active || !tracked.boss)
            {
                if (Timer == 0)
                {
                    Timer = 120;

                    ShardsSystem.SetTexture(Texture);

                    for (int x = 0; x < Texture.Width; x += 86)
                    {
                        for (int y = 0; y < Texture.Height; y += 23)
                        {
                            var pos   = bar.GetDimensions().Position() + new Vector2(x + 43, y + 11.5f);
                            var vel   = Vector2.UnitY.RotatedByRandom(0.3f) * -Main.rand.NextFloat(1, 4);
                            var frame = new Rectangle(x, y, 86, 23);

                            ShardsSystem.AddParticle(new Particle(pos, vel, 0, 1, Color.White, 120, Vector2.Zero, frame));
                        }
                    }

                    var tex = GetTexture("StarlightRiver/Assets/GUI/BossbarBack");

                    for (int x = 0; x < tex.Width; x += 12)
                    {
                        for (int y = 0; y < tex.Height; y += 11)
                        {
                            var pos   = bar.GetDimensions().Position() + new Vector2(x + 30, y + 14);
                            var vel   = Vector2.UnitY.RotatedByRandom(0.55f) * -Main.rand.NextFloat(1, 4);
                            var frame = new Rectangle(x, y, 12, 11);

                            ShardsSystem2.AddParticle(new Particle(pos, vel, 0, 1, Color.White, 120, Vector2.Zero, frame));
                        }
                    }
                }

                if (Timer == 1)
                {
                    visible = false;
                }

                Timer--;
            }

            if (tracked is null)
            {
                visible = false;
            }
        }
Ejemplo n.º 19
0
        //#################################
        // Helper Update - Fire
        //#################################
        void UpdateBorder(GameTime gameTime)
        {
            const int borderParticlesPerFrame = 100;

            // Create a number of fire particles, randomly positioned around a circle.
            for (int i = 0; i < borderParticlesPerFrame; i++)
            {
                borderParticles.AddParticle(RandomPointOnCircle(Global.MapRingRadius, 40), Vector3.Zero);
            }
            // Create one smoke particle per frmae, too.
            //SmokeParticles.AddParticle(RandomPointOnCircle(), Vector3.Zero);
            borderParticles.Update(gameTime);
        }
Ejemplo n.º 20
0
        public void Update(ParticleSystem particleSystem, float dt)
        {
            var velocityField = particleSystem.GetOrCreateField(ParticleFields.Velocity);

            // No more than 1000 particles
            if (particleSystem.ParticleCount < 1000)
            {
                var particle = particleSystem.AddParticle();

                // Default random velocity, going upward
                particle.Set(velocityField, new Vector3((float)rand.NextDouble() * 30.0f - 15.0f, (float)rand.NextDouble() * 30.0f - 15.0f, (float)rand.NextDouble() * 50.0f));
            }
        }
Ejemplo n.º 21
0
        public void Update(ParticleSystem particleSystem, float dt)
        {
            var velocityField = particleSystem.GetOrCreateField(ParticleFields.Velocity);

            // No more than 1000 particles
            if (particleSystem.ParticleCount < 1000)
            {
                var particle = particleSystem.AddParticle();

                // Default random velocity, going upward
                particle.Set(velocityField, new Vector3((float)rand.NextDouble() * 30.0f - 15.0f, (float)rand.NextDouble() * 30.0f - 15.0f, (float)rand.NextDouble() * 50.0f));
            }
        }
    public void CreateScenario(ParticleSystem a_ParticleSystem)
    {
        ViscousDragForce drag = new ViscousDragForce(0.1f);

        a_ParticleSystem.AddForce(drag);

        GravityForce gravity = new GravityForce(0.1f);

        a_ParticleSystem.AddForce(gravity);

        Particle p1 = new Particle(1f);

        p1.Position = new Vector2(-3f, 0f);
        a_ParticleSystem.AddParticle(p1);

        Particle p2 = new Particle(1f);

        p2.Position = new Vector2(3f, 0f);
        a_ParticleSystem.AddParticle(p2);

        HooksLawSpring spring1 = new HooksLawSpring(p1, p2, 3f, 10f, 10f);

        a_ParticleSystem.AddForce(spring1);
    }
        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            KeyboardState keyboard = Keyboard.GetState();

            IPlayer player = (IPlayer)Game.Services.GetService(typeof(IPlayer));

            if (!player.PlayerIndexSet)
            {
                for (PlayerIndex index = PlayerIndex.One; index <= PlayerIndex.Four; index++)
                {
                    if (GamePad.GetState(index).Buttons.Start == ButtonState.Pressed || keyboard.IsKeyDown(Keys.E))
                    {
                        player.PlayerIndexSaved = index;
                        player.PlayerIndexSet   = true;
                        NextState   = (int)MageDefenderStates.MainMenu;
                        ChangeState = true;
                        break;
                    }
                }
            }

            camera.Update(gameTime);
            magicMissilePartilces.SetCamera(camera.ViewMatrix, camera.ProjectionMatrix);
            magicMissilePartilces2.SetCamera(camera.ViewMatrix, camera.ProjectionMatrix);
            magicMissilePartilces3.SetCamera(camera.ViewMatrix, camera.ProjectionMatrix);

            for (int i = 0; i < 1; i++)
            {
                magicMissilePartilces.AddParticle(new Vector3(0.0f, 0.0f, 0.0f), Vector3.Zero);
            }
            for (int i = 0; i < 5; i++)
            {
                magicMissilePartilces2.AddParticle(new Vector3(21.0f + (float)Math.Sin((float)gameTime.TotalGameTime.Milliseconds), -2.0f + (float)Math.Cos((float)gameTime.TotalGameTime.Milliseconds), 0.0f), Vector3.Zero);
            }
            for (int i = 0; i < 5; i++)
            {
                magicMissilePartilces3.AddParticle(new Vector3(21.0f + (float)Math.Sin((float)gameTime.TotalGameTime.Milliseconds), -2.0f + (float)Math.Cos((float)gameTime.TotalGameTime.Milliseconds), 0.0f), Vector3.Zero);
            }

            magicMissilePartilces.Update(gameTime);
            magicMissilePartilces2.Update(gameTime);
            magicMissilePartilces3.Update(gameTime);

            base.Update(gameTime);
        }
        public void TestDraw()
        {
            using (
                ParticleSystemManager manager = new ParticleSystemManager(
                    this.mockedGraphicsDeviceService
                    )
                ) {
                // Add one particle system where there's stuff to do
                ParticleSystem <SimpleParticle> test = new ParticleSystem <SimpleParticle>(4096);
                for (int index = 0; index < test.Capacity; ++index)
                {
                    test.AddParticle(new SimpleParticle());
                }
                manager.AddParticleSystem(test, dontPrune, new DummyRenderer <SimpleParticle>());

                manager.Draw(new GameTime());
            }
        }
Ejemplo n.º 25
0
 public void Update(GameTime gameTime, Vector3 targetPosition)
 {
     foreach (var ast in _asteroidList)
     {
         ast.Update(gameTime);
         if (ast.IsShiny)
         {
             shinyParticles.AddParticle(ast.Position, -ast.Direction * ast.Speed);
         }
     }
     if (_asteroidList.Count < _asteroidNumber)
     {
         int    movespeed;
         double angle;
         int    size = _rand.Next(0, 11);
         int    noise;
         int    astAngle;
         int    shinyness;
         while (_asteroidList.Count < _asteroidNumber)
         {
             movespeed = _rand.Next(20, 100);
             astAngle  = _rand.Next(-360, 360);
             noise     = _rand.Next(0, 90);
             shinyness = _rand.Next(0, 21);
             angle     = _rand.NextDouble() * Math.PI * 2;
             Vector3 position  = new Vector3(Global.MapSpawnRadius * (float)Math.Cos(angle), 0, Global.MapSpawnRadius * (float)Math.Sin(angle));
             Vector3 direction = new Vector3(Global.MapSpawnRadius * (float)Math.Cos(angle + 180d), 0, Global.MapSpawnRadius * (float)Math.Sin(angle + 180d)) - position;
             direction.Normalize();
             Asteroid ast;
             if (shinyness == 10)
             {
                 ast = new Asteroid(_model, position, astAngle, direction, (float)movespeed / 100, true);
             }
             else
             {
                 ast = new Asteroid(_model, position, astAngle, direction, (float)movespeed / 100, false);
             }
             ast.LoadContent();
             _asteroidList.Add(ast);
         }
     }
     shinyParticles.Update(gameTime);
 }
Ejemplo n.º 26
0
        public static void newDraw(Texture2D drawnTexture, UIElement self)
        {
            var spriteBatch = Main.spriteBatch;

            if (drawnTexture == ModContent.GetTexture("StarlightRiver/Assets/BossChecklist/VitricBoss"))             //todo: More general to avoid this becoming a weird godclass
            {
                if (Main.rand.Next(2) == 0)
                {
                    ceirosSystem.AddParticle(new Particle(self.GetDimensions().Center() + Vector2.One.RotatedByRandom(6.28f) * Main.rand.NextFloat(100), Vector2.UnitY * -3, 0, Main.rand.NextFloat(0.3f), new Color(200, 200, 0), 100, Vector2.Zero));
                }

                float sin = 0.6f + (float)Math.Sin(Main.GameUpdateCount / 100f) * 0.2f;

                var tex  = ModContent.GetTexture("StarlightRiver/Assets/BossChecklist/VitricBossGlow");
                var tex2 = ModContent.GetTexture("StarlightRiver/Assets/Keys/Glow");
                spriteBatch.Draw(tex2, self.GetDimensions().ToRectangle(), null, Color.Black * 0.6f, 0, Vector2.UnitY * 2, 0, 0);

                spriteBatch.End();
                spriteBatch.Begin(default, BlendState.Additive, default, default, default, default, Main.UIScaleMatrix);
Ejemplo n.º 27
0
    public void CreateScenario(ParticleSystem a_ParticleSystem)
    {
        const float flatness = .975f;
        Vector2     dir      = new Vector2(2, -8);
        Vector2     dir2     = new Vector2(2, 8);

        Particle p1 = new Particle(1);

        p1.Position = new Vector2(-6, 4);
        a_ParticleSystem.AddParticle(p1);
        new EllipticalWireConstraint(p1, p1.Position + (1 - flatness) * dir, p1.Position + flatness * dir, a_ParticleSystem);

        Particle p2 = new Particle(1);

        p2.Position = new Vector2(-3, -4);
        a_ParticleSystem.AddParticle(p2);
        new EllipticalWireConstraint(p2, p2.Position + flatness * dir2, p2.Position + (1 - flatness) * dir2, a_ParticleSystem);


        Particle p3 = new Particle(1);

        p3.Position = new Vector2(0, 4);
        a_ParticleSystem.AddParticle(p3);
        new EllipticalWireConstraint(p3, p3.Position + (1 - flatness) * dir, p3.Position + flatness * dir, a_ParticleSystem);

        Particle p4 = new Particle(1);

        p4.Position = new Vector2(3, -4);
        a_ParticleSystem.AddParticle(p4);
        new EllipticalWireConstraint(p4, p4.Position + flatness * dir2, p4.Position + (1 - flatness) * dir2, a_ParticleSystem);

        a_ParticleSystem.AddForce(new HooksLawSpring(p1, p3, (p1.Position - p3.Position).magnitude, 1, 1));
        a_ParticleSystem.AddForce(new HooksLawSpring(p2, p4, (p2.Position - p4.Position).magnitude, 1, 1));
        //a_ParticleSystem.AddForce(new HooksLawSpring(p3, p4, (p3.Position - p4.Position).magnitude, 1, 1));

        Particle p5 = new Particle(1);

        p5.Position = new Vector2(6, 0);
        a_ParticleSystem.AddParticle(p5);
        new HLineConstraint(p5, a_ParticleSystem);
        Particle p6 = new Particle(1);

        p6.Position = new Vector2(6, 0);
        a_ParticleSystem.AddParticle(p6);
        new HLineConstraint(p6, a_ParticleSystem);
        a_ParticleSystem.AddForce(new HooksLawSpring(p1, p5, 1, 1));
        a_ParticleSystem.AddForce(new HooksLawSpring(p2, p6, 1, 1));
        a_ParticleSystem.AddForce(new HooksLawSpring(p3, p5, 1, 1));
        a_ParticleSystem.AddForce(new HooksLawSpring(p4, p6, 1, 1));
    }
Ejemplo n.º 28
0
    public void CreateScenario(ParticleSystem a_ParticleSystem)
    {
        const float flatness = .95f;
        Vector2     a        = new Vector2(4, -6);
        Vector2     a2       = new Vector2(a.y, -a.x);
        Vector2     b        = new Vector2(-a.x / 2, -a.y / 2);

        Particle p1 = new Particle(1);

        p1.Position = b;
        a_ParticleSystem.AddParticle(p1);
        Vector2 f1 = p1.Position + (1 - flatness) * a;
        Vector2 f2 = p1.Position + flatness * a;

        new EllipticalWireConstraint(p1, f1, f2, a_ParticleSystem);

        Particle p2 = new Particle(1);

        p2.Position = b;
        a_ParticleSystem.AddParticle(p2);
        new AnyLineConstraint(p2, a, a_ParticleSystem);

        Particle p3 = new Particle(1);

        p3.Position = new Vector2(0, 0);
        a_ParticleSystem.AddParticle(p3);
        new AnyLineConstraint(p3, a2, a_ParticleSystem);

        a_ParticleSystem.AddForce(new HooksLawSpring(p1, p2, 0, 5, 1));
        a_ParticleSystem.AddForce(new HooksLawSpring(p1, p3, 0, 1, 1));

        Particle q1 = new Particle(1);
        Particle q2 = new Particle(1);

        q1.Position = f1;
        q2.Position = f2;
        a_ParticleSystem.AddParticle(q1);
        a_ParticleSystem.AddParticle(q2);
        new FixedPointConstraint(q1, a_ParticleSystem);
        new FixedPointConstraint(q2, a_ParticleSystem);

        Particle p4 = new Particle(1);

        p4.Position = p1.Position + a;
        a_ParticleSystem.AddParticle(p4);
        new EllipticalWireConstraint(p4, f1, f2, a_ParticleSystem);
        a_ParticleSystem.AddForce(new HooksLawSpring(q1, p4, 0, 0, 0));
        a_ParticleSystem.AddForce(new HooksLawSpring(q2, p4, 0, 0, 0));
    }
Ejemplo n.º 29
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            LedorSystem.AddParticle(new Vector3(0, 50, 0));

            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            angle += 0.01f;
            view   = Matrix.CreateLookAt(
                new Vector3(5 * (float)Math.Sin(angle), -2, 5 * (float)Math.Cos(angle)),
                new Vector3(0, 0, 0),
                Vector3.UnitY);

            LedorSystem.Update(gameTime);

            base.Update(gameTime);
        }
        public override void Draw(SpriteBatch spriteBatch, float opacity)
        {
            int direction = Main.dungeonX > Main.spawnTileX ? -1 : 1;

            if (StarlightWorld.rottime == 0)
            {
                for (int k = 0; k < 10; k++)
                {
                    for (int i = (int)Main.worldSurface; i < Main.maxTilesY - 200; i += 20)
                    {
                        ParticleSystem.AddParticle(new Particle(new Vector2(0, 0), new Vector2(0.4f, Main.rand.NextFloat(-2, -1)), 0, Main.rand.NextFloat(1.5f, 2),
                                                                Color.White * 0.05f, 600, new Vector2(Main.dungeonX * 16 + k * (800 * direction) + Main.rand.Next(30), i * 16)));

                        ParticleSystem.AddParticle(new Particle(new Vector2(0, 0), new Vector2(0.15f, Main.rand.NextFloat(-2, -1)), 0, Main.rand.NextFloat(0.5f, 0.8f),
                                                                Color.White * 0.05f, 600, new Vector2(Main.dungeonX * 16 + k * (900 * direction) + Main.rand.Next(15), i * 16)));
                    }
                }
            }

            ParticleSystem.DrawParticles(Main.spriteBatch);
        }
        public void TestThrowDuringAsynchronousUpdate()
        {
            using (
                ParticleSystemManager manager = new ParticleSystemManager(
                    this.mockedGraphicsDeviceService
                    )
                ) {
                ParticleSystem <SimpleParticle> test = new ParticleSystem <SimpleParticle>(4096);
                for (int index = 0; index < test.Capacity; ++index)
                {
                    test.AddParticle(new SimpleParticle());
                }
                test.Affectors.Add(new ExceptionThrowingAffector());

                manager.AddParticleSystem(test, dontPrune, new DummyRenderer <SimpleParticle>());

                IAsyncResult asyncResult = manager.BeginUpdate(1, 1, null, null);
                Assert.Throws <ArithmeticException>(
                    delegate() { manager.EndUpdate(asyncResult); }
                    );
            }
        }
        //        public Tpl_PogoZombie()
        //    : base(typeof(PogoZombie), "e_pz")
        //{
        //    _hp = 3;
        //    _speed = 2.4f;
        //    _jumpForce = 25;
        //    _appearanceRate = 30;
        //}
        public PogoZombie()
            : base()
        {
            m_jumpForce = Globals.Random.Next(-JumpForceInterval, JumpForceInterval + 1) + JumpForce;

            m_sprite = new Sprite(Globals.TheGame, TextureLibrary.GetSpriteSheet("zombie_pogo", 1, 8), Transform);
            m_sprite.Origin = new Vector2(0.5f, 1.0f);
            m_physics = new PhysicsComponent(Globals.TheGame, Transform);
            m_loot = Loot.GenerateLoot(12);

            m_currentFrame = 0;

            ObjectState.BeginAction = delegate()
            {
                m_sprite.SetFrame(m_currentFrame);
            };
            ObjectState.StandbyAction = delegate()
            {
                m_sprite.SetFrame(m_currentFrame + 1);
            };
            ObjectState.DestroyAction = delegate()
            {
                m_destructible.ClearHitEvents();
                Backpacker.HitPlayerColliders.Remove(m_collider);
            };

            m_collider = new AABBCollider(this, new AABB(m_sprite));
            Backpacker.HitPlayerColliders.Add(m_collider, delegate(Collider other) { m_physics.Throw(10.0f, -10.0f, 0.1f); });

            m_destructible = new DestructibleComponent(Transform, m_collider, m_collider.AABB, 4);
            m_hitAnimation = new HitAnimation(World.baseEffect);
            m_impactBox = new AABB(new Transform(Transform, true), new Vector2(20, 60));
            m_impactBox.Transform.Position = new Vector2(5, -54);
            m_shurikenReceiver = new ShurikenReceiver(Transform, m_impactBox, 5);
            m_measurer = new AABBMeasurer(m_impactBox);

            //_projections = new BodyPart[] {
            //    null,
            //    new BodyPart(this, new Vector2(0, -65), "bp_basezombiearm"),
            //    new BodyPart(this, new Vector2(-10, -55), "bp_basezombiearm"),
            //    new BodyPart(this, new Vector2(15, -75), "bp_basezombiehead"),
            //};

            //_destroyProjections = new BodyPart[]
            //{
            //    new BodyPart(this, new Vector2(10, -50), "bp_basezombieupperb"),
            //    new BodyPart(this, new Vector2(10, -50), "bp_pogostick"),
            //    new BodyPart(this, new Vector2(10, -10), "bp_basezombielowerb")
            //};

            ///
            ///	Body parts
            ///

            m_bodyParts = new ParticleSystem(Globals.TheGame, 6);

            m_head = new BodyPart(TextureLibrary.GetSpriteSheet("bp_basezombiehead"), new Transform(Transform, true));
            m_head.Transform.Position = new Vector2(7, -97);
            m_bodyParts.AddParticle(m_head);

            m_armR = new BodyPart(TextureLibrary.GetSpriteSheet("bp_basezombiearm"), new Transform(Transform, true));
            m_armR.Transform.Position = new Vector2(-20, -70);
            m_bodyParts.AddParticle(m_armR);

            m_lowerB = new BodyPart(TextureLibrary.GetSpriteSheet("bp_basezombielowerb"), new Transform(Transform, true));
            m_lowerB.Transform.Position = new Vector2(0, -40);
            m_bodyParts.AddParticle(m_lowerB);

            m_upperB = new BodyPart(TextureLibrary.GetSpriteSheet("bp_basezombieupperb"), new Transform(Transform, true));
            m_upperB.Transform.Position = new Vector2(0, -65);
            m_bodyParts.AddParticle(m_upperB);

            m_armL = new BodyPart(TextureLibrary.GetSpriteSheet("bp_basezombiearm"), new Transform(Transform, true));
            m_armL.Transform.Position = new Vector2(-20, -70);
            m_bodyParts.AddParticle(m_armL);

            m_pogoStick = new BodyPart(TextureLibrary.GetSpriteSheet("bp_pogostick"), new Transform(Transform, true));
            m_pogoStick.Transform.Position = new Vector2(-6, -40);
            m_bodyParts.AddParticle(m_pogoStick);

            ///
            ///Hit events
            ///
            m_destructible.SetHitEvent(AttackType.Shuriken, OnShurikenHit);
            m_destructible.SetHitEvent(AttackType.Slash, OnSliceHit);

            ///
            /// Health events
            ///
            m_destructible.AddHealthEvent(3, false, new MethodAction(delegate()
            {
                m_currentFrame = 2;
                m_sprite.SetFrame(m_currentFrame);
                m_head.Pop(-1.1f, 800, true);
            }));
            m_destructible.AddHealthEvent(2, false, new MethodAction(delegate()
            {
                m_currentFrame = 4;
                m_sprite.SetFrame(m_currentFrame);
                m_armL.Pop(-1.1f, 800, true);
            }));
            m_destructible.AddHealthEvent(1, false, new MethodAction(delegate()
            {
                m_currentFrame = 6;
                m_sprite.SetFrame(m_currentFrame);
                m_armR.Pop(-1.1f, 800, true);
            }));
            m_destructible.AddHealthEvent(0, false, new MethodAction(delegate()
            {
                m_upperB.Pop(-1.1f, 800, true);
                m_lowerB.Pop(-1.1f, 800, true);
                m_pogoStick.Pop(-1.1f, 200, true);
                ObjectState.Destroy();
            }));

            ObjectState.Begin();
        }
Ejemplo n.º 33
0
 protected void EmitParticle(ParticleSystem particleSystem, Particle particle)
 {
     particleSystem.AddParticle(particle);
 }
Ejemplo n.º 34
0
        public void UpdateAmmo(GameTime gameTime, ScreenManager ScreenManager, ParticleSystem explosionParticles, Ship enemy, List<Building> buildings)
        {
            // Update bullets
            for (int i = bullets.Count - 1; i >= 0; i--)
            {
                bullets[i].Update(gameTime);

                if (bullets[i].position.Y < 0)
                {
                    bullets.RemoveAt(i);
                    break;
                }

                // Collision with enemy
                if (bullets[i].bulletSphere.Intersects(enemy.boundingSphere))
                {
                    bullets.RemoveAt(i);
                    enemy.life -= 5.0f;
                    enemy.vibrationLeft = enemy.vibrationRight = 0.6f;
                    break;
                }
            }

            // Update missiles
            for (int i = missiles.Count - 1; i >= 0; i--)
            {
                // Update missile
                missiles[i].Update(gameTime);

                // Hit ground
                if (missiles[i].position.Y < 0)
                {
                    ScreenManager.Sound.PlayMissileExplosion(missiles[i].position, Position);
                    ScreenManager.Sound.PlayMissileExplosion(missiles[i].position, enemy.Position);
                    explosionParticles.AddParticle(missiles[i].position, new Vector3(0, 0, 0));
                    missiles.RemoveAt(i);
                    break;
                }

                // Hit enemy
                if (missiles[i].missileSphere.Intersects(enemy.boundingSphere))
                {
                    ScreenManager.Sound.PlayMissileExplosion(missiles[i].position, Position);
                    ScreenManager.Sound.PlayMissileExplosion(missiles[i].position, enemy.Position);
                    explosionParticles.AddParticle(missiles[i].position, new Vector3(0, 0, 0));
                    enemy.life -= 30.0f;
                    enemy.vibrationLeft = enemy.vibrationRight = 1.0f;
                    missiles.RemoveAt(i);
                    break;
                }

                for (int j = buildings.Count - 1; j >= 0; j--)
                {
                    if (missiles[i].missileSphere.Intersects(buildings[j].boundingBox))
                    {
                        ScreenManager.Sound.PlayMissileExplosion(missiles[i].position, Position);
                        ScreenManager.Sound.PlayMissileExplosion(missiles[i].position, enemy.Position);
                        explosionParticles.AddParticle(missiles[i].position, new Vector3(0, 0, 0));
                        missiles.RemoveAt(i);
                        break;
                    }
                }
            }

            DeleteDeadBullet();
            DeleteDeadMissile();
        }
Ejemplo n.º 35
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            tex = Content.Load<Texture2D>("Particle");
            tex2 = Content.Load<Texture2D>("Particle");
            position = new Vector2(0, 0);
            Vector2 pos2 = new Vector2(90, 90);
            Vector2 pos3 = new Vector2(60, 40);
            rotation = 90*(float)Math.PI/180;
            scale = new Vector2(2.5f);
            origin = new Vector2(tex.Bounds.Center.X, tex.Bounds.Center.Y);
            origin2 = new Vector2(tex2.Bounds.Center.X, tex2.Bounds.Center.Y);
            camera = new Camera2D(GraphicsDevice);

            effect = Content.Load<Effect>("ParticleEffect");
            effect.Parameters["World"].SetValue(Matrix.Identity);
            effect.Parameters["Projection"].SetValue(Matrix.CreateOrthographicOffCenter(0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 0, 10));
            effect.Parameters["View"].SetValue(Matrix.CreateLookAt(new Vector3(0, 0, 1), Vector3.Zero, Vector3.Up));
            
            
            vertices = new ParticleVertex[12]
            {

                new ParticleVertex(new Vector3(
                    (position.X - origin2.X* scale.X * (float)Math.Cos(rotation) + origin2.Y* scale.Y * (float)Math.Sin(rotation)) ,
                    (position.Y - origin2.X* scale.X * (float)Math.Sin(rotation) - origin2.Y* scale.Y * (float)Math.Cos(rotation)),
                    0),
                    Color.Green,
                    new Vector2(0,0),
                    Vector2.Zero,
                    4,1),

                new ParticleVertex(new Vector3(
                    (position.X + (tex2.Width - origin2.X)* scale.X * (float)Math.Cos(rotation) + origin2.Y* scale.Y * (float)Math.Sin(rotation)),
                    (position.Y + (tex2.Width - origin2.X)* scale.X * (float)Math.Sin(rotation) - origin2.Y* scale.Y * (float)Math.Cos(rotation)),
                    0),
                    Color.Green,
                    new Vector2(1,0),
                    Vector2.Zero,
                    4,1),

                new ParticleVertex(new Vector3(
                    (position.X + (tex2.Width - origin2.X)* scale.X *  (float)Math.Cos(rotation) - (-origin2.Y+tex2.Height)* scale.Y* (float)Math.Sin(rotation)),
                    (position.Y + (tex2.Width - origin2.X)* scale.X *  (float)Math.Sin(rotation) + (-origin2.Y+tex2.Height)* scale.Y *(float)Math.Cos(rotation)),
                    0),
                    Color.Green,
                    new Vector2(1,1),
                    Vector2.Zero,
                    4,1),

                new ParticleVertex(new Vector3(
                    (position.X - origin2.X* scale.X* (float)Math.Cos(rotation)-(-origin2.Y+tex2.Height)* scale.Y* (float)Math.Sin(rotation)),
                    (position.Y -origin2.X* scale.X* (float)Math.Sin(rotation)+(-origin2.Y+tex2.Height)* scale.Y* (float)Math.Cos(rotation)),
                    0),
                    Color.Green,
                    new Vector2(0,1),
                    Vector2.Zero,
                    4,1),



                new ParticleVertex(new Vector3(
                    (pos2.X - origin2.X* scale.X * (float)Math.Cos(rotation) + origin2.Y* scale.Y * (float)Math.Sin(rotation)) ,
                    (pos2.Y - origin2.X* scale.X * (float)Math.Sin(rotation) - origin2.Y* scale.Y * (float)Math.Cos(rotation)),
                    0),
                    Color.Green,
                    new Vector2(0,0),
                    Vector2.Zero,
                    4,1),

                new ParticleVertex(new Vector3(
                    (pos2.X + (tex2.Width - origin2.X)* scale.X * (float)Math.Cos(rotation) + origin2.Y* scale.Y * (float)Math.Sin(rotation)),
                    (pos2.Y + (tex2.Width - origin2.X)* scale.X * (float)Math.Sin(rotation) - origin2.Y* scale.Y * (float)Math.Cos(rotation)),
                    0),
                    Color.Green,
                    new Vector2(1,0),
                    Vector2.Zero,
                    4,1),

                new ParticleVertex(new Vector3(
                    (pos2.X + (tex2.Width - origin2.X)* scale.X *  (float)Math.Cos(rotation) - (-origin2.Y+tex2.Height)* scale.Y* (float)Math.Sin(rotation)),
                    (pos2.Y + (tex2.Width - origin2.X)* scale.X *  (float)Math.Sin(rotation) + (-origin2.Y+tex2.Height)* scale.Y *(float)Math.Cos(rotation)),
                    0),
                    Color.Green,
                    new Vector2(1,1),
                    Vector2.Zero,
                    4,1),

                new ParticleVertex(new Vector3(
                    (pos2.X - origin2.X* scale.X* (float)Math.Cos(rotation)-(-origin2.Y+tex2.Height)* scale.Y* (float)Math.Sin(rotation)),
                    (pos2.Y -origin2.X* scale.X* (float)Math.Sin(rotation)+(-origin2.Y+tex2.Height)* scale.Y* (float)Math.Cos(rotation)),
                    0),
                    Color.Green,
                    new Vector2(0,1),
                    Vector2.Zero,
                    4,1),




                new ParticleVertex(new Vector3(
                    (pos3.X - origin2.X* scale.X * (float)Math.Cos(rotation) + origin2.Y* scale.Y * (float)Math.Sin(rotation)) ,
                    (pos3.Y - origin2.X* scale.X * (float)Math.Sin(rotation) - origin2.Y* scale.Y * (float)Math.Cos(rotation)),
                    0),
                    Color.Green,
                    new Vector2(0,0),
                    Vector2.Zero,
                    4,1),

                new ParticleVertex(new Vector3(
                    (pos3.X + (tex2.Width - origin2.X)* scale.X * (float)Math.Cos(rotation) + origin2.Y* scale.Y * (float)Math.Sin(rotation)),
                    (pos3.Y + (tex2.Width - origin2.X)* scale.X * (float)Math.Sin(rotation) - origin2.Y* scale.Y * (float)Math.Cos(rotation)),
                    0),
                    Color.Green,
                    new Vector2(1,0),
                    Vector2.Zero,
                    4,1),

                new ParticleVertex(new Vector3(
                    (pos3.X + (tex2.Width - origin2.X)* scale.X *  (float)Math.Cos(rotation) - (-origin2.Y+tex2.Height)* scale.Y* (float)Math.Sin(rotation)),
                    (pos3.Y + (tex2.Width - origin2.X)* scale.X *  (float)Math.Sin(rotation) + (-origin2.Y+tex2.Height)* scale.Y *(float)Math.Cos(rotation)),
                    0),
                    Color.Green,
                    new Vector2(1,1),
                    Vector2.Zero,
                    4,1),

                new ParticleVertex(new Vector3(
                    (pos3.X - origin2.X* scale.X* (float)Math.Cos(rotation)-(-origin2.Y+tex2.Height)* scale.Y* (float)Math.Sin(rotation)),
                    (pos3.Y -origin2.X* scale.X* (float)Math.Sin(rotation)+(-origin2.Y+tex2.Height)* scale.Y* (float)Math.Cos(rotation)),
                    0),
                    Color.Green,
                    new Vector2(0,1),
                    Vector2.Zero,
                    4,1),
            };
            indices = new int[18] { 0, 1, 2, 0, 2, 3,
                4,5,6  ,4,6,7,
                8,9,10,   8,10,11};
            
            ps = new ParticleSystem<TestParticle>(this);
            for (int i = 0; i < 128; i++)
            {
                Vector2 dir = RandomVector();
                dir.Normalize();
                ps.AddParticle(RandomVector(), dir, .04f, 0);
            }
        }
        public FatZombie()
        {
            m_physics = new PhysicsComponent(Globals.TheGame, Transform);
            m_sprite = new Sprite(Globals.TheGame, TextureLibrary.GetSpriteSheet("zombie_phat", 1, 12), Transform);
            m_sprite.Origin = new Vector2(0.5f, 1);
            m_loot = Loot.GenerateLoot(12);

            ObjectState.BeginAction = delegate() { m_actionManager.StartNew(m_full); };
            ObjectState.StandbyAction = delegate() { m_actionManager.Stop(); m_sprite.SetFrame(0); };
            ObjectState.DestroyAction = delegate() { m_destructible.ClearHitEvents(); Backpacker.HitPlayerColliders.Remove(m_collider); };

            m_collider = new AABBCollider(this, new AABB(m_sprite));
            Backpacker.HitPlayerColliders.Add(m_collider, delegate(Collider other) { m_physics.Throw(10.0f, -10.0f, 0.1f); } );

            m_destructible = new DestructibleComponent(Transform, m_collider, m_collider.AABB, HP);

            m_impactBox = new AABB(new Transform(Transform, true), new Vector2(72, 67));
            m_impactBox.Transform.Position = new Vector2(13, -70);
            m_shurikenReceiver = new ShurikenReceiver(Transform, m_impactBox, 10);
            m_hitAnimation = new HitAnimation(World.baseEffect);
            m_measurer = new AABBMeasurer(new AABB(new Transform(Transform, true), new Vector2(50, 50)));

            m_full = new SpriteSheetAnimation(m_sprite, 0, 1, 0.7f, -1);
            m_noHead1 = new SpriteSheetAnimation(m_sprite, 2, 3, 0.7f, -1);
            m_noHead2 = new SpriteSheetAnimation(m_sprite, 4, 5, 0.7f, -1);
            m_noRightArm = new SpriteSheetAnimation(m_sprite, 6, 7, 0.7f, -1);
            m_noLeftArm = new SpriteSheetAnimation(m_sprite, 8, 9, 0.7f, -1);
            m_noShoulders = new SpriteSheetAnimation(m_sprite, 10, 11, 0.7f, -1);

            m_actionManager = new SingleActionManager();
            m_actionManager.StartNew(m_full);

            //_projections = new BodyPart[]
            //{
            //    null,
            //    new BodyPart(this, new Vector2(0, -55), "bp_fatshoulders"),
            //    new BodyPart(this, new Vector2(-15, -75), "bp_basezombiearm"),
            //    new BodyPart(this, new Vector2(-15, -75), "bp_basezombiearm"),
            //    new BodyPart(this, new Vector2(-30, -100), "bp_fathead2"),
            //    new BodyPart(this, new Vector2(-30, -115), "bp_fathead1"),
            //};

            //_destroyProjections = new BodyPart[] {
            //    new BodyPart(this, new Vector2(0, -45), "bp_fatupperb"),
            //    new BodyPart(this, new Vector2(0, -10), "bp_fatlowerb"),
            //};
            m_bodyParts = new ParticleSystem(Globals.TheGame, 7);

            m_head1 = new BodyPart(TextureLibrary.GetSpriteSheet("bp_fathead1"), new Transform(Transform, true));
            m_head1.Transform.Position = new Vector2(-30, -110);
            m_bodyParts.AddParticle(m_head1);

            m_head2 = new BodyPart(TextureLibrary.GetSpriteSheet("bp_fathead2"), new Transform(Transform, true));
            m_head2.Transform.Position = new Vector2(-30, -100);
            m_bodyParts.AddParticle(m_head2);

            m_shoulders = new BodyPart(TextureLibrary.GetSpriteSheet("bp_fatshoulders"), new Transform(Transform, true));
            m_shoulders.Transform.Position = new Vector2(0, -80);
            m_bodyParts.AddParticle(m_shoulders);

            m_armL = new BodyPart(TextureLibrary.GetSpriteSheet("bp_basezombiearm"), new Transform(Transform, true));
            m_armL.Transform.Position = new Vector2(-15, -75);
            m_bodyParts.AddParticle(m_armL);

            m_armR = new BodyPart(TextureLibrary.GetSpriteSheet("bp_basezombiearm"), new Transform(Transform, true));
            m_armR.Transform.Position = new Vector2(-15, -75);
            m_bodyParts.AddParticle(m_armR);

            m_upperB = new BodyPart(TextureLibrary.GetSpriteSheet("bp_fatupperb"), new Transform(Transform, true));
            m_upperB.Transform.Position = new Vector2(15, -65);
            m_bodyParts.AddParticle(m_upperB);

            m_lowerB = new BodyPart(TextureLibrary.GetSpriteSheet("bp_fatlowerb"), new Transform(Transform, true));
            m_lowerB.Transform.Position = new Vector2(15, -27);
            m_bodyParts.AddParticle(m_lowerB);

            ///
            ///Hit events
            ///
            m_destructible.SetHitEvent(AttackType.Shuriken, OnShurikenHit);
            m_destructible.SetHitEvent(AttackType.Slash, OnSliceHit);

            ///
            /// Health events
            ///
            m_destructible.AddHealthEvent(7, false, new MethodAction(delegate()
            {
                m_actionManager.StartNew(m_noHead1);
                m_head1.Pop(-1.1f, 500, true);
            }));
            m_destructible.AddHealthEvent(6, false, new MethodAction(delegate()
            {
                m_actionManager.StartNew(m_noHead2);
                m_head2.Pop(-1.1f, 500, true);
            }));
            m_destructible.AddHealthEvent(5, false, new MethodAction(delegate()
            {
                m_actionManager.StartNew(m_noRightArm);
                m_armR.Pop(-1.1f, 500, true);
            }));
            m_destructible.AddHealthEvent(4, false, new MethodAction(delegate()
            {
                m_actionManager.StartNew(m_noLeftArm);
                m_armL.Pop(-1.1f, 500, true);
            }));
            m_destructible.AddHealthEvent(3, false, new MethodAction(delegate()
            {
                m_actionManager.StartNew(m_noShoulders);
                m_shoulders.Pop(-1.1f, 500, true);
            }));
            m_destructible.AddHealthEvent(0, false, new MethodAction(delegate()
            {
                m_upperB.Pop(-1.1f, 500, true);
                m_lowerB.Pop(-1.1f, 500, true);
                ObjectState.Destroy();
            }));

            ObjectState.Begin();
        }
        public BasicZombie()
            : base()
        {
            m_physics = new PhysicsComponent(Globals.TheGame, Transform);
            m_sprite = new Sprite(Globals.TheGame, TextureLibrary.GetSpriteSheet("zombie_base", 1, 8), Transform);
            m_sprite.Origin = new Vector2(0.5f, 1.0f);
            m_loot = Loot.GenerateLoot(4);

            ObjectState.BeginAction = delegate()
            {
                m_actionManager.StartNew(m_full);
            };
            ObjectState.StandbyAction = delegate()
            {
                m_actionManager.Stop();
                m_sprite.SetFrame(0);
            };
            ObjectState.DestroyAction = delegate()
            {
                m_destructible.ClearHitEvents();
                Backpacker.HitPlayerColliders.Remove(m_collider);
            };

            m_collider = new AABBCollider(this, new AABB(m_sprite));
            Backpacker.HitPlayerColliders.Add(m_collider, delegate(Collider other) { m_physics.Throw(10.0f, -10.0f, 0.1f); });
            m_destructible = new DestructibleComponent(Transform, m_collider, m_collider.AABB, HP);

            m_impactBox = new AABB(new Transform(Transform, true), new Vector2(22, 42));
            m_impactBox.Transform.Position = new Vector2(13, -44);
            m_measurer = new AABBMeasurer(m_impactBox);
            m_shurikenReceiver = new ShurikenReceiver(Transform, m_impactBox, 5);
            m_hitAnimation = new HitAnimation(World.baseEffect);

            m_full = new SpriteSheetAnimation(m_sprite, 0, 1, 0.5f, -1);
            m_noHead = new SpriteSheetAnimation(m_sprite, 2, 3, 0.5f, -1);
            m_noLeftArm = new SpriteSheetAnimation(m_sprite, 4, 5, 0.5f, -1);
            m_noRightArm = new SpriteSheetAnimation(m_sprite, 6, 7, 0.5f, -1);

            m_actionManager = new SingleActionManager();

            //Transform headTransform = new Transform(Transform, true
            //_projections = new BodyPart[] {
            //    null,
            //    new BodyPart(this, new Vector2(0, -65), "bp_basezombiearm"),
            //    new BodyPart(this, new Vector2(-10, -55), "bp_basezombiearm"),
            //    new BodyPart(this, new Vector2(15, -75), "bp_basezombiehead"),
             // new BodyPart(this, new Vector2(10, -50), "bp_basezombieupperb"),
             //   new BodyPart(this, new Vector2(10, -10), "bp_basezombielowerb")
            //};

            ///
            /// Body Parts
            ///
            m_bodyParts = new ParticleSystem(Globals.TheGame, 5);

            m_head = new BodyPart(TextureLibrary.GetSpriteSheet("bp_basezombiehead"), new Transform(Transform, true));
            m_head.Transform.Position = new Vector2(5, -50);
            m_bodyParts.AddParticle(m_head);

            m_armL = new BodyPart(TextureLibrary.GetSpriteSheet("bp_basezombiearm"), new Transform(Transform, true));
            m_armL.Transform.Position = new Vector2(5, -30);
            m_bodyParts.AddParticle(m_armL);

            m_armR = new BodyPart(TextureLibrary.GetSpriteSheet("bp_basezombiearm"), new Transform(Transform, true));
            m_armR.Transform.Position = new Vector2(-5, -30);
            m_bodyParts.AddParticle(m_armR);

            m_upperB = new BodyPart(TextureLibrary.GetSpriteSheet("bp_basezombieupperb"), new Transform(Transform, true));
            m_upperB.Transform.Position = new Vector2(0, -30);
            m_bodyParts.AddParticle(m_upperB);

            m_lowerB = new BodyPart(TextureLibrary.GetSpriteSheet("bp_basezombielowerb"), new Transform(Transform, true));
            m_lowerB.Transform.Position = new Vector2(0, -10);
            m_bodyParts.AddParticle(m_lowerB);

            ///
            ///Hit events
            ///
            m_destructible.SetHitEvent(AttackType.Shuriken, OnShurikenHit);
            m_destructible.SetHitEvent(AttackType.Slash, OnSliceHit);

            ///
            /// Health events
            ///
            m_destructible.AddHealthEvent(3, false, new MethodAction(delegate()
                {
                    m_actionManager.StartNew(m_noHead);
                    m_head.Pop(-1.1f, 500, true);
                }));
            m_destructible.AddHealthEvent(2, false, new MethodAction(delegate()
            {
                m_actionManager.StartNew(m_noLeftArm);
                m_armL.Pop(-1.1f, 500, true);
            }));
            m_destructible.AddHealthEvent(1, false, new MethodAction(delegate()
            {
                m_actionManager.StartNew(m_noRightArm);
                m_armR.Pop(-1.1f, 500, true);
            }));
            m_destructible.AddHealthEvent(0, false, new MethodAction(delegate()
            {
                m_upperB.Pop(-1.1f, 500, true);
                m_lowerB.Pop(-1.1f, 500, true);
                ObjectState.Destroy();
            }));

            ObjectState.Begin();
        }