public virtual void Update(float gameTime, Map map, ParticleManager pMan, Character[] c)
 {
     Location += Trajectory*gameTime;
     Frame -= gameTime;
     if (Frame < 0)
         KillMe();
 }
Beispiel #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.CheckParticleCol(Location))
            {
                this.frame = 0f;
                pMan.MakeExplosion(Location, 1f);
            }

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

            base.Update(gameTime, map, pMan, c);
        }
Beispiel #3
0
        public override void Update(float gameTime, Map map, ParticleManager pMan, Character[] c)
        {
            if (Frame < 0.5f)
            {
                if (Trajectory.Y < -10) Trajectory.Y += gameTime * 500;
                if (Trajectory.X < -10) Trajectory.X += gameTime * 150;
                if (Trajectory.X > 10) Trajectory.X -= gameTime * 150;
            }

            base.Update(gameTime, map, pMan, c);
        }
Beispiel #4
0
        public override void Update(float gameTime, Map map, ParticleManager pMan, Character[] c)
        {
            Trajectory.Y += gameTime * 100f;

            if (Trajectory.X < -10f) Trajectory.X += gameTime * 200f;
            if (Trajectory.X > 10f) Trajectory.X -= gameTime * 200f;

            Rotation = GlobalFunctions.GetAngle(Vector2.Zero, Trajectory);

            base.Update(gameTime, map, pMan, c);
        }
Beispiel #5
0
        public override void Update(float gameTime, Map map, ParticleManager pMan, Character[] c)
        {
            if (HitManager.CheckHit(this, c, pMan))
                Frame = 0f;

            if (map.CheckParticleCol(Location))
            {
                Frame = 0f;
                pMan.MakeBulletDust(Location, Trajectory);
            }
            base.Update(gameTime, map, pMan, c);
        }
Beispiel #6
0
        public override void Update(float gameTime, 
            ZombieSmashers.map.Map map,
            ParticleManager pMan,
            Character[] c)
        {
            if (!netSend)
            {
                HitManager.CheckHit(this, c, pMan);

                KillMe();
            }
        }
Beispiel #7
0
        public void Update(Character[] c, ParticleManager pMan)
        {
            if (NetSession != null)
                if (!NetSession.IsDisposed)
                    NetSession.Update();

            NetConnect.Update();

            if (NetSession != null)
            {
                if (NetSession.SessionState == NetworkSessionState.Playing)
                {
                    NetGame.Update(c, pMan);
                }
            }
        }
Beispiel #8
0
        public void Update(ParticleManager pMan, Character[] c)
        {
            CheckTransitions(c);
            if (transOutFrame > 0f)
            {
                transOutFrame -= Game1.FrameTime * 3f;
                if (transOutFrame <= 0f)
                {
                    path = TransitionDestination[(int)TransDir];
                    Read();
                    transInFrame = 1.1f;
                    for (int i = 1; i < c.Length; i++)
                        c[i] = null;
                    pMan.Reset();
                }
            }
            if (transInFrame > 0f)
            {
                transInFrame -= Game1.FrameTime * 3f;
            }

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

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

            frame += Game1.FrameTime;

            if (Fog > -1)
            {
                if ((int)(pFrame * 10f) != (int)(frame * 10f))
                {
                    pMan.AddParticle(new Fog(
                        Rand.GetRandomVector2(0f, (float)xSize * 64f,
                        (float)Fog + 150f, (float)Fog + 300f)));
                }
            }
            for (int i = 0; i < 64; i++)
            {
                if (mapSeg[LAYER_MAP, i] != null)
                {
                    if (segDef[mapSeg[LAYER_MAP, i].GetDefIdx()].GetFlags() ==
                        SegmentDefinition.FLAGS_TORCH)
                    {
                        pMan.AddParticle(new Smoke(
                            mapSeg[LAYER_MAP, i].GetLoc() * 2f
                            + new Vector2(20f, 13f),
                            Rand.GetRandomVector2(-50.0f, 50.0f, -300.0f, -200.0f),
                            1.0f, 0.8f, 0.6f, 1.0f, Rand.GetRandomFloat(0.25f, 0.5f),
                            Rand.GetRandomInt(0, 4)), true);
                        pMan.AddParticle(new Fire(
                            mapSeg[LAYER_MAP, i].GetLoc() * 2f
                            + new Vector2(20f, 37f),
                            Rand.GetRandomVector2(
                            -30.0f, 30.0f, -250.0f, -200.0f),
                                        Rand.GetRandomFloat(0.25f, 0.75f),
                                        Rand.GetRandomInt(0, 4)), true);
                        pMan.AddParticle(new Heat(mapSeg[LAYER_MAP, i].GetLoc() * 2f
                            + new Vector2(20f, -50f),
                            Rand.GetRandomVector2(-50f, 50f, -400f, -300f),
                            Rand.GetRandomFloat(1f, 2f)));
                    }
                }
            }

            pFrame = frame;
        }
