Example #1
0
 public virtual void Update(float gameTime, Map map, ParticleManager particleManager, Character[] characters)
 {
     location += trajectory * gameTime;
     frame -= gameTime;
     if (frame < 0.0f)
         KillMe();
 }
Example #2
0
        public override void Update(float gameTime, Map map, ParticleManager pMan, Character[] c)
        {
            if (HitManager.CheckHit(this, c, pMan))
                frame = 0f;

            trajectory.Y = (float)Math.Sin((double)frame * 13.0) * 150f;

            if (map.CheckParticleCollision(location))
            {
                this.frame = 0f;
                pMan.MakeExplosion(location, 1f);
            }

            pMan.AddParticle(new Fire(location, -trajectory / 8f,
                .5f, RandomGenerator.GetRandomInt(0, 4)));
            pMan.AddParticle(new Smoke(location,
                RandomGenerator.GetRandomVector2(-20f, 20f, -50f, 10f)
                - trajectory / 10f,
                1f, .8f, .6f, 1f, .5f,
                RandomGenerator.GetRandomInt(0, 4)));
            pMan.AddParticle(new Heat(location,
                RandomGenerator.GetRandomVector2(-20f, 20f, -50f, -10f),
                RandomGenerator.GetRandomFloat(.5f, 2f)));

            base.Update(gameTime, map, pMan, c);
        }
Example #3
0
        public override void Update(float gameTime, Map map, ParticleManager particleManager, Character[] characters)
        {
            if (HitManager.CheckHit(this, characters, particleManager))
                frame = 0f;

            if (map.CheckParticleCollision(location))
            {
                frame = 0f;
                particleManager.MakeBulletDust(location, trajectory);
            }
            base.Update(gameTime, map, particleManager, characters);
        }
Example #4
0
 public override void Update(float gameTime, MapClasses.Map map, ParticleManager particleManager, CharacterClasses.Character[] characters)
 {
     if (frame < 0.5f)
     {
         if (trajectory.Y < -10.0f)
             trajectory.Y += gameTime * 500.0f;
         if (trajectory.X < -10.0f)
             trajectory.X += gameTime * 150.0f;
         if (trajectory.X > 10.0f)
             trajectory.X -= gameTime * 150.0f;
     }
     base.Update(gameTime, map, particleManager, characters);
 }
