public override void Update(ManagerHelper mH) { if (nextPulseCounter >= nextPulseSpeed) { if (pulseCounter < pulseLength) { Pulse(mH); AnimatePulse(mH); pulseCounter += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } else { pulseCounter = 0; nextPulseCounter = 0; //Reset pulse pulse.SetFrameIndex(0); pulse.SetModeIndex(0); } } else { nextPulseCounter += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } Animate(mH); base.Update(mH); pulse.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; }
protected override void Behavior(ManagerHelper mH) { target = TargetDecider(mH); if (target != null) { if (!(GrenadeDecider(mH) && grenadeCounter > grenadeSpeed) && shootingCounter > shootingSpeed) { shootingCounter = 0; Shoot(mH); } else { shootingCounter += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } if (GrenadeDecider(mH) && grenadeCounter > grenadeSpeed) { grenadeCounter = 0; TossGrenade(mH); } else { grenadeCounter += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } } }
public override void Update(ManagerHelper mH) { base.Update(mH); if (calledIn < 1) { if (radioWave.GetFrameIndex() < 4 && radioTimerCounter > radioTimer) { radioTimerCounter = 0; radioWave.SetFrameIndex(radioWave.GetFrameIndex() + 1); } else if (radioTimerCounter > radioTimer) { radioWave.SetFrameIndex(0); radioTimerCounter = 0; } else { radioTimerCounter += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } radioWave.position = this.position; radioWave.origin = this.origin; radioWave.SetRotation(this.GetRotation()); radioWave.Update(mH); calledIn += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } }
public override void Update(ManagerHelper mH) { //if black dont work if (affilation == NPC.AffliationTypes.black) { spawnTime = 10000; spawnCounter = 0; } else if (isOneUse && !isUsed) { spawnTime = 8; NPCManager temp = mH.GetNPCManager(); if (spawnCounter > spawnTime) { isGoodSpawnPoint = true; foreach (var agent in mH.GetNPCManager().GetNPCs()) { if (agent.GetAffiliation() != affiliation && NPCManager.IsNPCInRadius(agent, spawnPoint, 100)) { isGoodSpawnPoint = false; } } } else { spawnCounter += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } } else if (!isUsed) { spawnTime = 8; NPCManager temp = mH.GetNPCManager(); if (spawnCounter > spawnTime) { isGoodSpawnPoint = true; foreach (var agent in mH.GetNPCManager().GetNPCs()) { if (agent.GetAffiliation() != affiliation && NPCManager.IsNPCInRadius(agent, spawnPoint, 100)) { isGoodSpawnPoint = false; } } } else { spawnCounter += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } } }
public override void Update(ManagerHelper mH) { if (drawTime > 0) { Turn(rotationAmount); drawTime -= mH.GetGameTime().ElapsedGameTime.TotalSeconds; base.Update(mH); } existanceTime -= mH.GetGameTime().ElapsedGameTime.TotalSeconds; }
protected override void Behavior(ManagerHelper mH) { //am i threatened? threatened = false; foreach (NPC agent in mH.GetNPCManager().GetNPCs()) { if (agent.GetAffiliation() != affiliation && NPCManager.IsNPCInRadius(agent, GetOriginPosition(), awareness)) { threatened = true; } } //also temp threatened = threatened || campingCounter >= campingEnd; target = TargetDecider(mH); if (threatened) { NewPath(mH); campingCounter = 0; } if (!path.GetMoving()) { //If nothing to shoot at, turn around if (target == null) { Turn(TURN_AMOUNT); campingCounter += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } else { if (shootingCounter > shootingSpeed) { shootingCounter = 0; Shoot(mH); } else { shootingCounter += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } } } else if (path.Count == 0) { path.SetMoving(false); campingCounter = 0; } }
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) { if (nextPulseCounter >= nextPulseSpeed) { if (pulseCounter < pulseLength) { Pulse(mH); AnimatePulse(mH); pulseCounter += mH.GetGameTime().ElapsedGameTime.TotalSeconds; for (int i = 0; i < affectedNPCList.Count; i++) { if (PathHelper.Distance(this.GetOriginPosition(), affectedNPCList[i].GetOriginPosition()) > 200) { affectedNPCList[i].speed = new Vector2(affectedNPCList[i].movementSpeed); affectedNPCList[i].path = affectedNPCList[i].NewPath(mH); affectedNPCList.Remove(affectedNPCList[i]); i--; } } } else { foreach (NPC a in affectedNPCList) { a.speed = new Vector2(a.movementSpeed); a.path = a.NewPath(mH); } affectedNPCList.Clear(); pulseCounter = 0; nextPulseCounter = 0; } } else { nextPulseCounter += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } Animate(mH); base.Update(mH); pulse.Update(mH); }
//This method will be used to dictate the AI's behavior in this public class public override void Update(ManagerHelper mH) { base.Update(mH); if (indicator != null) { //Animation of indicator if (timer > endtime) { indicator.SetFrameIndex(indicator.GetFrameIndex() + 1); if (indicator.GetFrameIndex() > 5) { indicator.SetFrameIndex(0); } timer = 0; } else { timer += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } indicator.position = new Vector2(position.X - origin.X, position.Y - origin.Y); indicator.Update(mH); } }
public override void Update(ManagerHelper mH) { if (animate) { if (animationTimer > animationEnd) { frameIndex++; animationTimer = 0; if (frameIndex >= totalFrames) { frameIndex = 0; animate = false; } } else { animationTimer += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } } else { animate = mH.GetRandom().Next(300) == 0; } base.Update(mH); }
private void Animate(ManagerHelper mH) { if (animateCounter < .25) { animateCounter += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } else if (upDown && frameIndex < 7) { animateCounter = 0; frameIndex++; } else if (!upDown && frameIndex > 0) { animateCounter = 0; frameIndex--; } else if (frameIndex == 7) { upDown = false; } else if (frameIndex == 0) { upDown = true; } }
public override void Update(ManagerHelper mH) { frameIndex = mH.GetRandom().Next(totalFrames); if (mH.GetGametype() is Survival) { foreach (NPC a in mH.GetNPCManager().GetAllies(NPC.AffliationTypes.black)) { if (CollisionHelper.IntersectPixelsDirectional(a, this) != -1) { a.ChangeHealth(-1, mH.GetNPCManager().GetCommander(NPC.AffliationTypes.yellow)); } } } else { foreach (NPC a in mH.GetNPCManager().GetNPCs()) { if (a.GetAffiliation() != affiliation && CollisionHelper.IntersectPixelsPoint(GetOriginPosition(), a) != new Vector2(-1)) { a.ChangeHealth(-1, mH.GetNPCManager().GetCommander(NPC.AffliationTypes.yellow)); } } } lifeTimer -= mH.GetGameTime().ElapsedGameTime.TotalSeconds; base.Update(mH); }
private void Spawn(ManagerHelper mH) { allies = mH.GetNPCManager().GetAllies(affiliation); int aT = mH.GetRandom().Next(3, 6); var ass = (Assault)mH.GetGametype(); if (spawnCounter > spawnTime && allies.Count < mH.GetGametype().GetPopCap()) { if (aT != 3 && aT != 6) { if (affiliation == ass.GetAttacker()) { aT = 5; } else { aT = 4; } } mH.GetGametype().Spawn(mH, affiliation, mH.GetSpawnHelper().Spawn(affiliation), aT); spawnCounter = 0; } else { spawnCounter += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } }
public override void Update(ManagerHelper mH) { base.Update(mH); if (shouldUsePower && CurrentPower() > abilityUse) { if (abilityTimer < abilityTime) { abilityTimer += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } else { abilityTimer = 0; mH.GetAbilityManager().AddLightning(position, PathHelper.Direction(velocity), affiliation); base.UsePower(mH); } } else { abilityTimer = abilityTime; shouldUsePower = false; movementSpeed = abilityOffSpeed; } }
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); }
protected void UpdateProtection(ManagerHelper mH) { if (protectedTimer > 0) { protectedTimer -= mH.GetGameTime().ElapsedGameTime.TotalSeconds; } }
public override void Update(ManagerHelper mH) { if (lifeCounter < 0) { mH.GetEnvironmentManager().RemoveStaticBlocker(this); } lifeCounter -= mH.GetGameTime().ElapsedGameTime.TotalSeconds; //Code for getting picked up if (theCrane.movementPhase == Crane.MovementPhaseType.picking) { //Get picked up if (theCrane.myBox == null && CollisionHelper.IntersectPixelsPoint(theCrane.GetCranePoint(), this) != new Vector2(-1)) { theCrane.myBox = this; } } else if (theCrane.movementPhase == Crane.MovementPhaseType.dropping) { theCrane.myBox = null; } //Movement if (theCrane.myBox == this) { position = theCrane.GetCranePoint() - origin; rotation = theCrane.GetRotation(); } else { for (int i = 0; i < theNet.boxNodes.Length; i++) { if (lastNode != theNet.boxNodes[i] && PathHelper.DistanceSquared(GetOriginPosition(), theNet.boxNodes[i].pos) < 4 * 4) { lastNode = theNet.boxNodes[i]; velocity = theNet.boxNodes[i].GetRandomDir(mH) * 15; position = theNet.boxNodes[i].pos - origin; break; } } if (velocity == Vector2.Zero) { mH.GetEnvironmentManager().RemoveStaticBlocker(this); } rotation = PathHelper.Direction(velocity); } if (this.health < 0) { } base.Update(mH); }
public override void Update(ManagerHelper mH) { Queue <Projectile> tempProjectiles = mH.GetProjectileManager().GetProjectiles(); foreach (Projectile p in tempProjectiles) { if (p.GetDrawTime() > 0 && CollisionHelper.IntersectPixelsPoint(p.GetOriginPosition(), this) != new Vector2(-1)) { health -= p.GetDamage(); lastDamager = p.GetCreator(); p.SetDrawTime(0); } } if (timer < animateTime) { frameIndex = (int)(timer / animateTime * 12); float frameModifier = ((frameIndex + 1) * 6); if (mH.GetGametype() is Survival) { foreach (NPC a in mH.GetNPCManager().GetAllies(NPC.AffliationTypes.black)) { float distanceToAgent = PathHelper.DistanceSquared(GetOriginPosition(), a.GetOriginPosition()); if (distanceToAgent < frameModifier * frameModifier) { a.AddAcceleration(PathHelper.DirectionVector(GetOriginPosition(), a.GetOriginPosition()) * 10); a.ChangeHealth(-1 * DAMAGE, mH.GetNPCManager().GetCommander(NPC.AffliationTypes.green)); } } } else { foreach (NPC a in mH.GetNPCManager().GetNPCs()) { if (a.GetAffiliation() != affiliation) { var distanceToAgent = PathHelper.DistanceSquared(GetOriginPosition(), a.GetOriginPosition()); if (distanceToAgent < frameModifier * frameModifier) { a.AddAcceleration(PathHelper.DirectionVector(GetOriginPosition(), a.GetOriginPosition()) * 10); a.ChangeHealth(-1 * DAMAGE, mH.GetNPCManager().GetCommander(NPC.AffliationTypes.green)); } } } } timer += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } 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); }
public override bool Update(ManagerHelper mH) { if (GetIfAllPlayersAreDead(mH) && redCommanderHasSpawned) { gameEndTimer = -1; } if ((int)gameEndTimer % 30 == 0) { if (!hasAppliedModifier) { survivalPointModifier++; suicideSpawnModifier++; UpdateScoreSurvival(mH); hasAppliedModifier = true; } } else { hasAppliedModifier = false; } #region Spawns if (mH.GetNPCManager().GetAllies(NPC.AffliationTypes.black).Count <= NUM_SUICIDES && counter > spawnSecs) { mH.GetNPCManager().Add(new Suicide(mH.GetSpawnHelper().SpawnSucideDots(), mH)); counter = 0; spawnSecs -= mH.GetGameTime().ElapsedGameTime.TotalSeconds; } //Update spent time counter += mH.GetGameTime().ElapsedGameTime.TotalSeconds; #endregion foreach (Claimable c in claimables) { c.Update(mH); } return(base.Update(mH)); }
public virtual bool Update(ManagerHelper mH) { #region Spawning Commanders int counter = 0; foreach (var commander in commanders) { if (mH.GetNPCManager().GetCommander(commander.Key) == null) { if (spawnsCounters[counter] > spawnTime) { SpawnCommander(mH, commander.Key, commander.Value, mH.GetSpawnHelper().Spawn(commander.Value)); spawnsCounters[counter] = 0; } else { spawnsCounters[counter] += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } } counter++; } #endregion if (winScore != -1) { if (GetWinner() != NPC.AffliationTypes.same) { return(true); } } if (gameEndTimer < 0) { return(true); } gameEndTimer -= mH.GetGameTime().ElapsedGameTime.TotalSeconds; return(false); }
protected virtual void Behavior(ManagerHelper mH) { target = TargetDecider(mH); if (shootingCounter > shootingSpeed && target != null) { shootingCounter = 0; Shoot(mH); } else { shootingCounter += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } }
public override void Update(ManagerHelper mH) { if (movementPhase == MovementPhaseType.picking || movementPhase == MovementPhaseType.dropping) { if (timer > endTime) { timer = 0; if (mH.GetRandom().NextDouble() > 0.5f) { movementPhase = MovementPhaseType.turningLeft; } else { movementPhase = MovementPhaseType.turningRight; } do { endRotation = (float)(Math.PI * mH.GetRandom().Next(4) / 2); } while (endRotation == rotation); } else { timer += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } } else { if (MathHelper.Distance(rotation, endRotation) > 0.01) { Turn(((movementPhase == MovementPhaseType.turningLeft) ? -1.0f : 1.0f) * MathHelper.Pi / 240.0f); } else { rotation = endRotation; if (myBox == null) { movementPhase = MovementPhaseType.picking; } else { movementPhase = MovementPhaseType.dropping; } } } base.Update(mH); }
public override void Update(ManagerHelper mH) { if (timer > endTime) { timer = 0; for (int i = 0; i < belts.Length; i++) { belts[i].SetFrameIndex(belts[i].GetFrameIndex() + 1); belts[i].SetModeIndex(belts[i].GetModeIndex() + 1); if (belts[i].GetFrameIndex() == belts[i].totalFrames) { belts[i].SetFrameIndex(0); } if (belts[i].GetModeIndex() == belts[i].totalModes) { belts[i].SetModeIndex(0); } foreach (NPC a in mH.GetNPCManager().GetNPCs()) { int tempCollide = CollisionHelper.IntersectPixelsDirectional(a, belts[i]); if (tempCollide != -1) { a.AddAcceleration(directions[i] * 2); } } belts[i].Update(mH); } if (mH.GetRandom().NextDouble() > 0.993) { mH.GetEnvironmentManager() .AddStaticBlocker(new SwitchBox(boxNodes[(mH.GetRandom().Next(2) == 0) ? 0 : 11].pos, this, theCrane)); } } else { timer += (mH.GetGameTime().ElapsedGameTime.TotalSeconds); } }
private void Spawn(ManagerHelper mH) { allies = mH.GetNPCManager().GetAllies(affiliation); if (spawnCounter > spawnTime && allies.Count < mH.GetGametype().GetPopCap()) { mH.GetGametype() .Spawn(mH, affiliation, mH.GetSpawnHelper().Spawn(affiliation), mH.GetRandom().Next(6, 9)); spawnCounter = 0; } else { spawnCounter += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } }
private float MoveNPC(ManagerHelper mH, float dir) { //If path is null, ie stay in same spot if (path.GetMoving()) { //If there are still destinations if (pathTimer >= pathTimerEnd || path.Count == 0) { NewPath(mH); pathTimer = 0; } else { Vector2 next = path.Last(); //Get next destination dir = PathHelper.Direction(base.GetOriginPosition(), next); //Find angle between points accelerations.Add(PathHelper.Direction(dir)); //Get x and y values from angle and set up direction //If already there... if (PathHelper.DistanceSquared(next, GetOriginPosition()) < 15 * 15) { //path.RemoveFirst(); //Go on to next destination path.RemoveAt(path.Count - 1); } pathTimer += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } } //Finalize direction foreach (Vector2 a in accelerations) { if (!float.IsNaN(a.X) && !float.IsNaN(a.Y)) { acceleration += a; } } drag = 0.05f; thrust = movementSpeed * drag; velocity += thrust * acceleration - drag * velocity; accelerations.Clear(); acceleration = Vector2.Zero; return(dir); }
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) { base.Update(mH); if (shouldUsePower && CurrentPower() > abilityUse) { if (abilityTimer > abilityTime) { movementSpeed = abilitySpeed; mH.GetAbilityManager().AddLightning(position, PathHelper.Direction(velocity), affiliation); base.UsePower(mH); abilityTimer = 0; } } else { shouldUsePower = false; movementSpeed = abilityOffSpeed; if (CurrentPower() > MaxPower() * .3) { abilityTimer = abilityTime; } else { abilityTimer = 0; } } if (CurrentPower() < bottom) { ranOut = true; } if (ranOut && CurrentPower() > waitCharge) { ranOut = false; } abilityTimer += mH.GetGameTime().ElapsedGameTime.TotalSeconds; }
private void animateEffects(ManagerHelper mH) { //animation of spawn sprite if (spriteTimer > spriteEndtime) { suicideSpawnSprite.SetFrameIndex(suicideSpawnSprite.GetFrameIndex() + 1); if (suicideSpawnSprite.GetFrameIndex() > 10) { suicideSpawnSprite.SetFrameIndex(0); } spriteTimer = 0; } else { spriteTimer += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } suicideSpawnSprite.position = new Vector2(position.X - origin.X, position.Y - origin.Y); suicideSpawnSprite.Update(mH); }