Пример #1
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);
        }
Пример #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);
        }
Пример #3
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;
        }
Пример #4
0
        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;
            }
        }
Пример #5
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;
                                    }

                    }
                }
            }
        }
Пример #6
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
                        );
                    }
                }
            }
        }
Пример #7
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;
     }
 }