protected virtual void SpecialPath(ManagerHelper mH) { if (mH.GetGametype() is Conquest) { ConquestPath(mH); } else if (mH.GetGametype() is CaptureTheFlag) { CTFPath(mH); } else if (mH.GetGametype() is Assault) { AssaultPath(mH); } else if (mH.GetGametype() is Deathmatch) { DeathmatchPath(mH); } else if (mH.GetGametype() is Survival) { pathTimerEnd = 0.1; SurvivalPath(mH); } else { EngagePath(mH); } }
protected override void NewPath(ManagerHelper mH) { if (mH.GetGametype() is Conquest) { ConquestPath(mH); } else if (mH.GetGametype() is CaptureTheFlag) { CTFPath(mH); } else if (mH.GetGametype() is Assault) { AssaultPath(mH); } else if (mH.GetGametype() is Deathmatch) { DeathmatchPath(mH); } else if (mH.GetGametype() is Survival) { SurvivalPath(mH); } else { EngagePath(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 SpawnPoint(Vector2 sP, NPC.AffliationTypes a, ManagerHelper mH) : base(null, sP) { spawnPoint = sP; affilation = a; isGoodSpawnPoint = true; spawnCounter = 0; spawnTime = mH.GetGametype().GetSpawnTime() * 1.1; //so same spot wont be used twice in a row velocity = Vector2.Zero; isOneUse = (mH.GetGametype() is Conquest) && (affilation == NPC.AffliationTypes.grey); isUsed = false; }
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 void Update(ManagerHelper mH) { medicKills = mH.GetNPCManager().GetMedicKills(); flagsCaptured = mH.GetGametype().GetFlagsCaptured(); flagsReturned = mH.GetGametype().GetFlagsReturned(); rocksCreatedCounter += (mH.GetNPCManager().GetSpecificCommander(NPC.AffliationTypes.green) != null) ? mH.GetNPCManager().GetSpecificCommander(NPC.AffliationTypes.green).GetPowerStatistic() : 0; rocksDestroyed = mH.GetAbilityManager().GetRocksDestroyedByCommanders(); waterSpilledCounter = mH.GetAbilityManager().GetWaterSpilledCounter(); dotsRecruited = mH.GetGametype().GetDotsRecruited(); lightningTravelledCounter = mH.GetAbilityManager().GetLightningTravelledCounter(); mostTimeFlagAway = mH.GetGametype().GetMostTimeFlagAway(); quickestFlagCapture = mH.GetGametype().GetQuickestFlagCapture(); dotsSetOnFireCounter = mH.GetAbilityManager().GetDotsSetOnFireCounter(); }
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); }
protected override void SpecialPath(ManagerHelper mH) { var temp = (CaptureTheFlag)mH.GetGametype(); if (temp.GetEnemyBase(affiliation).GetMyFlag().status != Flag.FlagStatus.taken) { mH.GetPathHelper() .FindClearPath(GetOriginPosition(), temp.GetEnemyBase(affiliation).GetMyFlag().GetOriginPosition(), mH, path); } else { NPC captor = temp.GetEnemyBase(affiliation).GetMyFlag().GetCaptor(); if (captor == this) { mH.GetPathHelper() .FindClearPath(GetOriginPosition(), temp.GetAllyBase(affiliation).GetOriginPosition(), mH, path); } else { mH.GetPathHelper().FindClearPath(GetOriginPosition(), captor.GetOriginPosition(), mH, path); } } }
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); }
public void Initialize(ManagerHelper mH, int r) { if (mH.GetGametype() is Survival) { randomness = 0; } else { randomness = r; } length = (int)mH.GetLevelSize().X / (int)nodeSize.X; width = (int)mH.GetLevelSize().Y / (int)nodeSize.Y; managers = mH; //Node Collections field = new Node[length + 1, width + 1]; //Set up field for (int i = 0; i <= length; i++) { for (int j = 0; j <= width; j++) { field[i, j] = new Node(null, 0, 0, false, i, j); } } open = new List <Node>(length * width); closed = new List <Node>(length * width); }
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; } }
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 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); } }
public Suicide(Vector2 p, ManagerHelper mH) : base("Dots/Grey/grey_suicide", p) { var temp = (Survival)mH.GetGametype(); maxHealth = (int)(50 * temp.suicideSpawnModifier); health = maxHealth; movementSpeed = (int)(50 + temp.suicideSpawnModifier * 50); affiliation = AffliationTypes.black; animateCounter = 0; }
protected virtual void AssaultPath(ManagerHelper mH) { var ass = (Assault)mH.GetGametype(); Flag f = ass.GetAllyBase(affiliation).GetMyFlag(); if (f != null && f.status == Flag.FlagStatus.away) { mH.GetPathHelper().FindClearPath(GetOriginPosition(), f.GetOriginPosition(), mH, path); } else { EngagePath(mH); } }
protected virtual void CTFPath(ManagerHelper mH) { var ctf = (CaptureTheFlag)mH.GetGametype(); Flag f = ctf.GetAllyBase(affiliation).GetMyFlag(); if (f.status == Flag.FlagStatus.away) { mH.GetPathHelper().FindClearPath(GetOriginPosition(), f.GetOriginPosition(), mH, path); } else { EngagePath(mH); } }
protected override void SpecialPath(ManagerHelper mH) { var temp = (Conquest)mH.GetGametype(); ConquestBase forwardBase = temp.GetForwardBase(affiliation, mH); if (forwardBase != null) { mH.GetPathHelper().FindClearPath(GetOriginPosition(), forwardBase.GetOriginPosition(), mH, path); } else { EngagePath(mH); } }
protected override void DeathmatchPath(ManagerHelper mH) { var temp = (Deathmatch)mH.GetGametype(); Claimable c = temp.GetClosestClaimable(GetOriginPosition(), mH); if (c != null && temp.GetPopCap() > mH.GetNPCManager().GetAllies(affiliation).Count) { mH.GetPathHelper().FindClearPath(GetOriginPosition(), c.GetOriginPosition(), mH, path); } else { EngagePath(mH); } }
public override void Update(ManagerHelper mH) { if (!taken) { foreach (NPC a in mH.GetNPCManager().GetCommanders()) { if (CollisionHelper.IntersectPixelsRadius(a, this, 16, 32) != new Vector2(-1)) { if (mH.GetNPCManager().GetAllies(a.GetAffiliation()).Count < mH.GetGametype().GetPopCap()) { taken = true; mH.GetGametype().UpdateDotsRecruited(a.GetPersonalAffilation()); for (int i = 0; i < 50 && !mH.GetGametype().Spawn(mH, a.GetAffiliation(), GetOriginPosition()); i++) { //Ain't this just a gem? } } } } } else { if (counter > 7) // counter greater than x number of seconds { Activate(); counter = 0; } else { counter += mH.GetGameTime().ElapsedGameTime.TotalSeconds; } } }
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 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 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); } }
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 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)); }
public void Initialize(ManagerHelper mH) { teams.Add(NPC.AffliationTypes.red); teams.Add(NPC.AffliationTypes.blue); teams.Add(NPC.AffliationTypes.green); teams.Add(NPC.AffliationTypes.yellow); foreach (NPC.AffliationTypes a in teams) { stats.Add(a, new StatisticsManager.StatHolder(0, 0, new StatisticsManager.DoubleWrapper(0), 0, false, 0)); } foreach (var team in mH.GetGametype().GetTeams()) { agents.Add(team, new List <NPC>()); } killsToCommanders = new int [4, 4]; managers = 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); } }
public void LoadContent(ManagerHelper mH) { front.LoadContent(mH.GetTextureManager()); back.LoadContent(mH.GetTextureManager()); damage.LoadContent(mH.GetTextureManager()); health.LoadContent(mH.GetTextureManager()); power.LoadContent(mH.GetTextureManager()); gun.LoadContent(mH.GetTextureManager()); toss.LoadContent(mH.GetTextureManager()); teammate.LoadContent(mH.GetTextureManager()); teammate.SetFrameIndex(NPC.GetTeam(myCamera.GetTeammateColor())); teammate.UpdateFrame(); scoreboard.LoadContent(mH.GetTextureManager()); scoreboard.SetModeIndex(Math.Min(3, mH.GetGametype().GetTeams().Count - 1)); scoreboard.UpdateFrame(); timer.LoadContent(mH.GetTextureManager()); damageWidth = health.GetFrame().Width; healthWidth = health.GetFrame().Width; powerWidth = power.GetFrame().Width; }
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)); }
public AssaultBase(NPC.AffliationTypes a, Vector2 p, ManagerHelper mH) : base("bases", p, Vector2.Zero) { var temp = (Assault)mH.GetGametype(); affiliation = a; if (affiliation == temp.GetAttacker()) { myFlag = null; } else { switch (affiliation) { case NPC.AffliationTypes.red: myFlag = new RedFlag(GetOriginPosition()); break; case NPC.AffliationTypes.blue: myFlag = new BlueFlag(GetOriginPosition()); break; case NPC.AffliationTypes.green: myFlag = new GreenFlag(GetOriginPosition()); break; case NPC.AffliationTypes.yellow: myFlag = new YellowFlag(GetOriginPosition()); break; } } spawnCounter = 0; spawnTime = 1.5; //1.5 seconds }
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); } }