protected override void UsePower(ManagerHelper mH) { if (CurrentPower() > abilityUse && !mH.GetAbilityManager().HasReachedLargeRockCap()) { Vector2 tempPos; if (GetPercentHealth() < .5) { tempPos = new Vector2(64) * lastDamagerDirection + GetOriginPosition(); } else { tempPos = new Vector2(64) * PathHelper.Direction(rotation) + GetOriginPosition(); } tempPos.X = tempPos.X - (tempPos.X % 32) + 16; tempPos.Y = tempPos.Y - (tempPos.Y % 32) + 16; if (tempPos.X > 0 && tempPos.X < mH.GetLevelSize().X&& tempPos.Y > 0 && tempPos.Y < mH.GetLevelSize().Y&& !PathHelper.IsNodeBlocked(tempPos)) { mH.GetAbilityManager().AddLargeRock(tempPos, affiliation); base.UsePower(mH); UpdatePowerStatistic(); } } }
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(); }
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; } }
protected override void UsePower(ManagerHelper mH) { if (CurrentPower() > abilityUse) { Vector2 tempPos = new Vector2(64) * PathHelper.Direction(rotation) + GetOriginPosition(); mH.GetAbilityManager().AddFireball(tempPos, PathHelper.Direction(this.rotation), affiliation); base.UsePower(mH); } }
protected override void UsePower(ManagerHelper mH) { if (CurrentPower() > abilityUse) { for (int i = 0; i < 4; i++) { mH.GetAbilityManager().AddWaterpool(new Vector2(32) * PathHelper.Direction(rotation + (i * (MathHelper.Pi / 2))) + GetOriginPosition(), affiliation); } base.UsePower(mH); } }
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)); }
protected override void UsePower(ManagerHelper mH) { if (CurrentPower() > abilityUse) { Vector2 tempPos = new Vector2(64) * PathHelper.Direction(rotation) + GetOriginPosition(); tempPos.X = tempPos.X - (tempPos.X % 32) + 16; tempPos.Y = tempPos.Y - (tempPos.Y % 32) + 16; if (tempPos.X > 0 && tempPos.X < mH.GetLevelSize().X&& tempPos.Y > 0 && tempPos.Y < mH.GetLevelSize().Y&& !PathHelper.IsNodeBlocked(tempPos)) { mH.GetAbilityManager().AddLargeRock(tempPos, affiliation); base.UsePower(mH); UpdatePowerStatistic(); } } }
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; }
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 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 virtual void PosUpdate(ManagerHelper mH) { //Update position Vector2 tempPos = position + velocity * mH.GetDeltaSeconds(); Vector2 tempOPos = tempPos + origin; float distSquared = 1000000; if (float.IsNaN(tempPos.X) || float.IsNaN(tempPos.Y)) { //TODO: Do not leave this in. throw new Exception("Not sure how this happened."); } //Collisions foreach (NPC a in mH.GetNPCManager().GetNPCs()) //first go through every single npc { if (a.GetAffiliation() != affiliation && distSquared > PathHelper.DistanceSquared(a.GetOriginPosition(), tempOPos)) { Vector2 tempVect = CollisionHelper.IntersectPixelsSimple(this, a); if (tempVect != new Vector2(-1)) { velocity = CollisionHelper.CollideRandom(GetOriginPosition(), tempVect) * movementSpeed; } } } foreach (LargeRock r in mH.GetAbilityManager().GetLargeRocks()) { if (distSquared > PathHelper.DistanceSquared(r.GetOriginPosition(), tempOPos)) { int tempVect = CollisionHelper.IntersectPixelsDirectionalRaw(this, tempOPos, r); if (tempVect != -1) { velocity = CollisionHelper.CollideSimple(tempVect, velocity); } } } foreach (Environment e in mH.GetEnvironmentManager().GetStaticBlockers()) { if (distSquared > PathHelper.DistanceSquared(e.GetOriginPosition(), tempOPos)) { int tempVect = CollisionHelper.IntersectPixelsDirectionalRaw(this, tempOPos, e); if (tempVect != -1) { if (e is SwitchBox) { SwitchBox box = (SwitchBox)e; box.lowerHealth(); } velocity = CollisionHelper.CollideSimple(tempVect, velocity); } } } foreach (Impassable e in mH.GetEnvironmentManager().GetImpassables()) { if (distSquared > PathHelper.DistanceSquared(e.GetOriginPosition(), tempOPos)) { int tempVect = CollisionHelper.IntersectPixelsDirectionalRaw(this, tempOPos, e); if (tempVect != -1) { velocity = CollisionHelper.CollideDirectional(velocity, tempVect); } } } tempPos = position + velocity * mH.GetDeltaSeconds(); if ( !(tempPos.X < buffer || tempPos.X > mH.GetLevelSize().X - frame.Width - buffer || tempPos.Y < buffer || tempPos.Y > mH.GetLevelSize().Y - frame.Height - buffer)) { } else { if (tempPos.X <= buffer) { tempPos.X = buffer; } else if (tempPos.X > mH.GetLevelSize().X - frame.Width - buffer) { tempPos.X = mH.GetLevelSize().X - frame.Width - buffer; } if (tempPos.Y <= buffer) { tempPos.Y = buffer; } else if (tempPos.Y > mH.GetLevelSize().Y - frame.Height - buffer) { tempPos.Y = mH.GetLevelSize().Y - frame.Height - buffer; } } position = tempPos; //Update frames frame.X = frameIndex * frame.Width; frame.Y = modeIndex * frame.Height; UpdateProtection(mH); }