protected override void Update(GameTime gameTime) { Sound.Update(); Music.Play("music1"); QuakeManager.Update(); ControlInput.Update(); FrameTime = (float)gameTime.ElapsedGameTime.TotalSeconds; if (SlowTime > 0f) { SlowTime -= FrameTime; FrameTime /= 10f; } switch (GameMode) { case GameModes.Playing: UpdateGame(); break; case GameModes.Menu: if (Menu.MenuMode == MenuMode.Dead) { var pTime = FrameTime; FrameTime /= 3f; UpdateGame(); FrameTime = pTime; } Menu.Update(this); break; } base.Update(gameTime); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// /// We'll instantiate our stuff, load character definitions. /// /// /// </summary> protected override void Initialize() { Rand.random = new Random(); map = new Map(); netPlay = new NetPlay(); screenSize.X = 800f; screenSize.Y = 600f; charDef[(int)CharacterDefinitions.Guy] = new CharDef("chars/guy", CharacterDefinitions.Guy); charDef[(int)CharacterDefinitions.Zombie] = new CharDef("chars/zombie", CharacterDefinitions.Zombie); charDef[(int)CharacterDefinitions.Wraith] = new CharDef("chars/wraith", CharacterDefinitions.Wraith); charDef[(int)CharacterDefinitions.Carlos] = new CharDef("chars/carlos", CharacterDefinitions.Carlos); Sound.Initialize(); Music.Initialize(); QuakeManager.Init(); base.Initialize(); store = new Store(); settings = new Settings(); store.GetDevice(); }
private void Awake() { if (Instance == null) { Instance = this; } else { Destroy(this); } }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { this.Exit(); } Sound.Update(); Music.Play("music1"); QuakeManager.Update(); frameTime = (float)gameTime.ElapsedGameTime.TotalSeconds; NetPlay.NetGame.FrameTime = FrameTime; frameTime *= 1.5f; if (SlowTime > 0f) { SlowTime -= FrameTime; frameTime /= 10f; } NetPlay.Update(character, pManager); store.Update(); switch (gameMode) { case GameModes.Playing: UpdateGame(); break; case GameModes.Menu: if (menu.menuMode == Menu.MenuMode.Dead) { float pTime = FrameTime; frameTime /= 3f; UpdateGame(); frameTime = pTime; } menu.Update(this); break; } base.Update(gameTime); }
/// <summary> /// Make wraith missle explosion, using smoke, fire, and a shockwave refraction effect. /// </summary> /// <param name="loc">Explosion location</param> /// <param name="mag">Explosion magnitude--affects particle size</param> public void MakeExplosion(Vector2 loc, float mag) { for (int i = 0; i < 8; i++) { AddParticle(new Smoke(loc, Rand.GetRandomVector2(-100f, 100f, -100f, 100f), 1f, .8f, .6f, 1f, Rand.GetRandomFloat(1f, 1.5f), Rand.GetRandomInt(0, 4))); } for (int i = 0; i < 8; i++) { AddParticle(new Fire(loc, Rand.GetRandomVector2(-80f, 80f, -80f, 80f), 1f, Rand.GetRandomInt(0, 4))); } AddParticle(new Shockwave(loc, true, 25f)); AddParticle(new Shockwave(loc, false, 10f)); Sound.PlayCue("explode"); QuakeManager.SetQuake(.5f); QuakeManager.SetBlast(1f, loc); }
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); }
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; } }
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); }
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; } }