public override void Update(ManagerHelper mH) { if (drawTime > 0) { if (timer > spawnTime) { //Animate the fire frameIndex++; if (frameIndex > 3) { frameIndex = 0; } timer = 0; mH.GetParticleManager() .AddStandardSmoke(GetOriginPosition(), 1); } else { timer += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } } base.Update(mH); }
public override void Update(ManagerHelper mH) { if (isExplosive && drawTime <= 0) { mH.GetParticleManager().AddExplosion(GetOriginPosition(), this.creator, damage); isExplosive = false; } if (position.X < 0 || position.X > mH.GetLevelSize().X || position.Y < 0 || position.Y > mH.GetLevelSize().Y) { SetDrawTime(0); } if (drawTime > 0) { drawTime -= mH.GetGameTime().ElapsedGameTime.TotalSeconds; SpriteUpdate(mH); //Spawn cool things to make it look better if (mH.GetRandom().NextDouble() < 0.5f) { EffectSpawnCode(mH); } } existenceTime -= mH.GetGameTime().ElapsedGameTime.TotalSeconds; }
public override void Update(ManagerHelper mH) { //Slow it to a stop if (velocity.Length() > 5) { Turn(((turnRight) ? -1 : 1) * MathHelper.Pi / 15 * (velocity.Length() / 64)); //Spawn blood if (mH.GetRandom().Next(100) < 0) { mH.GetParticleManager() .AddFire(GetOriginPosition(), PathHelper.Direction((float)(mH.GetRandom().NextDouble() * Math.PI * 2)) * 100, 2, 0.03f, 1, 1); } } else if (velocity.Length() != 0) { velocity *= 0; } //Prevent body parts from intersecting surroundings foreach (Environment e in mH.GetEnvironmentManager().GetStaticBlockers()) { int tempCollide = CollisionHelper.IntersectPixelsDirectional(this, e); if (tempCollide != -1) { velocity = CollisionHelper.CollideDirectional(GetOriginPosition(), tempCollide) * velocity.Length() * 0.8f; } } base.Update(mH); }
protected override bool ProjectileCheck(ManagerHelper mH) { if (health <= 0) { return(true); } else { foreach (Projectile p in mH.GetProjectileManager().GetProjectiles()) { if (p.GetDrawTime() > 0 && p.GetAffiliation() != affiliation && CollisionHelper.IntersectPixelsSimple(this, p) != new Vector2(-1)) { lastDamagerDirection = PathHelper.DirectionVector(GetOriginPosition(), p.GetOriginPosition()); counter = 0; float test = p.GetRotation() + MathHelper.Pi; if (test > MathHelper.TwoPi) { test -= MathHelper.TwoPi; } if (MathHelper.Distance(test, rotation) > (MathHelper.Pi * 5 / 6)) { ChangeHealth(-1 * p.GetDamage(), p.GetCreator()); mH.GetParticleManager().AddBlood(this); if (health <= 0) { return(true); } } else { Vector2 knockback = new Vector2((float)(p.velocity.X * .05), (float)(p.velocity.Y * .05)); accelerations.Add(knockback); mH.GetAudioManager().Play(AudioManager.JUGGERNAUT_RICOHET, (float).05, 0, 0, false); } p.SetDrawTime(0); } else { counter += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } if (counter > 2) { counter = 0; lastDamagerDirection = Vector2.Zero; } } } return(false); }
protected override void Explode(ManagerHelper mH) { mH.GetParticleManager().AddExplosion(GetOriginPosition(), ((lastDamager == null) ? this : lastDamager), 300); mH.GetNPCManager().Remove(this); if (lastDamager != null) { mH.GetGametype().ChangeScore(lastDamager, 1); } }
protected override void Behavior(ManagerHelper mH) { if (mH.GetRandom().Next(100) == 0) { //Spawn lightning thing mH.GetParticleManager().AddParticle("Effects/spr_bolt_strip3", GetOriginPosition() + new Vector2(mH.GetRandom().Next(-16, 16), mH.GetRandom().Next(-16, 16)), Vector2.Zero, 0.05f, 0, 0, (float)MathHelper.Pi / 10); } }
protected override void Shoot(ManagerHelper mH) { foreach (NPC agent in mH.GetNPCManager().GetAllies(affiliation)) { if (agent != this && NPCManager.IsNPCInRadius(agent, GetOriginPosition(), healRadius)) { agent.ChangeHealth(HEAL_NUM, this); mH.GetParticleManager().AddHeal(agent); } } }
protected virtual void EffectSpawnCode(ManagerHelper mH) { //Spawn bullet particles 15% of the time if (mH.GetRandom().Next(100) < 15) { mH.GetParticleManager() .AddParticle("Effects/particle_smoke", GetOriginPosition(), PathHelper.Direction((float)(MathHelper.Pi * mH.GetRandom().NextDouble()) * 2) * 20, 4, 0.005f, 1, 0.1f); } }
protected virtual void Explode(ManagerHelper mH) { for (int i = 0; i < 4; i++) { mH.GetParticleManager().AddGut(this, i); } mH.GetNPCManager().Remove(this); if ((mH.GetGametype() is Assasssins || mH.GetGametype() is Deathmatch) && lastDamager != null) { mH.GetGametype().ChangeScore(lastDamager, 1); } }
public override void Update(ManagerHelper mH) { if (armed) { if (existanceTimer > existanceTime) { draw = false; } else { foreach (NPC agent in mH.GetNPCManager().GetNPCs()) { if (agent.GetAffiliation() != creator.GetAffiliation() && NPCManager.IsNPCInRadius(agent, GetOriginPosition(), explodeRadius)) { draw = false; mH.GetParticleManager().AddExplosion(GetOriginPosition(), creator, damage); } } } } else { if (existanceTimer > armedTime) { armed = true; modeIndex = NPC.GetTeam(creator.GetAffiliation()) + 1; } } if (pulseTimer > pulseBeginTime) { frameIndex = (int)(totalFrames * (pulseTimer - pulseBeginTime) / (pulseTime - pulseBeginTime)); } else { frameIndex = 0; } if (pulseTimer > pulseTime) { pulseTimer = 0; } pulseTimer += mH.GetGameTime().ElapsedGameTime.TotalSeconds; existanceTimer += mH.GetGameTime().ElapsedGameTime.TotalSeconds; base.Update(mH); }
public override void Update(ManagerHelper mH) { foreach (var agent in mH.GetNPCManager().GetNPCs()) { if (CollisionHelper.IntersectPixelsPoint(agent.GetOriginPosition(), this) != new Vector2(-1)) { agent.ChangeHealth(-2, null); mH.GetParticleManager() .AddFire(agent.GetOriginPosition(), PathHelper.Direction((float)(mH.GetRandom().NextDouble() * Math.PI * 2)) * 100, 1, 0.05f, 1, 0.1f); } } base.Update(mH); }
protected virtual bool ProjectileCheck(ManagerHelper mH) { if (health <= 0) { return(true); } if (mH.GetGametype() is Survival && affiliation != AffliationTypes.black) { return(false); } else { foreach (Projectile p in mH.GetProjectileManager().GetProjectiles()) { if (p.GetDrawTime() > 0 && p.GetAffiliation() != affiliation && CollisionHelper.IntersectPixelsSimple(this, p) != new Vector2(-1)) { lastDamagerDirection = PathHelper.DirectionVector(GetOriginPosition(), p.GetOriginPosition()); ChangeHealth(-1 * p.GetDamage(), p.GetCreator()); mH.GetParticleManager().AddBlood(this); counter = 0; if (health <= 0) { return(true); } p.SetDrawTime(0); } else { counter += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } if (counter > 2) { counter = 0; lastDamagerDirection = Vector2.Zero; } } } return(false); }
public override void Update(ManagerHelper mH) { foreach (Sprite section in poolSections) { section.Turn(10000.0f / (section.GetFrame().Width *section.GetFrame().Width) * mH.GetDeltaSeconds()); } foreach (NPC a in mH.GetNPCManager().GetNPCs()) { if (!(a is Bomber)) { float tempDistance = PathHelper.DistanceSquared(GetOriginPosition(), a.GetOriginPosition()); if (tempDistance < 15 * 15) { //TODO: Modify a.position = mH.GetLevelSize() * new Vector2(mH.GetRandom().Next(2), mH.GetRandom().Next(2)); } else if (tempDistance < frame.Width / 2 * frame.Width / 2) { float tempRot = PathHelper.Direction(a.GetOriginPosition(), GetOriginPosition()) - MathHelper.Pi / 9; a.AddAcceleration(new Vector2(DWMath.Cos(tempRot), DWMath.Sin(tempRot)) * 4); } } } foreach (Particle e in mH.GetParticleManager().GetParticles()) { float tempDistance = PathHelper.DistanceSquared(GetOriginPosition(), e.GetOriginPosition()); if (tempDistance < 15 * 15) { e.SetDrawTime(0); } else if (tempDistance < (frame.Width / 2) * (frame.Width / 2)) { float tempRot = PathHelper.Direction(e.GetOriginPosition(), GetOriginPosition()) + MathHelper.Pi / 9; e.AddAcceleration(new Vector2((float)DWMath.Cos(tempRot), (float)DWMath.Sin(tempRot)) * 100); } } base.Update(mH); }
public void Set(Vector2 p, NPC.AffliationTypes aT, ManagerHelper mH) { position = p; animateTime = 0.3f; timer = 0; health = 150; affiliation = aT; LoadContent(mH.GetTextureManager()); mH.GetAudioManager().Play(AudioManager.LARGE_ROCK, (float)mH.GetRandom().NextDouble() / 4 + 0.75f, AudioManager.RandomPitch(mH), 0, false); for (int i = 0; i < 10; i++) { mH.GetParticleManager().AddStandardSmoke(origin + position, 64); } }
public override void Update(ManagerHelper mH) { foreach (NPC a in mH.GetNPCManager().GetNPCs()) { if (CollisionHelper.IntersectPixelsDirectional(a, this) != -1) { if (a.GetAffiliation() == affiliation) { if (mH.GetRandom().Next(40) == 0) { a.ChangeHealth(10, NPC.AffliationTypes.same); mH.GetParticleManager().AddHeal(a); } } else { a.AddAcceleration(a.velocity * new Vector2(-0.003f)); } } } //Animations if (animateTimer < animateEnd) { frameIndex = (int)(animateTimer / animateEnd * totalFrames); } if (animateTimer < splashEnd) { splash.SetFrameIndex((int)(animateTimer / splashEnd * splash.totalFrames)); } animateTimer += mH.GetGameTime().ElapsedGameTime.TotalSeconds + (mH.GetRandom().NextDouble() / 1000); //Base Updates splash.Update(mH); base.Update(mH); }
public override void Update(ManagerHelper mH) { elapsedTime = mH.GetGameTime().ElapsedGameTime.TotalSeconds; if (isExplosive && drawTime <= 0) { mH.GetParticleManager().AddExplosion(GetOriginPosition(), creator, damage); isExplosive = false; } if (drawTime > 0) { drawTime -= mH.GetGameTime().ElapsedGameTime.TotalSeconds; pulseTimer += elapsedTime; frameTimer += elapsedTime; #region Tossable Update #region Keep it in the level //Update position Vector2 tempPos = position + velocity * mH.GetDeltaSeconds(); //Check for collisions with environment foreach (Environment e in mH.GetEnvironmentManager().GetStaticBlockers()) { int tempCollide = CollisionHelper.IntersectPixelsDirectionalRaw(this, tempPos, e); if (tempCollide != -1) { velocity = CollisionHelper.CollideDirectional(velocity, tempCollide); } } tempPos = position + velocity * mH.GetDeltaSeconds(); if ((tempPos.X < 0 || tempPos.X > mH.GetLevelSize().X - frame.Width - 0 || tempPos.Y < 0 || tempPos.Y > mH.GetLevelSize().Y - frame.Height - 0)) { if (tempPos.X <= 0) { velocity = new Vector2(velocity.X * -1, velocity.Y); tempPos.X = 0; } else if (tempPos.X > mH.GetLevelSize().X - frame.Width - 0) { velocity = new Vector2(velocity.X * -1, velocity.Y); tempPos.X = mH.GetLevelSize().X - frame.Width - 0; } if (tempPos.Y <= 0) { velocity = new Vector2(velocity.X, velocity.Y * -1); tempPos.Y = 0; } else if (tempPos.Y > mH.GetLevelSize().Y - frame.Height - 0) { velocity = new Vector2(velocity.X, velocity.Y * -1); tempPos.Y = mH.GetLevelSize().Y - frame.Height - 0; } } position = tempPos; //Update frames frame.X = frameIndex * frame.Width; frame.Y = modeIndex * frame.Height; #endregion #region Finalize Direction foreach (Vector2 a in accelerations) { if (!float.IsNaN(a.X) && !float.IsNaN(a.Y)) { acceleration += a * mH.GetDeltaSeconds(); } } velocity += thrust * acceleration - drag * velocity; accelerations.Clear(); acceleration = Vector2.Zero; #endregion //Update position originPosition = position + origin; //Update frame if (frameIndex < 1) { frameIndex = 0; frameDirection = 1; } else if (frameIndex == totalFrames - 1) { frameIndex = totalFrames - 1; frameDirection = -1; } if (pulseTimer > pulseTime) { pulseTime /= 2; pulseTimer = 0; } if (frameTimer > pulseTime / (totalFrames * 2)) { frameTimer = 0; frameIndex += frameDirection; } if (modeIndex < 0) { modeIndex = 0; } else if (modeIndex >= totalModes) { modeIndex = totalModes; } frame.X = frameIndex * frame.Width; frame.Y = modeIndex * frame.Height; #endregion //Spawn cool things to make it look better EffectSpawnCode(mH); } existenceTime -= mH.GetGameTime().ElapsedGameTime.TotalSeconds; }
public override void Update(ManagerHelper mH) { foreach (NPC a in mH.GetNPCManager().GetNPCs()) { if (NPCManager.IsNPCInRadius(a, GetOriginPosition(), radius)) { if (!exploaded && a.GetAffiliation() != affiliation) { a.ChangeHealth(-1 * damage, creator); } //Make screen rumble if (a is Commander) { var tempCom = (Commander)a; mH.GetCameraManager().SetRumble(mH.GetCameraManager().GetPlayerIndex(tempCom), 1000); } } } foreach (LargeRock largeRock in mH.GetAbilityManager().GetLargeRocks()) { var test = PathHelper.DistanceSquared(GetOriginPosition(), largeRock.GetOriginPosition()); if (!exploaded && test < radius * radius) { largeRock.ChangeHealth(-1 * damage); } } frameIndex = (int)(existanceTime * 10); //Move particles from explosions foreach (Particle p in mH.GetParticleManager().GetParticles()) { float dir = PathHelper.Direction(GetOriginPosition(), p.GetOriginPosition()); p.AddAcceleration(PathHelper.Direction(dir) * 10000.0f / PathHelper.DistanceSquared(GetOriginPosition(), p.GetOriginPosition())); } foreach (Gut g in mH.GetParticleManager().GetGuts()) { float dir = PathHelper.Direction(GetOriginPosition(), g.GetOriginPosition()); g.AddAcceleration(PathHelper.Direction(dir) * 10000.0f / PathHelper.DistanceSquared(GetOriginPosition(), g.GetOriginPosition())); } Turn(MathHelper.Pi / 21); //Spawn Fires to make effect if (mH.GetRandom().NextDouble() < 0.25f) { mH.GetParticleManager() .AddFire(GetOriginPosition(), PathHelper.Direction((float)(mH.GetRandom().NextDouble() * Math.PI * 2)) * 500 * (float)mH.GetRandom().NextDouble(), 1, 0.01f, 1, 0.1f); for (int d = damage - 75; d >= 0; d -= 20) { mH.GetParticleManager() .AddFire(GetOriginPosition(), PathHelper.Direction((float)(mH.GetRandom().NextDouble() * MathHelper.TwoPi)) * 500 * (float)mH.GetRandom().NextDouble(), 1, 0.01f, 1, 0.1f); } } base.Update(mH); exploaded = true; }
public override void Update(ManagerHelper mH) { List <NPC.AffliationTypes> currentContestors = Controllers(mH); //Remove old suitors for (int i = 0; i < conquestCounters.Count; i++) { if (!currentContestors.Contains(conquestCounters.Keys.ElementAt(i))) { conquestCounters.Remove(conquestCounters.Keys.ElementAt(i)); i--; } } foreach (SpawnPoint sP in spawns) { if (affiliation != NPC.AffliationTypes.grey) { sP.affilation = affiliation; } else { sP.affilation = NPC.AffliationTypes.black; } } //Add new suitors foreach (NPC.AffliationTypes t in currentContestors) { if (!conquestCounters.ContainsKey(t)) { conquestCounters.Add(t, 0); } } if (conquestCounters.Count == 1) { if (!conquestCounters.Keys.Contains(affiliation)) { if (conquestCounters.Values.ElementAt(0) > conquestTime) { if (affiliation == NPC.AffliationTypes.grey) { affiliation = conquestCounters.Keys.First(); string smokeAsset = ""; //Set up image switch (affiliation) { case NPC.AffliationTypes.red: frameIndex = 1; smokeAsset = "Effects/smoke_red"; break; case NPC.AffliationTypes.blue: frameIndex = 2; smokeAsset = "Effects/smoke_blue"; break; case NPC.AffliationTypes.green: frameIndex = 3; smokeAsset = "Effects/smoke_green"; break; case NPC.AffliationTypes.yellow: frameIndex = 4; smokeAsset = "Effects/smoke_yellow"; break; } //Spawn Explosion mH.GetParticleManager().AddExplosion(GetOriginPosition(), affiliation, 0); for (int i = 0; i < NUM_SMOKES; i++) { mH.GetParticleManager().AddParticle(smokeAsset, GetOriginPosition(), PathHelper.Direction((float)(mH.GetRandom().NextDouble() * Math.PI * 2)) * 50, 1, 0.01f, 1, 0.05f); } } else { affiliation = NPC.AffliationTypes.grey; frameIndex = 0; conquestCounters.Clear(); //Spawn Explosion mH.GetParticleManager().AddExplosion(GetOriginPosition(), affiliation, 0); } } else { NPC.AffliationTypes tempConquestor = conquestCounters.Keys.ElementAt(0); Double tempTimer = conquestCounters.Values.ElementAt(0); conquestCounters.Remove(tempConquestor); conquestCounters.Add(tempConquestor, tempTimer + mH.GetGameTime().ElapsedGameTime.TotalSeconds); if (mH.GetRandom().NextDouble() < (tempTimer / conquestTime * 0.2f)) { mH.GetParticleManager() .AddFire(GetOriginPosition(), PathHelper.Direction((float)(mH.GetRandom().NextDouble() * Math.PI * 2)) * 50, 1, 0.01f, 1, 0.1f); } } } } base.Update(mH); }
private void Explode(ManagerHelper mH, NPC a) { mH.GetParticleManager().AddExplosion(GetOriginPosition(), a, 125); mH.GetNPCManager().Remove(this); }
public override void Update(ManagerHelper mH) { if (frameIndex < totalFrames) { frameIndex = (int)((float)frameCounter / drawFrames * totalFrames); //Spawn fire if (mH.GetRandom().NextDouble() < 0.3) { mH.GetParticleManager() .AddFire(GetOriginPosition(), PathHelper.Direction((float)(mH.GetRandom().NextDouble() * Math.PI * 2)) * 100, 1, 0.05f, 1, 0.1f); } if (mH.GetGametype() is Survival) { foreach (NPC a in mH.GetNPCManager().GetAllies(NPC.AffliationTypes.black)) { if (NPCManager.IsNPCInRadius(a, GetOriginPosition(), 64) && !doomedDots.Contains(a)) { doomedDots.Add(a); if (!a.GetFireStatus()) { a.ChangeFireStatus(); dotsSetOnFire.Add(a); } a.ChangeHealth(-30, mH.GetNPCManager().GetCommander(NPC.AffliationTypes.red)); } } } else { foreach (NPC a in mH.GetNPCManager().GetNPCs()) { if (a.GetAffiliation() != affiliation && NPCManager.IsNPCInRadius(a, GetOriginPosition(), 64) && !doomedDots.Contains(a)) { doomedDots.Add(a); if (!a.GetFireStatus()) { a.ChangeFireStatus(); dotsSetOnFire.Add(a); } a.ChangeHealth(-70, mH.GetNPCManager().GetCommander(NPC.AffliationTypes.red)); } } } } //Deal Damage for (int i = 0; i < doomedDots.Count; i++) { NPC a = doomedDots[i]; if (!mH.GetNPCManager().GetNPCs().Contains(a)) { doomedDots.Remove(a); i--; continue; } //Spawn fire if (mH.GetRandom().NextDouble() < 0.1f) { mH.GetParticleManager() .AddFire(a.GetOriginPosition(), PathHelper.Direction((float)(mH.GetRandom().NextDouble() * Math.PI * 2)) * 30, 1, 0.05f, 1, 0.1f); } if (frameCounter % burnFrames == 0) { a.ChangeHealth(-2, mH.GetNPCManager().GetCommander(NPC.AffliationTypes.red)); } } frameCounter++; this.scale = scale * modifer; base.Update(mH); }