Beispiel #9
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// 
        /// 
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            pManager = new ParticleManager(spriteBatch);
            spritesTex = Content.Load<Texture2D>
                (@"gfx/spritesTex");

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

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

            /*
             * Create our render targets--we'll start using these in chapter 8 when we
             * switch the render loop around.
             */
            mainTarget = new RenderTarget2D(GraphicsDevice,
                graphics.PreferredBackBufferWidth,
                graphics.PreferredBackBufferHeight,
                true, SurfaceFormat.Color, DepthFormat.Depth24);
                //1, SurfaceFormat.Color);

            gameTarget = new RenderTarget2D(GraphicsDevice,
                graphics.PreferredBackBufferWidth,
                graphics.PreferredBackBufferHeight,
                true, SurfaceFormat.Color, DepthFormat.Depth24);
                //1, SurfaceFormat.Color);
            /*
             * We'll use refractTarget for our post process refraction effect in
             * chapter 11.
             */
            refractTarget = new RenderTarget2D(GraphicsDevice,
                graphics.PreferredBackBufferWidth,
                graphics.PreferredBackBufferHeight,
                true, SurfaceFormat.Color, DepthFormat.Depth24);
                //1, SurfaceFormat.Color);

            /*
             * The next RenderTargets and Effects are used for post process effects
             * in chapter 11.
             */
            bloomTarget = new RenderTarget2D[2];
            bloomTarget[0] =
                new RenderTarget2D(GraphicsDevice,
                128, 128,
                true, SurfaceFormat.Color, DepthFormat.Depth24);
                //1, SurfaceFormat.Color);
            bloomTarget[1] =
                new RenderTarget2D(GraphicsDevice,
                256, 256,
                true, SurfaceFormat.Color, DepthFormat.Depth24);
                //1, SurfaceFormat.Color);
            waterTarget =
                new RenderTarget2D(GraphicsDevice,
                256, 256,
                true, SurfaceFormat.Color, DepthFormat.Depth24);
                //1, SurfaceFormat.Color);

            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");

            Character.LoadTextures(Content);

            nullTex = 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"),
                mapBackTex[0],
                spritesTex,
                spriteBatch);

            hud = new HUD(spriteBatch, spritesTex, nullTex, character, map);
        }
        public static bool CheckHit(Particle p, Character[] c, ParticleManager pMan)
        {
            var r = false;
            var tFace = GetFaceFromTraj(p.Trajectory);
            for (var i = 0; i < c.Length; i++)
            {
                if (i != p.Owner)
                {
                    if (c[i] != null)
                    {
                        if (c[i].DyingFrame < 0f && !c[i].Ethereal)
                        {
                            if (c[i].InHitBounds(p.Location))
                            {
                                float hVal = 1;

                                c[i].LastHitBy = p.Owner;

                                if (p is Bullet)
                                {
                                    #region Bullet

                                    if (!r)
                                    {
                                        hVal *= 4;
                                        c[i].Face = tFace == CharDir.Left ? CharDir.Right : CharDir.Left;
                                        c[i].SetAnim("idle");
                                        c[i].SetAnim("hit");
                                        c[i].Slide(-100f);
                                        Sound.PlayCue("bullethit");
                                        pMan.MakeBulletBlood(p.Location, p.Trajectory / 2f);
                                        pMan.MakeBulletBlood(p.Location, -p.Trajectory);
                                        pMan.MakeBulletDust(p.Location, p.Trajectory);
                                        r = true;
                                    }

                                    #endregion
                                }
                                else if (p is Hit)
                                {
                                    #region Hit

                                    c[i].Face = (tFace == CharDir.Left) ? CharDir.Right : CharDir.Left;
                                    var tX = 1f;
                                    if (tFace == CharDir.Left)
                                        tX = -1f;
                                    c[i].SetAnim("idle");
                                    c[i].SetAnim("hit");
                                    Sound.PlayCue("zomhit");

                                    if (c[i].State == CharState.Grounded)
                                        c[i].Slide(-200f);
                                    else
                                        c[i].Slide(-50f);

                                    switch (p.Flag)
                                    {
                                        case Character.TrigWrenchDiagDown:
                                            hVal *= 5;
                                            pMan.MakeBloodSplash(p.Location, new Vector2(50f * tX, 100f));
                                            Game1.SlowTime = 0.1f;
                                            break;
                                        case Character.TrigWrenchDiagUp:
                                            hVal *= 5;
                                            pMan.MakeBloodSplash(p.Location, new Vector2(-50f * tX, -100f));
                                            Game1.SlowTime = 0.1f;
                                            break;
                                        case Character.TrigWrenchUp:
                                            hVal *= 5;
                                            pMan.MakeBloodSplash(p.Location, new Vector2(30f * tX, -100f));
                                            Game1.SlowTime = 0.1f;
                                            break;
                                        case Character.TrigWrenchDown:
                                            hVal *= 5;
                                            pMan.MakeBloodSplash(p.Location, new Vector2(-50f * tX, 100f));
                                            Game1.SlowTime = 0.1f;
                                            break;
                                        case Character.TrigWrenchUppercut:
                                            hVal *= 15;
                                            pMan.MakeBloodSplash(p.Location, new Vector2(-50f * tX, -150f));
                                            c[i].Trajectory.X = 100f * tX;
                                            c[i].SetAnim("jhit");
                                            c[i].SetJump(700f);
                                            Game1.SlowTime = 0.125f;
                                            QuakeManager.SetQuake(.5f);
                                            QuakeManager.SetBlast(.5f, p.Location);
                                            break;
                                        case Character.TrigWrenchSmackdown:
                                            hVal *= 5;
                                            pMan.MakeBloodSplash(p.Location, new Vector2(-50f * tX, 150f));
                                            c[i].SetAnim("jfall");
                                            c[i].SetJump(-900f);
                                            Game1.SlowTime = 0.125f;
                                            break;
                                        case Character.TrigKick:
                                            hVal *= 5;
                                            pMan.MakeBloodSplash(p.Location, new Vector2(300f * tX, 0f));
                                            c[i].Trajectory.X = 1000f * tX;
                                            c[i].SetAnim("jhit");
                                            c[i].SetJump(300f);
                                            Game1.SlowTime = 0.25f;
                                            break;
                                        case Character.TrigZombieHit:
                                            hVal *= 5;
                                            pMan.MakeBloodSplash(p.Location, new Vector2(50f * tX, 100f));
                                            break;
                                    }

                                    #endregion
                                }

                                if (c[i].LastHitBy == 0)
                                    Game1.Score += (int)hVal * 50;

                                if (c[i].State == CharState.Air)
                                {
                                    if (c[i].AnimName == "hit")
                                    {
                                        c[i].SetAnim("jmid");
                                        c[i].SetJump(300f);
                                        if (p is Hit)
                                        {
                                            if (c[p.Owner].Team == Character.TeamGoodGuys)
                                                c[i].Location.Y = c[p.Owner].Location.Y;
                                        }
                                    }
                                }

                                c[i].Hp -= (int)hVal;

                                if (c[i].Hp < 0)
                                {
                                    if (c[i].AnimName == "hit")
                                        c[i].SetAnim("diehit");
                                }
                            }
                        }
                    }
                }
            }
            return r;
        }