Example #5
0
        /// <summary>
        /// Gets a Trigger and it's location and then usually creates new Particles,
        /// plays sound and set screen shake.
        /// This method has been verified!
        /// </summary>
        /// <param name="trigger">The trigger.</param>
        /// <param name="location">The location.</param>
        /// <param name="particleManager">The particle manager.</param>
        private void FireTrigger(int trigger, Vector2 location, ParticleManager particleManager)
        {
            switch (trigger)
            {
                case TRIG_PISTOL_ACROSS:
                case TRIG_PISTOL_UP:
                case TRIG_PISTOL_DOWN:
                    if (Team == TEAM_PLAYERS && ID < 4)
                    {
                        QuakeManager.SetRumble(ID, 1, .5f);
                        QuakeManager.SetRumble(ID, 0, .3f);
                    }
                    break;
            }

            #region Trigger Code

            switch (trigger)
            {
                case TRIG_FIRE_DIE:
                    for (int i = 0; i < 5; i++)
                    {
                        particleManager.AddParticle(new Fire(location +
                            RandomGenerator.GetRandomVector2(-30f, 30f, -30f, 30f),
                            RandomGenerator.GetRandomVector2(-5f, 60f, -150f, -20f),
                            RandomGenerator.GetRandomFloat(.3f, .8f), RandomGenerator.GetRandomInt(0, 4),
                            RandomGenerator.GetRandomFloat(.5f, .8f)));
                    }
                    particleManager.AddParticle(new Smoke(location,
                        RandomGenerator.GetRandomVector2(-10f, 10f, -60f, 10f),
                        1f, .8f, .6f, 1f, RandomGenerator.GetRandomFloat(.5f, 1.2f),
                        RandomGenerator.GetRandomInt(0, 4)));
                    particleManager.AddParticle(new Heat(location,
                        RandomGenerator.GetRandomVector2(-50f, 50f, -100f, 0f),
                        RandomGenerator.GetRandomFloat(1f, 2f)));
                    break;
                case TRIG_ROCKET:
                    particleManager.AddParticle(new Rocket(location, new Vector2((Face == CharacterDirection.Right ? 350f : -350f),
                        100f), ID));
                    break;
                case TRIG_PISTOL_ACROSS:
                    particleManager.MakeBullet(location, new Vector2(2000f, 0f), Face, ID);
                    Sound.PlayCue("revol");
                    QuakeManager.SetQuake(0.3f);
                    break;
                case TRIG_PISTOL_DOWN:
                    particleManager.MakeBullet(location, new Vector2(1400f, 1400f), Face, ID);
                    Sound.PlayCue("revol");
                    QuakeManager.SetQuake(0.3f);
                    break;
                case TRIG_PISTOL_UP:
                    particleManager.MakeBullet(location, new Vector2(1400f, -1400f), Face, ID);
                    Sound.PlayCue("revol");
                    QuakeManager.SetQuake(0.3f);
                    break;
                case TRIG_BLOOD_SQUIRT_BACK:
                case TRIG_BLOOD_SQUIRT_DOWN:
                case TRIG_BLOOD_SQUIRT_DOWN_BACK:
                case TRIG_BLOOD_SQUIRT_DOWN_FORWARD:
                case TRIG_BLOOD_SQUIRT_FORWARD:
                case TRIG_BLOOD_SQUIRT_UP:
                case TRIG_BLOOD_SQUIRT_UP_BACK:
                case TRIG_BLOOD_SQUIRT_UP_FORWARD:
                    double r = 0.0;
                    switch (trigger)
                    {
                        case TRIG_BLOOD_SQUIRT_FORWARD:
                            r = 0.0;
                            break;
                        case TRIG_BLOOD_SQUIRT_DOWN_FORWARD:
                            r = Math.PI * .25;
                            break;
                        case TRIG_BLOOD_SQUIRT_DOWN:
                            r = Math.PI * .5;
                            break;
                        case TRIG_BLOOD_SQUIRT_DOWN_BACK:
                            r = Math.PI * .75;
                            break;
                        case TRIG_BLOOD_SQUIRT_BACK:
                            r = Math.PI;
                            break;
                        case TRIG_BLOOD_SQUIRT_UP_BACK:
                            r = Math.PI * 1.25;
                            break;
                        case TRIG_BLOOD_SQUIRT_UP:
                            r = Math.PI * 1.5;
                            break;
                        case TRIG_BLOOD_SQUIRT_UP_FORWARD:
                            r = Math.PI * 1.75;
                            break;
                    }
                    for (int i = 0; i < 7; i++)
                    {
                        particleManager.AddParticle(new Blood(location, new Vector2(
                            (float)Math.Cos(r) * (Face == CharacterDirection.Right ? 1f : -1f),
                            (float)Math.Sin(r)
                            ) * RandomGenerator.GetRandomFloat(10f, 500f) +
                            RandomGenerator.GetRandomVector2(-90f, 90f, -90f, 90f),
                            0.3f, 0f, 0f, 1f, RandomGenerator.GetRandomFloat(0.1f, 0.5f),
                            RandomGenerator.GetRandomInt(0, 4)));
                    }
                    particleManager.AddParticle(new BloodDust(location,
                        RandomGenerator.GetRandomVector2(-30f, 30f, -30f, 30f),
                        0.3f, 0f, 0f, .2f,
                        RandomGenerator.GetRandomFloat(.25f, .5f),
                        RandomGenerator.GetRandomInt(0, 4)));
                    break;
                case TRIG_BLOOD_CLOUD:
                    particleManager.AddParticle(new BloodDust(location,
                        RandomGenerator.GetRandomVector2(-30f, 30f, -30f, 30f),
                        0.3f, 0f, 0f, .4f,
                        RandomGenerator.GetRandomFloat(.25f, .75f),
                        RandomGenerator.GetRandomInt(0, 4)));
                    break;
                case TRIG_BLOOD_SPLAT:
                    for (int i = 0; i < 6; i++)
                    {
                        particleManager.AddParticle(new BloodDust(location,
                        RandomGenerator.GetRandomVector2(-30f, 30f, -30f, 30f),
                        0.3f, 0f, 0f, .4f,
                        RandomGenerator.GetRandomFloat(.025f, .125f),
                        RandomGenerator.GetRandomInt(0, 4)));
                    }
                    break;
                default:
                    particleManager.AddParticle(new Hit(location, new Vector2(
                        200f * (float)Face - 100f, 0f),
                        ID, trigger));
                    break;
            }
            #endregion
        }
