public override void Update() { if (!damaged) { foreach (Actor a in MainGame.dm.Players) { if (a is ClientPlayer && a.Alive) { float angleBetween = Helper.angleBetween(this.Pos, a.Core); if (Helper.Distance(a.Core, this.Pos) < 130) { a.Health -= 20; a.ouchTimer = 10; a.Killer = this.Owner; } if (Helper.Distance(a.Core, this.Pos) < 110) { a.Health -= 30; a.ouchTimer = 10; a.Killer = this.Owner; } if (Helper.Distance(a.Core, this.Pos) < 80) { a.Health = 0; a.Killer = this.Owner; } } } damaged = true; for (int i = 0; i < 6; i++) { int gibNum = MainGame.rand.Next(1, 3); Gib g = new Gib(new Texture(Content.GetTexture("explosionGib" + gibNum + ".png")), this.Pos, (float)MainGame.rand.NextDouble() * 6.5f, Helper.angleBetween(this.Pos, this.Pos - new Vector2f(0, 4)) + (float)Math.PI + (float)(i - 5 / 10f) + (float)MainGame.rand.NextDouble()); MainGame.dm.GameObjects.Add(g); } } animation.Update(); if (animation.Frame >= animation.Count - 1) { MainGame.dm.GameObjects.Remove(this); } base.Update(); }
public override void Update() { if (!damaged) { foreach (Actor a in MainGame.dm.Players) { if (a is ClientPlayer && a.Alive) { float angleBetween = Helper.angleBetween(this.Pos, a.Core); if (Helper.Distance(a.Core, this.Pos) < 130) { a.Health -= 20; a.ouchTimer = 10; a.Killer = this.Owner; } if (Helper.Distance(a.Core, this.Pos) < 110) { a.Health -= 30; a.ouchTimer = 10; a.Killer = this.Owner; } if (Helper.Distance(a.Core, this.Pos) < 80) { a.Health = 0; a.Killer = this.Owner; } } } damaged = true; for (int i = 0; i < 6; i++) { int gibNum = MainGame.rand.Next(1, 3); Gib g = new Gib(new Texture(Content.GetTexture("explosionGib" + gibNum + ".png")), this.Pos, (float)MainGame.rand.NextDouble() * 6.5f, Helper.angleBetween(this.Pos, this.Pos - new Vector2f(0, 4)) + (float)Math.PI + (float)(i - 5 / 10f) + (float)MainGame.rand.NextDouble()); MainGame.dm.GameObjects.Add(g); } } animation.Update(); if (animation.Frame >= animation.Count - 1) MainGame.dm.GameObjects.Remove(this); base.Update(); }
public void HandleDeath() { if (Alive) { if (Health <= 0) { Alive = false; for (int i = 0; i < MainGame.gibCount; i++) { int gibNum = MainGame.rand.Next(1, 4); Gib g = new Gib(new Texture(Content.GetTexture("gib" + gibNum + ".png")), Core - new Vector2f(0, 4) + new Vector2f(MainGame.rand.Next(-4, 5), MainGame.rand.Next(-4, 5)), (float)MainGame.rand.NextDouble() * 4.5f, Helper.angleBetween(Core, Core - new Vector2f(0, 4)) + (float)Math.PI + (float)(i - 5 / 10f) + (float)MainGame.rand.NextDouble()); g.addVel = new Vector2f(Velocity.X / 15, Velocity.Y / 35); //Trauma MainGame.dm.GameObjects.Add(g); } MainGame.dm.GameObjects.Add(new Gib(new Texture(Content.GetTexture("gibHead.png")), Core - new Vector2f(0, 4), 3, Helper.angleBetween(Core, Core - new Vector2f(0, 4)) + (float)Math.PI)); MainGame.dm.GameObjects.Add(new Gib(new Texture(Content.GetTexture("gibBody.png")), Core - new Vector2f(0, 1), 2, Helper.angleBetween(Core, Core - new Vector2f(1, 2)) + (float)Math.PI)); MainGame.dm.GameObjects.Add(new Gib(new Texture(Content.GetTexture("gibUpperLeg.png")), Core + new Vector2f(0, 1), 3.2f, Helper.angleBetween(Core, Core - new Vector2f(.5f, 1)) + (float)Math.PI)); MainGame.dm.GameObjects.Add(new Gib(new Texture(Content.GetTexture("gibUpperLeg.png")), Core + new Vector2f(0, 1), 3.2f, Helper.angleBetween(Core, Core - new Vector2f(-.5f, 1)) + (float)Math.PI)); MainGame.dm.GameObjects.Add(new Gib(new Texture(Content.GetTexture("gibLowerLeg.png")), Core + new Vector2f(0, 1), 3.2f, Helper.angleBetween(Core, Core - new Vector2f(.15f, 3)) + (float)Math.PI)); MainGame.dm.GameObjects.Add(new Gib(new Texture(Content.GetTexture("gibLowerLeg.png")), Core + new Vector2f(0, 1), 3.2f, Helper.angleBetween(Core, Core - new Vector2f(-.20f, 2)) + (float)Math.PI)); MainGame.dm.GameObjects.Add(new Gib(new Texture(Content.GetTexture("gibArm.png")), Core + new Vector2f(0, 1), 3.2f, Helper.angleBetween(Core, Core - new Vector2f(.04f, 3)) + (float)Math.PI)); MainGame.dm.GameObjects.Add(new Gib(new Texture(Content.GetTexture("gibArm.png")), Core + new Vector2f(0, 1), 3.2f, Helper.angleBetween(Core, Core - new Vector2f(-.55f, 2)) + (float)Math.PI)); } } }
public void HandleDeath() { if (Alive) { if (Health <= 0) { if (Killer != null) { MainGame.dm.Mailman.SendKillerMessage(Killer.UID); } else { MainGame.dm.Mailman.SendKillerMessage(0); } MainGame.soundInstances.Add(new SoundInstance(Content.GetSound("splat.wav"), 1f, .1f, 3)); MainGame.soundInstances.Add(new SoundInstance(Content.GetSound("SaD.wav"), 1f, .1f, 2)); DropMoney(DropOnDeathCoins); dm.player.gold -= DropOnDeathCoins; Health = 0; Alive = false; for (int i = 0; i < MainGame.gibCount; i++) { int gibNum = MainGame.rand.Next(1, 4); Gib g = new Gib(new Texture(Content.GetTexture("gib" + gibNum + ".png")), Core - new Vector2f(0, 4) + new Vector2f(MainGame.rand.Next(-4, 5), MainGame.rand.Next(-4, 5)), (float)MainGame.rand.NextDouble() * 4.5f, Helper.angleBetween(Core, Core - new Vector2f(0, 4)) + (float)Math.PI + (float)(i - 5 / 10f) + (float)MainGame.rand.NextDouble()); g.addVel = new Vector2f(Velocity.X / 15, Velocity.Y / 35); //Trauma MainGame.dm.GameObjects.Add(g); } MainGame.dm.GameObjects.Add(new Gib(new Texture(Content.GetTexture(model.gibHeadFile)), Core - new Vector2f(0, 4), 3, Helper.angleBetween(Core, Core - new Vector2f(0, 4)) + (float)Math.PI)); MainGame.dm.GameObjects.Add(new Gib(new Texture(Content.GetTexture(model.gibBodyFile)), Core - new Vector2f(0, 1), 2, Helper.angleBetween(Core, Core - new Vector2f(1, 2)) + (float)Math.PI)); MainGame.dm.GameObjects.Add(new Gib(new Texture(Content.GetTexture(model.gibUpperLegFile)), Core + new Vector2f(0, 1), 3.2f, Helper.angleBetween(Core, Core - new Vector2f(.5f, 1)) + (float)Math.PI)); MainGame.dm.GameObjects.Add(new Gib(new Texture(Content.GetTexture(model.gibUpperLegFile)), Core + new Vector2f(0, 1), 3.2f, Helper.angleBetween(Core, Core - new Vector2f(-.5f, 1)) + (float)Math.PI)); MainGame.dm.GameObjects.Add(new Gib(new Texture(Content.GetTexture(model.gibLowerLegFile)), Core + new Vector2f(0, 1), 3.2f, Helper.angleBetween(Core, Core - new Vector2f(.15f, 3)) + (float)Math.PI)); MainGame.dm.GameObjects.Add(new Gib(new Texture(Content.GetTexture(model.gibLowerLegFile)), Core + new Vector2f(0, 1), 3.2f, Helper.angleBetween(Core, Core - new Vector2f(-.20f, 2)) + (float)Math.PI)); MainGame.dm.GameObjects.Add(new Gib(new Texture(Content.GetTexture(model.gibArmFile)), Core + new Vector2f(0, 1), 3.2f, Helper.angleBetween(Core, Core - new Vector2f(.04f, 3)) + (float)Math.PI)); MainGame.dm.GameObjects.Add(new Gib(new Texture(Content.GetTexture(model.gibArmFile)), Core + new Vector2f(0, 1), 3.2f, Helper.angleBetween(Core, Core - new Vector2f(-.55f, 2)) + (float)Math.PI)); //MainGame.dm.Players.Remove(this); } } else { deathTimer++; if (Killer != null) if (deathTimer > 60 * 2.5f) { Helper.MoveCameraTo(MainGame.Camera, Killer.Core, .8f); } if (respawnTimer > 0) respawnTimer--; } }
public void HandleDeath() { if (Alive) { if (Health <= 0) { if (Killer != null) { MainGame.dm.Mailman.SendKillerMessage(Killer.UID); } else { MainGame.dm.Mailman.SendKillerMessage(0); } MainGame.soundInstances.Add(new SoundInstance(Content.GetSound("splat.wav"), 1f, .1f, 3)); MainGame.soundInstances.Add(new SoundInstance(Content.GetSound("SaD.wav"), 1f, .1f, 2)); DropMoney(DropOnDeathCoins); dm.player.gold -= DropOnDeathCoins; Health = 0; Alive = false; for (int i = 0; i < MainGame.gibCount; i++) { int gibNum = MainGame.rand.Next(1, 4); Gib g = new Gib(new Texture(Content.GetTexture("gib" + gibNum + ".png")), Core - new Vector2f(0, 4) + new Vector2f(MainGame.rand.Next(-4, 5), MainGame.rand.Next(-4, 5)), (float)MainGame.rand.NextDouble() * 4.5f, Helper.angleBetween(Core, Core - new Vector2f(0, 4)) + (float)Math.PI + (float)(i - 5 / 10f) + (float)MainGame.rand.NextDouble()); g.addVel = new Vector2f(Velocity.X / 15, Velocity.Y / 35); //Trauma MainGame.dm.GameObjects.Add(g); } MainGame.dm.GameObjects.Add(new Gib(new Texture(Content.GetTexture(model.gibHeadFile)), Core - new Vector2f(0, 4), 3, Helper.angleBetween(Core, Core - new Vector2f(0, 4)) + (float)Math.PI)); MainGame.dm.GameObjects.Add(new Gib(new Texture(Content.GetTexture(model.gibBodyFile)), Core - new Vector2f(0, 1), 2, Helper.angleBetween(Core, Core - new Vector2f(1, 2)) + (float)Math.PI)); MainGame.dm.GameObjects.Add(new Gib(new Texture(Content.GetTexture(model.gibUpperLegFile)), Core + new Vector2f(0, 1), 3.2f, Helper.angleBetween(Core, Core - new Vector2f(.5f, 1)) + (float)Math.PI)); MainGame.dm.GameObjects.Add(new Gib(new Texture(Content.GetTexture(model.gibUpperLegFile)), Core + new Vector2f(0, 1), 3.2f, Helper.angleBetween(Core, Core - new Vector2f(-.5f, 1)) + (float)Math.PI)); MainGame.dm.GameObjects.Add(new Gib(new Texture(Content.GetTexture(model.gibLowerLegFile)), Core + new Vector2f(0, 1), 3.2f, Helper.angleBetween(Core, Core - new Vector2f(.15f, 3)) + (float)Math.PI)); MainGame.dm.GameObjects.Add(new Gib(new Texture(Content.GetTexture(model.gibLowerLegFile)), Core + new Vector2f(0, 1), 3.2f, Helper.angleBetween(Core, Core - new Vector2f(-.20f, 2)) + (float)Math.PI)); MainGame.dm.GameObjects.Add(new Gib(new Texture(Content.GetTexture(model.gibArmFile)), Core + new Vector2f(0, 1), 3.2f, Helper.angleBetween(Core, Core - new Vector2f(.04f, 3)) + (float)Math.PI)); MainGame.dm.GameObjects.Add(new Gib(new Texture(Content.GetTexture(model.gibArmFile)), Core + new Vector2f(0, 1), 3.2f, Helper.angleBetween(Core, Core - new Vector2f(-.55f, 2)) + (float)Math.PI)); //MainGame.dm.Players.Remove(this); } } else { deathTimer++; if (Killer != null) { if (deathTimer > 60 * 2.5f) { Helper.MoveCameraTo(MainGame.Camera, Killer.Core, .8f); } } if (respawnTimer > 0) { respawnTimer--; } } }