Beispiel #11
0
        public void Update(Map map, ParticleManager pMan, Character[] c)
        {
            if (Ai != null)
                Ai.Update(c, 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 = CharDir.Left;
                    if (KeyRight)
                        Face = CharDir.Right;

                    PressedKey = PressedKeys.None;

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

                    frame = 0f;
                }
            }

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

            #region Update Dying
            if (DyingFrame > -1f)
            {
                DyingFrame += Game1.FrameTime;

            }
            #endregion

            #region Update Animation
            if (DyingFrame < 0f)
            {
                Animation animation = charDef.GetAnimation(Anim);
                KeyFrame keyframe = animation.GetKeyFrame(AnimFrame);

                frame += Game1.FrameTime * 30.0f;

                if (frame > (float)keyframe.Duration)
                {
                    int pframe = AnimFrame;

                    script.DoScript(Anim, AnimFrame);
                    CheckTrig(pMan);

                    frame -= (float)keyframe.Duration;
                    if (AnimFrame == pframe)
                        AnimFrame++;

                    keyframe = animation.GetKeyFrame(AnimFrame);

                    if (AnimFrame >=
                        animation.getKeyFrameArray().Length)
                        AnimFrame = 0;

                }

                if (keyframe.FrameRef < 0)
                    AnimFrame = 0;

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

            #region Collison w/ other characters
            for (int i = 0; i < c.Length; i++)
            {
                if (i != ID)
                {
                    if (c[i] != null)
                    {
                        if (!ethereal && !c[i].ethereal)
                        {
                            if (Loc.X > c[i].Loc.X - 90f * c[i].Scale &&
                                Loc.X < c[i].Loc.X + 90f * c[i].Scale &&
                                Loc.Y > c[i].Loc.Y - 120f * c[i].Scale &&
                                Loc.Y < c[i].Loc.Y + 10f * c[i].Scale)
                            {
                                float dif = (float)Math.Abs(Loc.X - c[i].Loc.X);
                                dif = 180f * c[i].Scale - dif;
                                dif *= 2f;
                                if (Loc.X < c[i].Loc.X)
                                {
                                    ColMove = -dif;
                                    c[i].ColMove = dif;
                                }
                                else
                                {
                                    ColMove = dif;
                                    c[i].ColMove = -dif;
                                }
                            }
                        }
                    }
                }
            }
            if (ColMove > 0f)
            {
                ColMove -= 400f * Game1.FrameTime;
                if (ColMove < 0f) ColMove = 0f;
            }
            if (ColMove < 0f)
            {
                ColMove += 400f * Game1.FrameTime;
                if (ColMove > 0f) ColMove = 0f;
            }
            #endregion

            #region Update loc by trajectory

            Vector2 pLoc = new Vector2(Loc.X, Loc.Y);

            if (State == CharState.Grounded || (State == CharState.Air && Floating))
            {
                if (Trajectory.X > 0f)
                {
                    Trajectory.X -= Game1.Friction * Game1.FrameTime;
                    if (Trajectory.X < 0f) Trajectory.X = 0f;
                }
                if (Trajectory.X < 0f)
                {
                    Trajectory.X += Game1.Friction * Game1.FrameTime;
                    if (Trajectory.X > 0f) Trajectory.X = 0f;
                }
            }
            Loc.X += Trajectory.X * Game1.FrameTime;
            Loc.X += ColMove * Game1.FrameTime;
            if (State == CharState.Air)
            {
                Loc.Y += Trajectory.Y * Game1.FrameTime;
            }
            #endregion

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

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

                CheckXCol(map, pLoc);

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

                            int ts = map.GetLedgeSec(i, pLoc.X);
                            int s = map.GetLedgeSec(i, Loc.X);
                            float fY;
                            float tfY;
                            if (s > -1 && ts > -1)
                            {

                                tfY = map.GetLedgeYLoc(i, s, pLoc.X);
                                fY = map.GetLedgeYLoc(i, s, Loc.X);
                                if (pLoc.Y <= tfY && Loc.Y >= fY)
                                {
                                    if (Trajectory.Y > 0.0f)
                                    {

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

                                    if (map.GetLedgeFlags(i) == (int)LedgeFlags.Solid
                                        &&
                                        Loc.Y >= fY)
                                    {
                                        Loc.Y = fY;
                                        ledgeAttach = i;
                                        Land();
                                    }
                            }

                        }
                    }
                }
                #endregion

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

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

                if (ledgeAttach > -1)
                {
                    if (map.GetLedgeSec(ledgeAttach, Loc.X) == -1)
                    {
                        FallOff();
                    }
                    else
                    {
                        Loc.Y = map.GetLedgeYLoc(ledgeAttach,
                            map.GetLedgeSec(ledgeAttach, Loc.X), Loc.X);
                    }
                }
                else
                {
                    if (!map.CheckCol(new Vector2(Loc.X, Loc.Y + 15f)))
                        FallOff();
                }

                CheckXCol(map, pLoc);

                #endregion
            }
            #endregion

            #region Key input
            if (AnimName == "idle" || AnimName == "run" ||
                (State == CharState.Grounded && CanCancel))
            {
                if (AnimName == "idle" || AnimName == "run")
                {
                    if (KeyLeft)
                    {
                        SetAnim("run");
                        Trajectory.X = -Speed;
                        Face = CharDir.Left;
                    }
                    else if (KeyRight)
                    {
                        SetAnim("run");
                        Trajectory.X = Speed;
                        Face = CharDir.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 (AnimName == "roll")
                    {
                        if (RightAnalog.X > 0f)
                            Face = CharDir.Right;
                        else
                            Face = CharDir.Left;
                    }
                }
            }

            if (AnimName == "fly" ||
                (State == CharState.Air && CanCancel))
            {
                if (KeyLeft)
                {
                    Face = CharDir.Left;
                    if (Trajectory.X > -Speed)
                        Trajectory.X -= 500f * Game1.FrameTime;
                }
                if (KeyRight)
                {
                    Face = CharDir.Right;
                    if (Trajectory.X < Speed)
                        Trajectory.X += 500f * Game1.FrameTime;
                }
                if (KeySecondary)
                {
                    SetAnim("fsecond");
                }
                if (KeyAttack)
                {
                    SetAnim("fattack");
                }
            }

            #endregion
        }
        private void FireTrig(int trig, Vector2 loc, ParticleManager pMan)
        {
            switch (trig)
            {
                case TrigPistolAcross:
                    pMan.MakeBullet(loc, new Vector2(2000, 0), Face, Id);
                    Sound.PlayCue("revol");
                    break;
                case TrigPistolDown:
                    pMan.MakeBullet(loc, new Vector2(1400, 1400), Face, Id);
                    Sound.PlayCue("revol");
                    break;
                case TrigPistolUp:
                    pMan.MakeBullet(loc, new Vector2(1400, -1400), Face, Id);
                    Sound.PlayCue("revol");
                    break;
                case TrigBloodSquirtBack:
                case TrigBloodSquirtDown:
                case TrigBloodSquirtDownBack:
                case TrigBloodSquirtDownForward:
                case TrigBloodSquirtForward:
                case TrigBloodSquirtUp:
                case TrigBloodSquirtUpBack:
                case TrigBloodSquirtUpForward:
                    var r = 0.0;
                    switch (trig)
                    {
                        case TrigBloodSquirtForward:
                            r = 0.0;
                            break;
                        case TrigBloodSquirtDownForward:
                            r = Math.PI * .25;
                            break;
                        case TrigBloodSquirtDown:
                            r = Math.PI * .5;
                            break;
                        case TrigBloodSquirtDownBack:
                            r = Math.PI * .75;
                            break;
                        case TrigBloodSquirtBack:
                            r = Math.PI;
                            break;
                        case TrigBloodSquirtUpBack:
                            r = Math.PI * 1.25;
                            break;
                        case TrigBloodSquirtUp:
                            r = Math.PI * 1.5;
                            break;
                        case TrigBloodSquirtUpForward:
                            r = Math.PI * 1.75;
                            break;
                    }

                    for (var i = 0; i < 7; i++)
                    {
                        pMan.AddParticle(new Blood(loc,
                            new Vector2((float)Math.Cos(r) * (Face == CharDir.Right ? 1f : -1f), (float)Math.Sin(r)) *
                            Rand.GetRandomFloat(10f, 500f) + Rand.GetRandomVector2(-90f, 90f, -90f, 90f), 1f, 0f, 0f, 1f,
                            Rand.GetRandomFloat(0.1f, 0.5f), Rand.GetRandomInt(0, 4)));
                    }
                    pMan.AddParticle(new BloodDust(loc, Rand.GetRandomVector2(-30f, 30f, -30f, 30f), 1f, 0f, 0f, .2f,
                        Rand.GetRandomFloat(.25f, .5f), Rand.GetRandomInt(0, 4)));
                    break;
                case TrigBloodCloud:
                    pMan.AddParticle(new BloodDust(loc, Rand.GetRandomVector2(-30f, 30f, -30f, 30f), 1f, 0f, 0f, .4f,
                        Rand.GetRandomFloat(.25f, .75f), Rand.GetRandomInt(0, 4)));
                    break;
                case TrigBloodSplat:
                    for (var i = 0; i < 6; i++)
                    {
                        pMan.AddParticle(new BloodDust(loc, Rand.GetRandomVector2(-30f, 30f, -30f, 30f), 1f, 0f, 0f, .4f,
                            Rand.GetRandomFloat(.025f, .125f), Rand.GetRandomInt(0, 4)));
                    }
                    break;

                default:
                    pMan.AddParticle(new Hit(loc, new Vector2(200f * (float)Face - 100f, 0f), Id, trig));
                    break;
            }

            switch (trig)
            {
                case TrigPistolAcross:
                case TrigPistolUp:
                case TrigPistolDown:
                    if (Team == TeamGoodGuys && Id < 4)
                    {
                        QuakeManager.SetRumble(Id, 1, .5f);
                        QuakeManager.SetRumble(Id, 0, .3f);
                    }
                    break;
            }
        }
        private void CheckTrig(ParticleManager pMan)
        {
            var frameIndex = _charDef.Animations[Anim].KeyFrames[AnimFrame].FrameRef;

            var frame = _charDef.Frames[frameIndex];

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

                    if (Face == CharDir.Left)
                        location.X -= part.Location.X * Scale * 2;

                    FireTrig(part.Index - 1000, location, pMan);
                }
            }
        }
        public void Update(ParticleManager pMan, Character[] c)
        {
            #region Update AI

            if (Ai != null)
                Ai.Update(c, Id, Map);

            #endregion

            #region Update Dying

            if (DyingFrame > -1)
                DyingFrame += Game1.FrameTime;

            #endregion

            #region Update animation

            if (DyingFrame < 0)
            {
                var animation = _charDef.Animations[Anim];
                var keyFrame = animation.KeyFrames[AnimFrame];

                _frame += Game1.FrameTime * 30;

                if (_frame > keyFrame.Duration)
                {
                    var pFrame = AnimFrame;
                    _script.DoScript(Anim, AnimFrame);
                    CheckTrig(pMan);

                    _frame -= keyFrame.Duration;

                    if (AnimFrame == pFrame)
                        AnimFrame++;

                    if (AnimFrame >= animation.KeyFrames.Length)
                        AnimFrame = 0;

                    keyFrame = animation.KeyFrames[AnimFrame];

                    if (keyFrame.FrameRef < 0)
                        AnimFrame = 0;
                }
            }

            #endregion

            #region Collison w/ other characters

            for (var i = 0; i < c.Length; i++)
            {
                if (i != Id)
                {
                    if (c[i] != null)
                    {
                        if (!Ethereal && !c[i].Ethereal)
                        {
                            if (Location.X > c[i].Location.X - 90f * c[i].Scale &&
                                Location.X < c[i].Location.X + 90f * c[i].Scale &&
                                Location.Y > c[i].Location.Y - 120f * c[i].Scale &&
                                Location.Y < c[i].Location.Y + 10f * c[i].Scale)
                            {
                                var dif = Math.Abs(Location.X - c[i].Location.X);
                                dif = 180f * c[i].Scale - dif;
                                dif *= 2f;
                                if (Location.X < c[i].Location.X)
                                {
                                    ColMove = -dif;
                                    c[i].ColMove = dif;
                                }
                                else
                                {
                                    ColMove = dif;
                                    c[i].ColMove = -dif;
                                }
                            }
                        }
                    }
                }
            }

            if (ColMove > 0f)
            {
                ColMove -= 400f * Game1.FrameTime;
                if (ColMove < 0f) ColMove = 0f;
            }
            else if (ColMove < 0f)
            {
                ColMove += 400f * Game1.FrameTime;
                if (ColMove > 0f) ColMove = 0f;
            }

            #endregion

            #region Update location by trajectory

            var pLoc = Location;

            if (State == CharState.Grounded)
            {
                if (Trajectory.X > 0)
                {
                    Trajectory.X -= Game1.Friction * Game1.FrameTime;
                    if (Trajectory.X < 0)
                        Trajectory.X = 0;
                }

                if (Trajectory.X < 0)
                {
                    Trajectory.X += Game1.Friction * Game1.FrameTime;
                    if (Trajectory.X > 0)
                        Trajectory.X = 0;
                }
            }

            Location.X += Trajectory.X * Game1.FrameTime;
            Location.X += ColMove * Game1.FrameTime;

            if (State == CharState.Air)
            {
                Location.Y += Trajectory.Y * Game1.FrameTime;
                Trajectory.Y += Game1.FrameTime * Game1.Gravity;
            }

            #endregion

            #region Colision detection

            if (State == CharState.Air)
            {
                CheckXCol(pLoc);

                #region Land on ledge

                if (Trajectory.Y > 0)
                {
                    for (var i = 0; i < 16; i++)
                    {
                        if (Map.Ledges[i].TotalNodes > 1)
                        {
                            var ts = Map.GetLedgeSec(i, pLoc.X);
                            var s = Map.GetLedgeSec(i, Location.X);

                            if (s > -1 && ts > -1)
                            {
                                var tfy = Map.GetLedgeYLoc(i, s, pLoc.X);
                                var fy = Map.GetLedgeYLoc(i, s, Location.X);

                                if (pLoc.Y <= tfy && Location.Y >= fy)
                                {
                                    if (Trajectory.Y > 0)
                                    {
                                        Location.Y = fy;
                                        _ledgeAttach = i;
                                        Land();
                                    }
                                }
                                else
                                {
                                    if (Map.Ledges[i].Flags == (int)LedgeFlags.Solid && Location.Y >= fy)
                                    {
                                        Location.Y = fy;
                                        _ledgeAttach = i;
                                        Land();
                                    }
                                }
                            }
                        }
                    }
                }

                #endregion

                #region Land on col

                if (State == CharState.Air && Trajectory.Y > 0)
                {
                    if (Map.CheckCol(new Vector2(Location.X, Location.Y + 15)))
                    {
                        Location.Y = (int)(Location.Y + 15) / 64 * 64;
                        Land();
                    }
                }

                #endregion
            }
            else if (State == CharState.Grounded)
            {
                #region Grounded state

                if (_ledgeAttach > -1)
                {
                    if (Map.GetLedgeSec(_ledgeAttach, Location.X) == -1)
                    {
                        FallOff();
                    }
                    else
                    {
                        Location.Y = Map.GetLedgeYLoc(_ledgeAttach, Map.GetLedgeSec(_ledgeAttach, Location.X),
                            Location.X);
                    }
                }
                else
                {
                    if (!Map.CheckCol(new Vector2(Location.X, Location.Y + 15)))
                        FallOff();
                }

                CheckXCol(pLoc);

                #endregion
            }

            #endregion

            #region UpdateKey input

            if (AnimName == "idle" || AnimName == "run")
            {
                if (KeyLeft)
                {
                    SetAnim("run");
                    Trajectory.X = -200;
                    Face = CharDir.Left;
                }
                else if (KeyRight)
                {
                    SetAnim("run");
                    Trajectory.X = 200;
                    Face = CharDir.Right;
                }
                else
                {
                    SetAnim("idle");
                }

                if (KeyAttack)
                {
                    SetAnim("attack");
                }

                if (KeySecondary)
                {
                    SetAnim("second");
                }

                if (KeyJump)
                {
                    SetAnim("fly");
                    Trajectory.Y = -600;
                    State = CharState.Air;
                    _ledgeAttach = -1;
                    if (KeyRight) Trajectory.X = 200;
                    else if (KeyLeft) Trajectory.X = -200;
                }
            }

            if (AnimName == "fly")
            {
                if (KeyLeft)
                {
                    Face = CharDir.Left;
                    if (Trajectory.X > -200)
                        Trajectory.X -= 500 * Game1.FrameTime;
                }
                else if (KeyRight)
                {
                    Face = CharDir.Right;
                    if (Trajectory.X < 200)
                        Trajectory.X += 500 * Game1.FrameTime;
                }
            }

            PressedKey = PressedKeys.None;

            if (KeyAttack)
                PressedKey = KeyUp ? PressedKeys.Lower : KeyDown ? PressedKeys.Upper : PressedKeys.Attack;

            if (KeySecondary)
                PressedKey = KeyUp ? PressedKeys.SecUp : KeyDown ? PressedKeys.SecDown : PressedKeys.Secondary;

            if (PressedKey != PressedKeys.None)
            {
                if (GotoGoal[(int)PressedKey] > -1)
                {
                    AnimFrame = GotoGoal[(int)PressedKey];

                    if (KeyLeft)
                        Face = CharDir.Left;
                    else if (KeyRight)
                        Face = CharDir.Right;

                    PressedKey = PressedKeys.None;

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

                    _frame = 0;
                    _script.DoScript(Anim, AnimFrame);
                }
            }

            #endregion
        }