Example #6
0
        /// <summary>
        /// Gets the trigger by checking all parts with an index >= 1000.
        /// All Triggers have values between 1-25 (constants defined in the Character class)
        /// and are set to index + 1000. So we deduct 1000 from the part index and get back
        /// the original constant trigger. We then give this trigger index to FireTrigger method.
        /// This method has been verified!
        /// </summary>
        /// <param name="particleManager">The particle manager.</param>
        private void CheckTrigger(ParticleManager particleManager)
        {
            int frameIndex = characterDefinition.Animations[Animation].KeyFrames[AnimationFrame].FrameReference;

            Frame frame = characterDefinition.Frames[frameIndex];

            for (int i = 0; i < frame.Parts.Length; i++)
            {
                Part part = frame.Parts[i];
                if (part.Index >= 1000)
                {
                    Vector2 location = part.Location * Scale + Location;

                    if (Face == CharacterDirection.Left)
                        location.X -= part.Location.X * Scale * 2.0f;

                    FireTrigger(part.Index - 1000, location, particleManager);
                }
            }
        }
Example #7
0
        /// <summary>
        /// Updates the Character, checks for collision and handles input.
        /// This method has been verified!
        /// </summary>
        /// <param name="gameTime">The game time.</param>
        public void Update(Map map, ParticleManager particleManager, Character[] character)
        {
            if (Ai != null)
                Ai.Update(character, ID, map);

            PressedKey = PressedKeys.None;
            if (keyAttack)
            {
                PressedKey = PressedKeys.Attack;
                if (keyUp) PressedKey = PressedKeys.Lower;
                if (keyDown) PressedKey = PressedKeys.Upper;
            }
            if (keySecondary)
            {
                PressedKey = PressedKeys.Secondary;
                if (keyUp) PressedKey = PressedKeys.SecUp;
                if (keyDown) PressedKey = PressedKeys.SecDown;
            }
            if (PressedKey > PressedKeys.None)
            {
                if (GotoGoal[(int)PressedKey] > -1)
                {
                    SetFrame(GotoGoal[(int)PressedKey]);

                    if (keyLeft)
                        Face = CharacterDirection.Left;
                    if (keyRight)
                        Face = CharacterDirection.Right;

                    PressedKey = PressedKeys.None;

                    for (int i = 0; i < GotoGoal.Length; i++)
                        GotoGoal[i] = -1;

                    frame = 0f;
                }
            }

            if (StunFrame > 0f)
                StunFrame -= RuinExplorersMain.FrameTime;

            #region update dying
            if (DyingFrame > -1f)
            {
                DyingFrame += RuinExplorersMain.FrameTime;
            }
            #endregion

            #region Update Animation
            if (DyingFrame < 0)
            {
                Animation animation = characterDefinition.Animations[Animation];
                KeyFrame keyFrame = animation.KeyFrames[AnimationFrame];

                frame += RuinExplorersMain.FrameTime * 30.0f;

                if (frame > (float)keyFrame.Duration)
                {
                    int pframe = AnimationFrame;

                    script.DoScript(Animation, AnimationFrame);
                    CheckTrigger(particleManager);

                    frame -= (float)keyFrame.Duration;
                    if (AnimationFrame == pframe)
                        AnimationFrame++;

                    keyFrame = animation.KeyFrames[AnimationFrame];

                    if (AnimationFrame >=
                        animation.KeyFrames.Length)
                        AnimationFrame = 0;
                }

                if (keyFrame.FrameReference < 0)
                    AnimationFrame = 0;

                if (AnimationName == "jhit")
                {
                    if (Trajectory.Y > -100f)
                        SetAnim("jmid");
                }
            }

            #endregion

            #region Collision with other characters
            for (int i = 0; i < character.Length; i++)
            {
                if (i != ID)
                {
                    if (character[i] != null)
                    {
                        if (!Ethereal && !character[i].Ethereal)
                        {
                            if (Location.X > character[i].Location.X - 90f * character[i].Scale &&
                         Location.X < character[i].Location.X + 90f * character[i].Scale &&
                         Location.Y > character[i].Location.Y - 120f * character[i].Scale &&
                         Location.Y < character[i].Location.Y + 10f * character[i].Scale)
                            {
                                float dif = (float)Math.Abs(Location.X - character[i].Location.X);
                                dif = 180f * character[i].Scale - dif;
                                dif *= 2f;
                                if (Location.X < character[i].Location.X)
                                {
                                    CollisionMove = -dif;
                                    character[i].CollisionMove = dif;
                                }
                                else
                                {
                                    CollisionMove = dif;
                                    character[i].CollisionMove = -dif;
                                }
                            }
                        }
                    }
                }
            }

            if (CollisionMove > 0f)
            {
                CollisionMove -= 400f * RuinExplorersMain.FrameTime;
                if (CollisionMove < 0f)
                    CollisionMove = 0f;
            }
            if (CollisionMove < 0f)
            {
                CollisionMove += 400f * RuinExplorersMain.FrameTime;
                if (CollisionMove > 0f)
                    CollisionMove = 0f;
            }
            #endregion

            #region Update Location by Trajectory
            Vector2 previousLocation = new Vector2(Location.X, Location.Y);

            if (State == CharacterState.Ground || (State == CharacterState.Air && floating))
            {
                if (Trajectory.X > 0f)
                {
                    Trajectory.X -= RuinExplorersMain.Friction * RuinExplorersMain.FrameTime;
                    if (Trajectory.X < 0f)
                        Trajectory.X = 0f;
                }
                if (Trajectory.X < 0f)
                {
                    Trajectory.X += RuinExplorersMain.Friction * RuinExplorersMain.FrameTime;
                    if (Trajectory.X > 0f)
                        Trajectory.X = 0f;
                }
            }

            Location.X += Trajectory.X * RuinExplorersMain.FrameTime;
            Location.X += CollisionMove * RuinExplorersMain.FrameTime;

            if (State == CharacterState.Air)
            {
                Location.Y += Trajectory.Y * RuinExplorersMain.FrameTime;
            }
            #endregion

            #region Collision detection
            if (State == CharacterState.Air)
            {
                #region Air State
                if (floating)
                {
                    Trajectory.Y += RuinExplorersMain.FrameTime * RuinExplorersMain.Gravity * 0.5f;
                    if (Trajectory.Y > 100f) Trajectory.Y = 100f;
                    if (Trajectory.Y < -100f) Trajectory.Y = -100f;

                }
                else
                    Trajectory.Y += RuinExplorersMain.FrameTime * RuinExplorersMain.Gravity;

                CheckXCollision(map, previousLocation);

                #region Land on ledge
                if (Trajectory.Y > 0.0f)
                {
                    for (int i = 0; i < 16; i++)
                    {
                        if (map.Legdes[i].TotalNodes > 1)
                        {

                            int ts = map.GetLedgeSection(i, previousLocation.X);
                            int s = map.GetLedgeSection(i, Location.X);
                            float fY;
                            float tfY;
                            if (s > -1 && ts > -1)
                            {

                                tfY = map.GetLedgeYLocation(i, s, previousLocation.X);
                                fY = map.GetLedgeYLocation(i, s, Location.X);
                                if (previousLocation.Y <= tfY && Location.Y >= fY)
                                {
                                    if (Trajectory.Y > 0.0f)
                                    {

                                        Location.Y = fY;
                                        ledgeAttach = i;
                                        Land();
                                    }
                                }
                                else

                                    if (map.Legdes[i].isHardLedge == (int)LedgeFlags.Solid
                                        &&
                                        Location.Y >= fY)
                                    {
                                        Location.Y = fY;
                                        ledgeAttach = i;
                                        Land();
                                    }
                            }

                        }
                    }
                }
                #endregion

                #region Land on col
                if (State == CharacterState.Air)
                {
                    if (Trajectory.Y > 0f)
                    {
                        if (map.CheckCollision(new Vector2(Location.X, Location.Y + 15f)))
                        {
                            Location.Y = (float)((int)((Location.Y + 15f) / 64f) * 64);
                            Land();
                        }
                    }
                }
                #endregion

                #endregion
            }
            else if (State == CharacterState.Ground)
            {
                #region Grounded State

                if (ledgeAttach > -1)
                {
                    if (map.GetLedgeSection(ledgeAttach, Location.X) == -1)
                    {
                        FallOff();
                    }
                    else
                    {
                        Location.Y = map.GetLedgeYLocation(ledgeAttach,
                            map.GetLedgeSection(ledgeAttach, Location.X), Location.X);
                    }
                }
                else
                {
                    if (!map.CheckCollision(new Vector2(Location.X, Location.Y + 15f)))
                        FallOff();
                }

                CheckXCollision(map, previousLocation);

                #endregion
            }
            #endregion

            #region Key input
            if (AnimationName == "idle" || AnimationName == "run" ||
                (State == CharacterState.Ground && CanCancel))
            {
                if (AnimationName == "idle" || AnimationName == "run")
                {
                    if (keyLeft)
                    {
                        SetAnim("run");
                        Trajectory.X = -Speed;
                        Face = CharacterDirection.Left;
                    }
                    else if (keyRight)
                    {
                        SetAnim("run");
                        Trajectory.X = Speed;
                        Face = CharacterDirection.Right;
                    }
                    else
                    {
                        SetAnim("idle");
                    }
                }
                if (keyAttack)
                {
                    SetAnim("attack");
                }
                if (keySecondary)
                {
                    SetAnim("second");
                }
                if (keyJump)
                {
                    SetAnim("jump");
                }
                if (RightAnalog.X > 0.2f || RightAnalog.X < -0.2f)
                {
                    SetAnim("roll");
                    if (AnimationName == "roll")
                    {
                        if (RightAnalog.X > 0f)
                            Face = CharacterDirection.Right;
                        else
                            Face = CharacterDirection.Left;
                    }
                }
            }

            if (AnimationName == "fly" ||
                (State == CharacterState.Air && CanCancel))
            {
                if (keyLeft)
                {
                    Face = CharacterDirection.Left;
                    if (Trajectory.X > -Speed)
                        Trajectory.X -= 500f * RuinExplorersMain.FrameTime;
                }
                if (keyRight)
                {
                    Face = CharacterDirection.Right;
                    if (Trajectory.X < Speed)
                        Trajectory.X += 500f * RuinExplorersMain.FrameTime;
                }
                if (keySecondary)
                {
                    SetAnim("fsecond");
                }
                if (keyAttack)
                {
                    SetAnim("fattack");
                }
            }

            #endregion
        }
