protected override void NewPath(ManagerHelper mH) { List <Vector2> sniperSpots = mH.GetLevel().GetSniperSpots(); Vector2 endPoint = GetOriginPosition(); foreach (Vector2 v in sniperSpots) { bool validPoint = true; foreach (NPC agent in mH.GetNPCManager().GetNPCs()) { if (agent.GetAffiliation() != affiliation && NPCManager.IsNPCInRadius(agent, GetOriginPosition(), 200)) { validPoint = false; break; } } if (validPoint) { endPoint = v; break; } } mH.GetPathHelper().FindClearPath(GetOriginPosition(), endPoint, mH, path); }
public Vector2 SpawnSucideDots() { int spawnPick; bool proceed = false; int counter = 0; do { spawnPick = managers.GetRandom().Next(0, suicideSpawnPoints.Count); counter++; List <NPC> suicides = managers.GetNPCManager().GetAllies(NPC.AffliationTypes.black); int suicideCount = 0; foreach (NPC suicide in suicides) { if (NPCManager.IsNPCInRadius(suicide, suicideSpawnPoints[spawnPick].GetOriginPosition(), 60)) { suicideCount++; } if (suicideCount >= 1) { break; } } if (suicideCount < 1) { proceed = true; } } while (!proceed && counter < 240); return(suicideSpawnPoints[spawnPick].GetOriginPosition()); }
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; } } }
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 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); }
protected virtual NPC TargetDecider(ManagerHelper mH) { if (mH.GetGametype() is Survival) { NPC closest = null; float closestDistance = float.PositiveInfinity; foreach (var suicide in mH.GetNPCManager().GetAllies(NPC.AffliationTypes.black)) { if (NPCManager.IsNPCInRadius(suicide, GetOriginPosition(), sight) && NPCManager.IsNPCInDirection(suicide, GetOriginPosition(), rotation, vision, mH)) { float distanceToSuicide = PathHelper.DistanceSquared(GetOriginPosition(), suicide.GetOriginPosition()); if (distanceToSuicide < closestDistance) { closestDistance = distanceToSuicide; closest = suicide; } } } return(closest); } else { NPC closest = null; float closestDistance = float.PositiveInfinity; foreach (var agent in mH.GetNPCManager().GetNPCs()) { if (agent.GetAffiliation() != affiliation && NPCManager.IsNPCInRadius(agent, GetOriginPosition(), sight) && NPCManager.IsNPCInDirection(agent, GetOriginPosition(), rotation, vision, mH)) { float distanceToAgent = PathHelper.DistanceSquared(GetOriginPosition(), agent.GetOriginPosition()); if (distanceToAgent < closestDistance) { closestDistance = distanceToAgent; closest = agent; } } } return(closest); } }
private void Pulse(ManagerHelper mH) { foreach (NPC a in mH.GetNPCManager().GetNPCs()) { if (NPCManager.IsNPCInRadius(a, GetOriginPosition(), 200)) { float dir = PathHelper.Direction(GetOriginPosition(), a.GetOriginPosition()); a.AddAcceleration(PathHelper.Direction(dir) * 15); if (a is Commander) { var tempCom = (Commander)a; mH.GetCameraManager().SetRumble(mH.GetCameraManager().GetPlayerIndex(tempCom), 512); } } } }
public override bool ShouldUsePower(ManagerHelper mH) { if (mH.GetGametype() is Survival) { if (target != null && PathHelper.DistanceSquared(target.GetOriginPosition(), GetOriginPosition()) < 200 * 200) { return(true); } } else { if (GetPercentHealth() < .5) { return(true); } foreach (NPC ally in mH.GetNPCManager().GetAllies(affiliation)) { if (NPCManager.IsNPCInRadius(ally, GetOriginPosition(), 200) && ally.GetHealth() < (ally.GetMaxHealth() / 2)) { return(true); } } //Check for number of enemies int enemyCount = 0; foreach (var agent in mH.GetNPCManager().GetNPCs()) { if (agent.GetAffiliation() != affiliation && NPCManager.IsNPCInRadius(agent, GetOriginPosition(), 200)) { enemyCount++; } } if (enemyCount > 3) { return(true); } } return(base.ShouldUsePower(mH)); }
protected bool GrenadeDecider(ManagerHelper mH) { int enemyCount = 0; foreach (var enemy in mH.GetNPCManager().GetAllies(target.affiliation)) { if (NPCManager.IsNPCInRadius(enemy, target.GetOriginPosition(), 100)) { enemyCount++; } } if (enemyCount > 2) { return(true); } return(false); }
public override bool ShouldUsePower(ManagerHelper mH) { if (!mH.GetAbilityManager().HasReachedLargeRockCap()) { if (mH.GetGametype() is Survival) { if (target != null && PathHelper.DistanceSquared(target.GetOriginPosition(), GetOriginPosition()) < 200 * 200) { return(true); } } else { if (GetPercentHealth() < .5 && lastDamagerDirection != Vector2.Zero) { return(true); } int enemyCount = 0; foreach (var agent in mH.GetNPCManager().GetNPCs()) { if (agent.GetAffiliation() != affiliation && NPCManager.IsNPCInRadius(agent, GetOriginPosition(), 200)) { enemyCount++; } } if (enemyCount > 3) { return(true); } } } return(base.ShouldUsePower(mH)); }
protected override NPC TargetDecider(ManagerHelper mH) { NPC bestEnemy = null; float bestDistance = float.PositiveInfinity; foreach (var agent in mH.GetNPCManager().GetNPCs()) { if (agent.GetAffiliation() != affiliation && NPCManager.IsNPCInRadius(agent, GetOriginPosition(), sight) && NPCManager.IsNPCInDirection(agent, GetOriginPosition(), rotation, vision, mH)) { float distanceToEnemy = PathHelper.DistanceSquared(GetOriginPosition(), agent.GetOriginPosition()); if (distanceToEnemy < bestDistance) { bestDistance = distanceToEnemy; bestEnemy = agent; } } } return(bestEnemy); }
public void FindEscapePath(Vector2 pA, Vector2 pGTFA, float mD, ManagerHelper mH, float aw, Path path) { //Add blockers for enemies foreach (NPC n in mH.GetNPCManager().GetAllies(NPC.AffliationTypes.black)) { if (NPCManager.IsNPCInRadius(n, pA, aw)) { int x = -1; int y = -1; for (int adjX = -32; adjX < 32; adjX += 32) { for (int adjY = -32; adjY < 32; adjY += 32) { x = (int)(n.GetOriginPosition().X / nodeSize.X) + adjX; y = (int)(n.GetOriginPosition().Y / nodeSize.Y); if ((y > 0 && y < mH.GetLevel().GetSizeOfLevel().Y) && (x > 0 && y < mH.GetLevel().GetSizeOfLevel().X)) { field[x, y].SetBlocker(true); } } } } } float farthest = 0; float convenience = mD * mD; //forces dot to go to furtherest location that is easiest to get to Vector2 pointB = pA; int nodeX, nodeY; //Find best end point for (int x = (int)(pA.X - mD) / 32; x < (pA.X + mD); x += 32) { if (x > 32 && x < mH.GetLevel().GetSizeOfLevel().X) { for (var y = (int)(pA.Y - mD); y < (pA.Y + mD); y += 32) { if (y > 0 && y < mH.GetLevel().GetSizeOfLevel().Y - 32) { nodeX = x / 32; nodeY = y / 32; if (!field[nodeX, nodeY].GetBlocker()) { var currentPoint = new Vector2(x, y); float dist = DistanceSquared(pGTFA, currentPoint); float tempCon = DistanceSquared(pA, currentPoint); if (convenience > tempCon && dist > farthest) { farthest = dist; convenience = tempCon; pointB = currentPoint; } } } } } } FindClearPath(pA, pointB, mH, path); }
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; }
protected bool ShouldUseMine(ManagerHelper mH) { if (mH.GetGametype() is CaptureTheFlag) { CaptureTheFlag tempGametype = (CaptureTheFlag)mH.GetGametype(); if (tempGametype.GetEnemyBase(affiliation).GetMyFlag().GetCaptor() == this) { return(true); } } else if (mH.GetGametype() is Assault) { Assault tempGametype = (Assault)mH.GetGametype(); if (tempGametype.GetAttacker() == affiliation && tempGametype.GetEnemyBase(affiliation).GetMyFlag().GetCaptor() == this) { return(true); } } else if (mH.GetGametype() is Conquest) { Conquest tempGametype = (Conquest)mH.GetGametype(); foreach (ConquestBase point in tempGametype.GetBases()) { if (point.affiliation != affiliation && PathHelper.DistanceSquared(GetOriginPosition(), point.GetOriginPosition()) < awareness * awareness) { return(true); } } } else if (mH.GetGametype() is Deathmatch) { Deathmatch tempGametype = (Deathmatch)mH.GetGametype(); foreach (Claimable claimable in tempGametype.GetClaimables()) { if (PathHelper.DistanceSquared(GetOriginPosition(), claimable.GetOriginPosition()) < awareness * awareness) { return(true); } } } //Default int numEnemies = 0; foreach (NPC agent in mH.GetNPCManager().GetNPCs()) { if (agent.GetAffiliation() != affiliation && NPCManager.IsNPCInRadius(agent, GetOriginPosition(), awareness)) { numEnemies++; } } return(numEnemies > 2); }
public override bool ShouldUsePower(ManagerHelper mH) { if (CurrentPower() < .5 * MaxPower()) { return(false); } if (mH.GetGametype() is Assault) { var temp = (Assault)mH.GetGametype(); Flag f = temp.GetAllyBase(temp.GetDefender()).GetMyFlag(); if (temp.GetAttacker() == affiliation) { if (f.status != Flag.FlagStatus.taken) { return(PathHelper.DistanceSquared(GetOriginPosition(), f.GetOriginPosition()) < 300 * 300); } else { return(f.GetCaptor() is YellowCommander); } } else { return(f.status != Flag.FlagStatus.home); } } else if (mH.GetGametype() is CaptureTheFlag) { var temp = (CaptureTheFlag)mH.GetGametype(); Flag eF = temp.GetEnemyBase(affiliation).GetMyFlag(); if (eF.status != Flag.FlagStatus.taken) { return(PathHelper.DistanceSquared(GetOriginPosition(), eF.GetOriginPosition()) < 240 * 240); } else if (eF.GetCaptor() != null) { return(eF.GetCaptor() is YellowCommander); } } else if (mH.GetGametype() is Survival) { return((target != null) && (PathHelper.DistanceSquared(GetOriginPosition(), target.GetOriginPosition()) < 200 * 200)); } else { int enemyCount = 0; foreach (var agent in mH.GetNPCManager().GetNPCs()) { if (agent.GetAffiliation() != affiliation && NPCManager.IsNPCInRadius(agent, GetOriginPosition(), 120)) { enemyCount++; } } return(enemyCount > 1); } return(false); }
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); }