Beispiel #15
0
        private void CheckTrig(ParticleManager pMan)
        {
            int frameIdx = charDef.GetAnimation(Anim).GetKeyFrame(AnimFrame).FrameRef;

            Frame frame = charDef.GetFrame(frameIdx);

            for (int i = 0; i < frame.GetPartArray().Length; i++)
            {
                Part part = frame.GetPart(i);
                if (part.Index >= 1000)
                {

                    float rotation = part.Rotation;

                    Vector2 location = part.Location * Scale + Loc;

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

                    FireTrig(part.Index - 1000, location, pMan);

                }
            }
        }
Beispiel #16
0
 public override void Update(float gameTime, Map map, ParticleManager pMan, Character[] c)
 {
     HitManager.CheckHit(this, c, pMan);
     KillMe();
 }
Beispiel #17
0
        public void Update(Character[] c, ParticleManager pMan)
        {
            LocalNetworkGamer gamer = GetGamer();
            if (gamer == null)
                return;

            frame -= FrameTime;
            if (frame < 0f)
            {
                frame = .05f;

                if (netPlay.Hosting)
                {
                    if (c[0] != null)
                    {
                        writer.Write(MSG_SERVER_DATA);

                        c[0].WriteToNet(writer);

                        for (int i = 2; i < c.Length; i++)
                            if (c[i] != null)
                                c[i].WriteToNet(writer);

                        pMan.NetWriteParticles(writer);

                        writer.Write(MSG_END);
                        gamer.SendData(writer, SendDataOptions.None);
                    }
                }
                if (netPlay.Joined)
                {
                    if (c[1] != null)
                    {
                        writer.Write(MSG_CLIENT_DATA);

                        c[1].WriteToNet(writer);

                        pMan.NetWriteParticles(writer);

                        writer.Write(MSG_END);
                        gamer.SendData(writer, SendDataOptions.None);
                    }

                }

            }
            if (gamer.IsDataAvailable)
            {
                NetworkGamer sender;
                gamer.ReceiveData(reader, out sender);

                if (!sender.IsLocal)
                {
                    byte type = reader.ReadByte();

                    if (netPlay.Joined)
                    {
                        for (int i = 0; i < c.Length; i++)
                            if (i != 1)
                                if (c[i] != null)
                                    c[i].ReceivedNetUpdate = false;

                    }

                    bool end = false;
                    while (!end)
                    {
                        byte msg = reader.ReadByte();
                        switch (msg)
                        {
                            case MSG_END:
                                end = true;
                                break;
                            case MSG_CHARACTER:

                                int defID = NetPacker.SbyteToInt(reader.ReadSByte());
                                int team = NetPacker.SbyteToInt(reader.ReadSByte());
                                int ID = NetPacker.SbyteToInt(reader.ReadSByte());

                                if (c[ID] == null)
                                {
                                    c[ID] = new Character(new Vector2(),
                                        Game1.charDef[defID],
                                        ID, team);
                                }

                                c[ID].ReadFromNet(reader);

                                c[ID].ReceivedNetUpdate = true;
                                break;
                            case MSG_PARTICLE:
                                byte pType = reader.ReadByte();
                                bool bg = reader.ReadBoolean();

                                switch (pType)
                                {
                                    case Particle.PARTICLE_NONE:
                                        //
                                        break;
                                    case Particle.PARTICLE_BLOOD:
                                        pMan.AddParticle(new Blood(reader), bg, true);
                                        break;
                                    case Particle.PARTICLE_BLOOD_DUST:
                                        pMan.AddParticle(new BloodDust(reader), bg, true);
                                        break;
                                    case Particle.PARTICLE_BULLET:
                                        pMan.AddParticle(new Bullet(reader), bg, true);
                                        break;
                                    case Particle.PARTICLE_FIRE:
                                        pMan.AddParticle(new Fire(reader), bg, true);
                                        break;
                                    case Particle.PARTICLE_FOG:
                                        pMan.AddParticle(new Fog(reader), bg, true);
                                        break;
                                    case Particle.PARTICLE_HEAT:
                                        pMan.AddParticle(new Heat(reader), bg, true);
                                        break;
                                    case Particle.PARTICLE_HIT:
                                        pMan.AddParticle(new Hit(reader), bg, true);
                                        break;
                                    case Particle.PARTICLE_MUZZLEFLASH:
                                        pMan.AddParticle(new MuzzleFlash(reader), bg, true);
                                        break;
                                    case Particle.PARTICLE_ROCKET:
                                        pMan.AddParticle(new Rocket(reader), bg, true);
                                        break;
                                    case Particle.PARTICLE_SHOCKWAVE:
                                        pMan.AddParticle(new Shockwave(reader), bg, true);
                                        break;
                                    case Particle.PARTICLE_SMOKE:
                                        pMan.AddParticle(new Smoke(reader), bg, true);
                                        break;
                                    default:
                                        //Error!
                                        break;
                                }
                                break;
                        }
                    }

                    if (netPlay.Joined)
                    {
                        for (int i = 0; i < c.Length; i++)
                            if (i != 1)
                                if (c[i] != null)
                                    if (c[i].ReceivedNetUpdate == false)
                                    {
                                        c[i] = null;
                                    }

                    }
                }
            }
        }
