public NPC GetClosestInList(List <NPC> aL, NPC n) { Vector2 p = n.GetOriginPosition(); if (aL.Count > 0) { NPC closest = null; var minDist = float.PositiveInfinity; foreach (NPC a in aL) { if (a != n) { var aDist = PathHelper.DistanceSquared(p, a.GetOriginPosition()); if (aDist < minDist) { closest = a; minDist = aDist; } } } return(closest); } return(null); }
protected override void NewPath(ManagerHelper mH) { NPC tempEnemy = null; float shortestDistance = float.PositiveInfinity; foreach (var agent in mH.GetNPCManager().GetNPCs()) { if (agent.GetAffiliation() != affiliation) { float distanceToAgent = PathHelper.DistanceSquared(GetOriginPosition(), agent.GetOriginPosition()); if (distanceToAgent < shortestDistance) { shortestDistance = distanceToAgent; tempEnemy = agent; } } } Vector2 closetRockPosition = FindClosestRock(mH); if (closetRockPosition != new Vector2(-1, -1)) { mH.GetPathHelper().FindClearPath(GetOriginPosition(), closetRockPosition, mH, path); } else if (tempEnemy != null) { mH.GetPathHelper().FindClearPath(GetOriginPosition(), tempEnemy.GetOriginPosition(), mH, path); } else { RandomPath(mH); } }
protected override NPC TargetDecider(ManagerHelper mH) { NPC closest = null; float closestDistance = float.PositiveInfinity; foreach (var affliationType in mH.GetGametype().GetTeams()) { if (affliationType != affiliation) { NPC closestForTeam = mH.GetNPCManager().GetClosestInList(mH.GetNPCManager().GetAllies(affliationType), this); if (closestForTeam != null) { float closestDistanceForTeam = PathHelper.DistanceSquared(GetOriginPosition(), closestForTeam.GetOriginPosition()); if (closestDistanceForTeam < closestDistance) { closest = closestForTeam; closestDistance = closestDistanceForTeam; } } } } return(closest); }
public Claimable GetClosestClaimable(Vector2 p) { if (claimables.Count > 0) { Claimable closest = null; float minDist = float.PositiveInfinity; foreach (Claimable a in claimables) { if (!a.taken) { float aDist = PathHelper.DistanceSquared(p, a.GetOriginPosition()); if (aDist < minDist) { closest = a; minDist = aDist; } } } return(closest); } return(null); }
//This method will be used to dictate the AI's behavior in this public class public override void Update(ManagerHelper mH) { double distanceToTarget = PathHelper.DistanceSquared(GetOriginPosition(), targetPosition); if (distanceToTarget < 300 * 300 && !hasBombed) { Bomb(mH); hasBombed = true; } if (distanceToTarget < 50 * 50) { drawTarget = false; } //remove thyself if (position.X < -200 || position.X > mH.GetLevelSize().X + 200 || position.Y < -200 || position.Y > mH.GetLevelSize().Y + 200) { mH.GetNPCManager().Remove(this); } var newTargetSpriteIndex = (int) (targetSprite.GetTotalFrames() * Math.Max(0, Math.Min(1000 * 1000, 1000 * 1000 - PathHelper.DistanceSquared(GetOriginPosition(), targetPosition))) / 1000 * 1000); targetSprite.SetFrameIndex(newTargetSpriteIndex); SpriteUpdate(mH); targetSprite.Update(mH); }
public Claimable GetClosestClaimable(Vector2 p, ManagerHelper mH) { if (claimables.Count > 0) { Claimable closest = claimables.First(); float minDist = PathHelper.DistanceSquared(p, closest.GetOriginPosition()); foreach (Claimable a in claimables) { if (!a.taken) { float aDist = PathHelper.DistanceSquared(p, a.GetOriginPosition()); if (aDist < minDist) { closest = a; minDist = aDist; } } } if (closest.taken) { return(null); } else { return(closest); } } return(null); }
public override bool ShouldUsePower(ManagerHelper mH) { if (target != null && PathHelper.DistanceSquared(target.GetOriginPosition(), GetOriginPosition()) < 50 * 50) { return(true); } return(false); }
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); }
public void Add(Vector2 p, ManagerHelper mH) { base.Add(p); //AddFirst(p); if (Count > 1) { distance += PathHelper.DistanceSquared(base[Count - 1], base[Count - 2]); //distance += PathHelper.Distance(base.First.Value, base.First.Next.Value); } SetMoving(true); }
public static Vector2 IntersectPixelsRadius(Sprite sA, Sprite sB, float rA, float rB) { float dist = PathHelper.DistanceSquared(sA.GetOriginPosition(), sB.GetOriginPosition()); if (dist < (rA * rA + rB * rB)) { return(sB.GetOriginPosition()); } else { return(new Vector2(-1)); } }
protected override void Behavior(ManagerHelper mH) { target = TargetDecider(mH); //TODO: Make this compatable with NPC death code if (target != null && CollisionHelper.IntersectPixelsRadius(this, target, 24, 24) != new Vector2(-1)) { Explode(mH); } else if (PathHelper.DistanceSquared(this.GetOriginPosition(), FindClosestRock(mH)) < 48 * 48) { Explode(mH); } }
protected override void SpecialPath(ManagerHelper mH) { //do i have friends NPC friend = mH.GetNPCManager().GetClosestInList(mH.GetNPCManager().GetAllies(affiliation), this); if (friend != null) { float closestDistancetoTarget = float.PositiveInfinity; target = null; foreach (var team in mH.GetGametype().GetTeams()) { if (team != affiliation) { NPC closestTargetForTeam = mH.GetNPCManager() .GetClosestInList(mH.GetNPCManager().GetAllies(team), friend.GetOriginPosition()); if (closestTargetForTeam != null) { float closestDiestanceToTargetForTeam = PathHelper.DistanceSquared( closestTargetForTeam.GetOriginPosition(), friend.GetOriginPosition()); if (closestDiestanceToTargetForTeam < closestDistancetoTarget) { target = closestTargetForTeam; closestDistancetoTarget = closestDiestanceToTargetForTeam; } } } } } Vector2 destination; //if so if (friend != null && target != null) { //we can now get a midpoint destination = PathHelper.MidPoint(friend.GetOriginPosition(), target.GetOriginPosition()); //and wedge ourselves in mH.GetPathHelper().FindClearPath(GetOriginPosition(), destination, mH, path); } //else, we shall wander the planes between heaven and hell else { RandomPath(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); } }
protected void EngagePath(ManagerHelper mH) { NPC tempEnemy; if (mH.GetGametype() is Survival) { tempEnemy = target ?? mH.GetNPCManager() .GetClosestInList(mH.GetNPCManager().GetAllies(AffliationTypes.black), this); } else { NPC tempClosestEnemy = null; float tempClosestDistance = float.PositiveInfinity; foreach (var agent in mH.GetNPCManager().GetNPCs()) { if (agent.GetAffiliation() != affiliation) { float distaceToEnemy = PathHelper.DistanceSquared(GetOriginPosition(), agent.GetOriginPosition()); if (distaceToEnemy < tempClosestDistance) { tempClosestDistance = distaceToEnemy; tempClosestEnemy = agent; } } } tempEnemy = target != null ? target : tempClosestEnemy; } if (tempEnemy != null) { if (PathHelper.DistanceSquared(GetOriginPosition(), tempEnemy.GetOriginPosition()) > 128 * 128) { mH.GetPathHelper().FindClearPath(GetOriginPosition(), tempEnemy.GetOriginPosition(), mH, path); } else { HoverPath(mH, GetOriginPosition(), 64); } } else { RandomPath(mH); } }
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); }
private Vector2 FindClosestRock(ManagerHelper mH) { float closestDistance = float.PositiveInfinity; float distance; LargeRock closestRock = null; foreach (LargeRock rock in mH.GetAbilityManager().GetLargeRocks()) { distance = PathHelper.DistanceSquared(rock.GetOriginPosition(), this.GetOriginPosition()); if (distance < closestDistance && rock.IsFullyUp()) { closestDistance = distance; closestRock = rock; } } return(closestRock != null ? closestRock.GetOriginPosition() : new Vector2(-1, -1)); }
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 ConquestBase GetForwardBase(NPC.AffliationTypes a, ManagerHelper mH) { ConquestBase fb = null; if (GetNumAlliedBases(a) != 0 && GetNumAlliedBases(a) != winScore) { ConquestBase closestToFB = null; float distanceToClosestToFB = float.PositiveInfinity; foreach (ConquestBase b in GetBases()) { if (b.affiliation == a) { ConquestBase closestToB = null; float distanceToClosestToB = float.PositiveInfinity; foreach (ConquestBase conquestBase in GetBases()) { if (conquestBase.affiliation != b.affiliation) { float distanceToNewEnemy = PathHelper.DistanceSquared(conquestBase.GetOriginPosition(), b.GetOriginPosition()); if (distanceToNewEnemy < distanceToClosestToB) { distanceToClosestToB = distanceToNewEnemy; closestToB = conquestBase; } } } if (distanceToClosestToB < distanceToClosestToFB) { distanceToClosestToFB = distanceToClosestToB; closestToFB = closestToB; fb = b; } } } } return(fb); }
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 virtual void SurvivalPath(ManagerHelper mH) { var c = (Commander)mH.GetNPCManager().GetCommander(affiliation); if (c != null) { if (PathHelper.DistanceSquared(c.GetOriginPosition(), GetOriginPosition()) < 96 * 96) { HoverPath(mH, c.GetOriginPosition(), 96); } else { mH.GetPathHelper().FindClearPath(GetOriginPosition(), c.GetOriginPosition(), mH, path); } } else { RandomPath(mH); } }
protected override void SpecialPath(ManagerHelper mH) { var temp = (Conquest)mH.GetGametype(); ConquestBase targetBase = null; float distanceToClosest = float.PositiveInfinity; foreach (ConquestBase conquestBase in temp.GetBases()) { if (conquestBase.affiliation != affiliation) { float distanceToBase = PathHelper.DistanceSquared(GetOriginPosition(), conquestBase.GetOriginPosition()); if (distanceToBase < distanceToClosest) { distanceToClosest = distanceToBase; targetBase = conquestBase; } } } if (targetBase != null) { if (PathHelper.DistanceSquared(GetOriginPosition(), targetBase.GetOriginPosition()) > 32 * 32) { mH.GetPathHelper().FindClearPath(GetOriginPosition(), targetBase.GetOriginPosition(), mH, path); } else { HoverPath(mH, targetBase.GetOriginPosition(), 32); } } else { EngagePath(mH); } }
protected override void Behavior(ManagerHelper mH) { if (TargetDecider(mH) != null && PathHelper.DistanceSquared(GetOriginPosition(), TargetDecider(mH).GetOriginPosition()) < 96 * 96) { target = TargetDecider(mH); } else if (TargetDecider(mH) == null) { target = null; } if (shootingCounter > shootingSpeed) { shootingCounter = 0; Shoot(mH); } else { shootingCounter += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } }
public ConquestBase GetClosestInList(List <ConquestBase> bL, Vector2 p) { if (bL.Count > 0) { ConquestBase closest = null; float minDist = float.PositiveInfinity; foreach (ConquestBase b in bL) { float aDist = PathHelper.DistanceSquared(p, b.GetOriginPosition()); if (aDist < minDist) { closest = b; minDist = aDist; } } return(closest); } return(null); }
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); }
protected override void SurvivalPath(ManagerHelper mH) { pathTimerEnd = .5; var temp = (Survival)mH.GetGametype(); Claimable c = temp.GetClosestClaimable(GetOriginPosition()); NPC enemy = mH.GetNPCManager() .GetClosestInList(mH.GetNPCManager().GetAllies(AffliationTypes.black), GetOriginPosition()); if (enemy != null && PathHelper.DistanceSquared(GetOriginPosition(), enemy.GetOriginPosition()) < 200 * 200) { mH.GetPathHelper().FindEscapePath(GetOriginPosition(), enemy.GetOriginPosition(), 400, mH, 200, path); } else if (c != null && temp.GetPopCap() > mH.GetNPCManager().GetAllies(affiliation).Count) { mH.GetPathHelper().FindClearPath(GetOriginPosition(), c.GetOriginPosition(), mH, path); } else { RandomPath(mH); } }
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 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 override void AssaultPath(ManagerHelper mH) { var temp = (Assault)mH.GetGametype(); if (temp.GetAttacker() == affiliation) { if (temp.GetEnemyBase(affiliation).GetMyFlag().status != Flag.FlagStatus.taken) { mH.GetPathHelper() .FindClearPath(GetOriginPosition(), temp.GetEnemyBase(affiliation).GetOriginPosition(), mH, path); } else { NPC captor = temp.GetEnemyBase(affiliation).GetMyFlag().GetCaptor(); NPC closestEnemy = null; float closestDistanceToEnemy = float.PositiveInfinity; foreach (var team in mH.GetGametype().GetTeams()) { if (team != affiliation) { NPC closestEnemyForTeam = mH.GetNPCManager().GetClosestInList(mH.GetNPCManager().GetAllies(team), captor); if (closestEnemyForTeam != null) { float closestDistanceToEnemyForTeam = PathHelper.DistanceSquared(closestEnemyForTeam.GetOriginPosition(), captor.GetOriginPosition()); if (closestDistanceToEnemyForTeam < closestDistanceToEnemy) { closestDistanceToEnemy = closestDistanceToEnemyForTeam; closestEnemy = closestEnemyForTeam; } } } } if (captor == this) { mH.GetPathHelper() .FindClearPath(GetOriginPosition(), temp.GetAllyBase(affiliation).GetOriginPosition(), mH, path); } else if (closestEnemy != null) { mH.GetPathHelper() .FindClearPath(GetOriginPosition(), closestEnemy.GetOriginPosition(), mH, path); } else { mH.GetPathHelper().FindClearPath(GetOriginPosition(), captor.GetOriginPosition(), mH, path); } } } else { if (temp.GetAllyBase(affiliation).GetMyFlag().status == Flag.FlagStatus.home) { HoverPath(mH, temp.GetAllyBase(affiliation).GetOriginPosition(), 48); } else { NPC captor = temp.GetAllyBase(affiliation).GetMyFlag().GetCaptor(); if (captor != null) { mH.GetPathHelper().FindClearPath(GetOriginPosition(), captor.GetOriginPosition(), mH, path); } else { mH.GetPathHelper() .FindClearPath(GetOriginPosition(), temp.GetAllyBase(affiliation).GetMyFlag().GetOriginPosition(), mH, path); } } } }