Example #8
0
 public override void Update(float gameTime, MapClasses.Map map, ParticleManager particleManager, CharacterClasses.Character[] characters)
 {
     HitManager.CheckHit(this, characters, particleManager);
     KillMe();
 }
        /// <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);

            // not sure if there is a visible difference with these two constructors
            mainTarget = new RenderTarget2D(GraphicsDevice, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, true, SurfaceFormat.Color, DepthFormat.Depth24);
            gameTarget = new RenderTarget2D(GraphicsDevice, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, true, SurfaceFormat.Color, DepthFormat.Depth24);
            refractTarget = new RenderTarget2D(GraphicsDevice, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, true, SurfaceFormat.Color, DepthFormat.Depth24);
            //mainTarget = new RenderTarget2D(GraphicsDevice, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);

            bloomTarget = new RenderTarget2D[2];
            bloomTarget[0] = new RenderTarget2D(GraphicsDevice, 128, 128, true, SurfaceFormat.Color, DepthFormat.Depth24);
            bloomTarget[1] = new RenderTarget2D(GraphicsDevice, 256, 256, true, SurfaceFormat.Color, DepthFormat.Depth24);
            waterTarget = new RenderTarget2D(GraphicsDevice, 256, 256, true, SurfaceFormat.Color, DepthFormat.Depth24);

            filterEffect = Content.Load<Effect>(@"fx/filter");
            pauseEffect = Content.Load<Effect>(@"fx/pause");
            negEffect = Content.Load<Effect>(@"fx/negative");
            bloomEffect = Content.Load<Effect>(@"fx/bloom");
            waterEffect = Content.Load<Effect>(@"fx/water");

            particleManager = new ParticleManager(spriteBatch);
            spritesTexture = Content.Load<Texture2D>(@"gfx/sprites");

            for (int i = 0; i < mapTexture.Length; i++)
                mapTexture[i] = Content.Load<Texture2D>(@"gfx/segments" + (i + 1).ToString());
            for (int i = 0; i < mapBackgroundTexture.Length; i++)
                mapBackgroundTexture[i] = Content.Load<Texture2D>(@"gfx/background" + (i + 1).ToString());

            Character.LoadTextures(Content);

            nullTexture = Content.Load<Texture2D>(@"gfx/1x1");

            /*
             * Create our menu and HUD objects, which we'll use in Chapter 9.
             */
            menu = new Menu(
                Content.Load<Texture2D>(@"gfx/pose"),
                Content.Load<Texture2D>(@"gfx/posefore"),
                Content.Load<Texture2D>(@"gfx/options"),
                mapBackgroundTexture[0],
                spritesTexture,
                spriteBatch);

            hud = new HUD(spriteBatch, spritesTexture, nullTexture, characters, map);
        }