Beispiel #18
0
        protected override void Initialize()
        {
            _map = new Map("start");

            CharDefs[(int)CharacterType.Guy] = new CharDef("chars/guy");
            CharDefs[(int)CharacterType.Zombie] = new CharDef("chars/zombie");

            _characters[0] = new Character(new Vector2(100, 100), CharDefs[(int)CharacterType.Guy], 0,
                Character.TeamGoodGuys) { Map = _map };

            _screenSize.X = GraphicsDevice.Viewport.Width;
            _screenSize.Y = GraphicsDevice.Viewport.Height;

            base.Initialize();

            _particleManager = new ParticleManager(_spriteBatch);
        }
Beispiel #19
0
 private void FireTrig(int trig, Vector2 loc, ParticleManager pMan)
 {
     switch (trig)
     {
         case TRIG_PISTOL_ACROSS:
         case TRIG_PISTOL_UP:
         case TRIG_PISTOL_DOWN:
             if (Team == TEAM_GOOD_GUYS && ID < 4)
             {
                 QuakeManager.SetRumble(ID, 1, .5f);
                 QuakeManager.SetRumble(ID, 0, .3f);
             }
             break;
     }
     switch (trig)
     {
         case TRIG_FIRE_DIE:
             for (int i = 0; i < 5; i++)
             {
                 pMan.AddParticle(new Fire(loc +
                     Rand.GetRandomVector2(-30f, 30f, -30f, 30f),
                     Rand.GetRandomVector2(-5f, 60f, -150f, -20f),
                     Rand.GetRandomFloat(.3f, .8f), Rand.GetRandomInt(0, 4),
                     Rand.GetRandomFloat(.5f, .8f)));
             }
             pMan.AddParticle(new Smoke(loc,
                 Rand.GetRandomVector2(-10f, 10f, -60f, 10f),
                 1f, .8f, .6f, 1f, Rand.GetRandomFloat(.5f, 1.2f),
                 Rand.GetRandomInt(0, 4)));
             pMan.AddParticle(new Heat(loc,
                 Rand.GetRandomVector2(-50f, 50f, -100f, 0f),
                 Rand.GetRandomFloat(1f, 2f)));
             break;
         case TRIG_ROCKET:
             pMan.AddParticle(new Rocket(loc, new Vector2((Face == CharDir.Right ? 350f : -350f),
                 100f), ID));
             break;
         case TRIG_PISTOL_ACROSS:
             pMan.MakeBullet(loc, new Vector2(2000f, 0f), Face, ID);
             Sound.PlayCue("revol");
             //QuakeManager.SetQuake(0.3f);
             break;
         case TRIG_PISTOL_DOWN:
             pMan.MakeBullet(loc, new Vector2(1400f, 1400f), Face, ID);
             Sound.PlayCue("revol");
             //QuakeManager.SetQuake(0.3f);
             break;
         case TRIG_PISTOL_UP:
             pMan.MakeBullet(loc, 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_FORNWARD:
         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 (trig)
             {
                 case TRIG_BLOOD_SQUIRT_FORWARD:
                     r = 0.0;
                     break;
                 case TRIG_BLOOD_SQUIRT_DOWN_FORNWARD:
                     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++)
             {
                 pMan.AddParticle(new Blood(loc, new Vector2(
                     (float)Math.Cos(r) * (Face == CharDir.Right ? 1f : -1f),
                     (float)Math.Sin(r)
                     ) * Rand.GetRandomFloat(10f, 500f) +
                     Rand.GetRandomVector2(-90f, 90f, -90f, 90f),
                     1f, 0f, 0f, 1f, Rand.GetRandomFloat(0.1f, 0.5f),
                     Rand.GetRandomInt(0, 4)));
             }
             pMan.AddParticle(new BloodDust(loc,
                 Rand.GetRandomVector2(-30f, 30f, -30f, 30f),
                 1f, 0f, 0f, .2f,
                 Rand.GetRandomFloat(.25f, .5f),
                 Rand.GetRandomInt(0, 4)));
             break;
         case TRIG_BLOOD_CLOUD:
             pMan.AddParticle(new BloodDust(loc,
                 Rand.GetRandomVector2(-30f, 30f, -30f, 30f),
                 1f, 0f, 0f, .4f,
                 Rand.GetRandomFloat(.25f, .75f),
                 Rand.GetRandomInt(0, 4)));
             break;
         case TRIG_BLOOD_SPLAT:
             for (int i = 0; i < 6; i++)
             {
                 pMan.AddParticle(new BloodDust(loc,
                 Rand.GetRandomVector2(-30f, 30f, -30f, 30f),
                 1f, 0f, 0f, .4f,
                 Rand.GetRandomFloat(.025f, .125f),
                 Rand.GetRandomInt(0, 4)));
             }
             break;
         default:
             pMan.AddParticle(new Hit(loc, new Vector2(
                 200f * (float)Face - 100f, 0f),
                 ID, trig));
             break;
     }
 }
Beispiel #20
0
        public void Update(ParticleManager pMan, Character[] c)
        {
            CheckTransitions(c);
            if (TransOutFrame > 0f)
            {
                TransOutFrame -= Game1.FrameTime * 3f;
                if (TransOutFrame <= 0f)
                {
                    Path = TransitionDestination[(int) TransDir];
                    Read();
                    TransInFrame = 1.1f;

                    for (var i = 1; i < c.Length; i++)
                        c[i] = null;

                    pMan.Reset();
                }
            }
            if (TransInFrame > 0f)
            {
                TransInFrame -= Game1.FrameTime * 3f;
            }

            if (MapScript.IsReading)
                MapScript.DoScript(c);

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

            Frame += Game1.FrameTime;

            if (Fog)
            {
                if ((int)(PFrame * 10f) != (int)(Frame * 10f))
                    pMan.AddParticle(new Fog(Rand.GetRandomVector2(0f, 1280f, 600f, 1000f)));
            }

            for (var i = 0; i < 64; i++)
            {
                if (Segments[LayerMap, i] != null)
                {
                    if (SegmentDefinitions[Segments[LayerMap, i].Index].Flags == (int)SegmentFlags.Torch)
                    {
                        pMan.AddParticle(
                            new Smoke(
                                Segments[LayerMap, i].Location * 2f + new Vector2(20f, 13f),
                                Rand.GetRandomVector2(-50.0f, 50.0f, -300.0f, -200.0f),
                                1.0f, 0.8f, 0.6f, 1.0f,
                                Rand.GetRandomFloat(0.25f, 0.5f), Rand.GetRandomInt(0, 4)
                            ),
                            true
                        );
                        pMan.AddParticle(
                            new Fire(
                                Segments[LayerMap, i].Location * 2f + new Vector2(20f, 37f),
                                Rand.GetRandomVector2(-30.0f, 30.0f, -250.0f, -200.0f),
                                Rand.GetRandomFloat(0.25f, 0.75f),
                                Rand.GetRandomInt(0, 4)
                            ),
                            true
                        );
                    }
                }
            }
        }
Beispiel #21
0
        public static bool CheckHit(Particle p, Character[] c, 
            ParticleManager pMan)
        {
            bool r = false;

            CharDir tFace = GetFaceFromTraj(p.GetTraj());

            for (int i = 0; i < c.Length; i++)
            {
                if (i != p.Owner)
                {
                    if (c[i] != null)
                    {
                        if (c[i].DyingFrame < 0f &&
                            !c[i].ethereal)
                        {
                            if (c[i].InHitBounds(p.GetLoc()))
                            {
                                float hVal = 1f;

                                c[i].LastHitBy = p.Owner;
                                CharState pState = c[i].State;
                                Vector2 pLoc = c[i].Loc;

                                bool noAnim = false;
                                if (c[i].StunFrame > 0f &&
                                    c[i].StunFrame < 3f)
                                    noAnim = true;
                                if (c[i].NoLifty)
                                {
                                    if (c[i].StunFrame <= 0f ||
                                        c[i].StunFrame > 5.2f)
                                        c[i].StunFrame = 5.5f;

                                }

                                if (typeof(Bullet).Equals(p.GetType()))
                                {
                                    if (!r)
                                    {
                                        hVal *= 4f;

                                        c[i].Face = 1 - tFace;

                                        c[i].SetAnim("idle");
                                        if (!noAnim)
                                        {
                                            c[i].SetAnim("hit");
                                            c[i].Slide(-100f);
                                        }
                                        Sound.PlayCue("bullethit");

                                        Vector2 v = new Vector2(c[i].Loc.X,
                                            p.GetLoc().Y);
                                        pMan.MakeBulletBlood(v, p.GetTraj() / 2f);
                                        pMan.MakeBulletBlood(v, -p.GetTraj());
                                        pMan.MakeBulletDust(v, p.GetTraj());
                                        Game1.SlowTime = 0.05f;

                                        r = true;
                                    }
                                }
                                else if (typeof(Rocket).Equals(p.GetType()))
                                {
                                    pMan.MakeExplosion(p.GetLoc(), 1f);
                                    hVal *= 5f;
                                    if (!noAnim)
                                    {
                                        c[i].Trajectory.X = (p.GetTraj().X > 0f ? 600f : -600f);
                                        c[i].SetAnim("jhit");
                                        c[i].SetJump(300f);
                                    }
                                    Game1.SlowTime = 0.25f;
                                    r = true;
                                }
                                else if (typeof(Hit).Equals(p.GetType()))
                                {
                                    c[i].Face = 1 - tFace;
                                    float tX = 1f;
                                    if (tFace == CharDir.Left)
                                        tX = -1f;
                                    if (!noAnim)
                                    {
                                        c[i].SetAnim("idle");
                                        c[i].SetAnim("hit");
                                    }
                                    Sound.PlayCue("zomhit");

                                    if (c[i].State == CharState.Grounded)
                                        c[i].Slide(-200f);
                                    else
                                        c[i].Slide(-50f);

                                    switch (p.GetFlag())
                                    {

                                        case Character.TRIG_ZOMBIE_HIT:
                                            hVal *= 5f;
                                            pMan.MakeBloodSplash(p.GetLoc(),
                                                new Vector2(50f * tX, 100f));

                                            break;
                                        case Character.TRIG_WRENCH_DIAG_DOWN:
                                            hVal *= 5f;
                                            pMan.MakeBloodSplash(p.GetLoc(),
                                                new Vector2(50f * tX, 100f));

                                            Game1.SlowTime = 0.1f;

                                            break;
                                        case Character.TRIG_WRENCH_DIAG_UP:
                                            hVal *= 5f;
                                            pMan.MakeBloodSplash(p.GetLoc(),
                                                new Vector2(-50f * tX, -100f));

                                            Game1.SlowTime = 0.1f;

                                            break;
                                        case Character.TRIG_WRENCH_UP:
                                            hVal *= 5f;
                                            pMan.MakeBloodSplash(p.GetLoc(),
                                                new Vector2(30f * tX, -100f));
                                            Game1.SlowTime = 0.1f;

                                            break;
                                        case Character.TRIG_WRENCH_DOWN:
                                            hVal *= 5f;
                                            pMan.MakeBloodSplash(p.GetLoc(),
                                                new Vector2(-50f * tX, 100f));

                                            Game1.SlowTime = 0.1f;
                                            Sound.PlayCue("zomhit");

                                            break;
                                        case Character.TRIG_WRENCH_UPPERCUT:
                                        case Character.TRIG_CHAINSAW_UPPER:
                                            hVal *= 15f;
                                            pMan.MakeBloodSplash(p.GetLoc(),
                                                new Vector2(-50f * tX, -150f));
                                            c[i].Trajectory.X = 100f * tX;

                                            c[i].SetAnim("jhit");
                                            c[i].SetJump(700f);
                                            Game1.SlowTime = 0.125f;
                                            QuakeManager.SetQuake(.5f);
                                            QuakeManager.SetBlast(.5f, p.GetLoc());
                                            break;
                                        case Character.TRIG_WRENCH_SMACKDOWN:
                                        case Character.TRIG_CHAINSAW_DOWN:
                                            hVal *= 15f;
                                            pMan.MakeBloodSplash(p.GetLoc(),
                                                new Vector2(-50f * tX, 150f));
                                            c[i].SetAnim("jfall");
                                            c[i].SetJump(-900f);

                                            Game1.SlowTime = 0.125f;
                                            QuakeManager.SetQuake(.5f);
                                            QuakeManager.SetBlast(.5f, p.GetLoc());
                                            break;
                                        case Character.TRIG_KICK:
                                            hVal *= 15f;
                                            pMan.MakeBloodSplash(p.GetLoc(),
                                                new Vector2(300f * tX, 0f));

                                            c[i].Trajectory.X = 1000f * tX;

                                            c[i].SetAnim("jhit");
                                            c[i].SetJump(300f);

                                            Game1.SlowTime = 0.25f;
                                            QuakeManager.SetQuake(.5f);
                                            QuakeManager.SetBlast(.75f, p.GetLoc());
                                            break;
                                    }
                                }
                                if (c[i].State == CharState.Air)
                                {

                                    if (c[i].AnimName == "hit")
                                    {
                                        c[i].SetAnim("jmid");
                                        c[i].SetJump(300f);
                                        if (typeof(Hit).Equals(p.GetType()))
                                        {
                                            if (c[p.Owner].Team ==
                                                Character.TEAM_GOOD_GUYS)
                                            {
                                                c[i].Loc.Y =
                                                    c[p.Owner].Loc.Y;
                                            }
                                        }
                                    }
                                    if (c[i].NoLifty)
                                    {
                                        if (pState == CharState.Grounded)
                                        {
                                            c[i].Loc = pLoc;
                                            c[i].State = pState;
                                            c[i].SetAnim("hit");
                                        }
                                        if (c[i].Trajectory.X > 300f)
                                            c[i].Trajectory.X = 300f;
                                        if (c[i].Trajectory.X < -300f)
                                            c[i].Trajectory.X = -300f;
                                    }
                                }

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

                                if (c[i].LastHitBy == 0)
                                    Game1.Score += (int)hVal * 50;

                                if (c[i].HP < 0)
                                {
                                    if (c[i].AnimName == "hit")
                                        c[i].SetAnim("diehit");
                                    if (i == 0)
                                    {
                                        if (c[i].AnimName == "hit")
                                        {
                                            c[i].SetAnim("jmid");
                                            c[i].SetJump(300f);

                                        }
                                        Game1.Menu.Die();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return r;
        }