Example #10
0
        public void Update(ParticleManager particleManager, Character[] characters)
        {
            CheckTransitions(characters);
            if (transOutFrame > 0f)
            {
                transOutFrame -= RuinExplorersMain.FrameTime * 3f;
                if (transOutFrame <= 0)
                {
                    path = transitionDestination[(int)TransDir];
                    Read();
                    transInFrame = 1.1f;
                    for (int i = 1; i < characters.Length; i++)
                    {
                        characters[i] = null;
                    }
                    particleManager.Reset();
                }
            }

            if (transInFrame > 0f)
            {
                transInFrame -= RuinExplorersMain.FrameTime * 3f;
            }

            if (mapScript.IsReading)
                mapScript.DoScript(characters);

            if (Bucket != null)
            {
                if (!Bucket.IsEmpty)
                    Bucket.Update(characters);
            }

            frame += RuinExplorersMain.FrameTime;

            if (Fog > -1)
            {
                if ((int)(previousFrame * 10f) != (int)(frame * 10f))
                    particleManager.AddParticle(new Fog(RandomGenerator.GetRandomVector2(0f, 1280f, 600f, 1000f)));
            }

            for (int i = 0; i < 64; i++)
            {
                if (mapSegment[LAYER_MAP, i] != null)
                {
                    if (segDef[mapSegment[LAYER_MAP,i].Index].Flags == (int)SegmentFlags.Torch)
                    {
                        particleManager.AddParticle(new Smoke(
                          mapSegment[LAYER_MAP,i].location * 2f + new Vector2(10f,13f),
                          RandomGenerator.GetRandomVector2(-50.0f, 50.0f, -300.0f, -200.0f),
                          1.0f,
                          0.8f,
                          0.6f,
                          1.0f,
                          RandomGenerator.GetRandomFloat(0.25f, 0.5f),
                          RandomGenerator.GetRandomInt(0, 4)), true);

                        particleManager.AddParticle(new Fire(
                            mapSegment[LAYER_MAP, i].location * 2f + new Vector2(10f, 37f),
                            RandomGenerator.GetRandomVector2(-30.0f, 30.0f, -250.0f, -200.0f),
                            RandomGenerator.GetRandomFloat(0.25f, 0.75f),
                            RandomGenerator.GetRandomInt(0, 4)), true);

                        // apparently heat is not the glowing orb I was looking for
                        particleManager.AddParticle(new Heat(mapSegment[LAYER_MAP, i].location * 2f
                             + new Vector2(10f, -37f),
                             RandomGenerator.GetRandomVector2(-50f, 50f, -400f, -300f),
                             RandomGenerator.GetRandomFloat(1f, 2f)));
                    }
                }
            }

            previousFrame = frame;
        }
Example #11
0
        public static bool CheckHit(Particle particle, Character[] character, ParticleManager particleManager)
        {
            bool r = false;
            CharacterDirection tFace = GetFaceFromTrajectory(particle.trajectory);

            for (int i = 0; i < character.Length; i++)
            {
                if (i != particle.owner)
                {
                    if (character[i] != null)
                    {
                        if (character[i].DyingFrame < 0f && !character[i].Ethereal)
                        {

                            if (character[i].InHitBounds(particle.location))
                            {
                                float hVal = 1f;
                                character[i].LastHitBy = particle.owner;

                                #region hit by bullet

                                if (particle is Bullet)
                                {
                                    if (!r)
                                    {
                                        hVal *= 4f;

                                        if (tFace == CharacterDirection.Left)
                                            character[i].Face = CharacterDirection.Right;
                                        else
                                            character[i].Face = CharacterDirection.Left;

                                        character[i].SetAnim("idle");
                                        character[i].SetAnim("hit");
                                        character[i].Slide(-100f);
                                        Sound.PlayCue("bullethit");

                                        particleManager.MakeBulletBlood(particle.location, particle.trajectory / 2);
                                        particleManager.MakeBulletBlood(particle.location, -particle.trajectory);
                                        // imho white smoke doesn't look so cool when zombies get hit by bullets!
                                        //particleManager.MakeBulletDust(particle.location, particle.trajectory);

                                        r = true;
                                    }
                                }
                                #endregion

                                #region hit by hit particle

                                else if (particle is Hit)
                                {
                                    character[i].Face = (tFace == CharacterDirection.Left) ? CharacterDirection.Right : CharacterDirection.Left;
                                    float tX = 1f;
                                    if (tFace == CharacterDirection.Left)
                                        tX = -1f;

                                    character[i].SetAnim("idle");
                                    character[i].SetAnim("hit");
                                    Sound.PlayCue("zombiehit");

                                    if (character[i].State == CharacterState.Ground)
                                        character[i].Slide(-200f);
                                    else
                                        character[i].Slide(-50f);

                                    switch (particle.flag)
                                    {
                                        case Character.TRIG_ZOMBIE_HIT:
                                            hVal *= 5f;
                                            particleManager.MakeBloodSplash(particle.location, new Vector2(50f * tX, 100f));
                                            break;
                                        case Character.TRIG_WRENCH_DIAG_DOWN:
                                            hVal *= 5f;
                                            particleManager.MakeBloodSplash(particle.location,
                                        new Vector2(50f * tX, 100f));
                                            RuinExplorersMain.SlowTime = 0.1f;
                                            break;
                                        case Character.TRIG_WRENCH_DIAG_UP:
                                            hVal *= 5f;
                                            particleManager.MakeBloodSplash(particle.location,
                                            new Vector2(-50f * tX, -100f));
                                            RuinExplorersMain.SlowTime = 0.1f;
                                            break;
                                        case Character.TRIG_WRENCH_UP:
                                            hVal *= 5f;
                                            particleManager.MakeBloodSplash(particle.location,
                                            new Vector2(30f * tX, -100f));
                                            RuinExplorersMain.SlowTime = 0.1f;
                                            break;
                                        case Character.TRIG_WRENCH_DOWN:
                                            hVal *= 5f;
                                            particleManager.MakeBloodSplash(particle.location,
                                            new Vector2(-50f * tX, 100f));
                                            RuinExplorersMain.SlowTime = 0.1f;
                                            break;
                                        case Character.TRIG_WRENCH_UPPERCUT:
                                            hVal *= 15f;
                                            particleManager.MakeBloodSplash(particle.location,
                                            new Vector2(-50f * tX, -150f));
                                            character[i].Trajectory.X = 100f * tX;
                                            character[i].SetAnim("jhit");
                                            character[i].SetJump(700f);
                                            RuinExplorersMain.SlowTime = 0.125f;
                                            QuakeManager.SetQuake(0.5f);
                                            QuakeManager.SetBlast(0.5f, particle.location);
                                            break;
                                        case Character.TRIG_WRENCH_SMACKDOWN:
                                            hVal *= 15f;
                                            particleManager.MakeBloodSplash(particle.location,
                                            new Vector2(-50f * tX, 150f));
                                            character[i].SetAnim("jfall");
                                            character[i].SetJump(-900f);
                                            RuinExplorersMain.SlowTime = 0.125f;
                                            break;
                                        case Character.TRIG_KICK:
                                            hVal *= 15f;
                                            particleManager.MakeBloodSplash(particle.location,
                                            new Vector2(300f * tX, 0f));
                                            character[i].Trajectory.X = 1000f * tX;
                                            character[i].SetAnim("jhit");
                                            character[i].SetJump(300f);
                                            RuinExplorersMain.SlowTime = 0.25f;
                                            //QuakeManager.SetBlast(0.5f, particle.location);
                                            break;
                                    }
                                }
                                #endregion

                                #region hitting characters in air

                                if (character[i].State == CharacterState.Air)
                                {
                                    if (character[i].AnimationName == "hit")
                                    {
                                        character[i].SetAnim("jmid");
                                        character[i].SetJump(300f);
                                        if (particle is Hit)
                                        {
                                            if (character[particle.owner].Team == Character.TEAM_PLAYERS)
                                            {
                                                character[i].Location.Y = character[particle.owner].Location.Y;
                                            }
                                        }
                                    }
                                }
                                #endregion

                                character[i].HP -= (int)hVal;

                                // calculate score
                                if (character[i].LastHitBy == 0)
                                {
                                    RuinExplorersMain.Score += (int)hVal * 50;
                                }

                                if (character[i].HP < 0)
                                {
                                    if (character[i].AnimationName == "hit")
                                        character[i].SetAnim("diehit");
                                    if (i == 0)
                                    {
                                        if (character[i].AnimationName == "hit")
                                        {
                                            character[i].SetAnim("jmid");
                                            character[i].SetJump(300f);
                                        }
                                        RuinExplorersMain.Menu.Die();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return r;
        }