public void Tick(Actor self) { if (allies1.WinState != WinState.Undefined) return; if (world.FrameNumber == 1) InsertSpies(); if (frameInfiltrated != -1) { if (world.FrameNumber == frameInfiltrated + 100) { Sound.Play("aarrivs1.aud"); worldRenderer.Viewport.Center(reinforcementsUnloadPoint.CenterPosition); world.AddFrameEndTask(w => SendReinforcements()); } if (world.FrameNumber == frameInfiltrated + 200) { Sound.Play("timergo1.aud"); destroyBaseTimer = new CountdownTimer(destroyBaseTicks, OnDestroyBaseTimerExpired, true); destroyBaseTimerWidget = new CountdownTimerWidget(destroyBaseTimer, "Secure lab in: {0}"); Ui.Root.AddChild(destroyBaseTimerWidget); } if (world.FrameNumber >= frameInfiltrated + 200) destroyBaseTimer.Tick(); if (world.FrameNumber == frameInfiltrated + 1500 * 12 && !bridgeTank.IsDead() && bridgeTank.IsInWorld && !bridge.IsDead()) { bridgeTank.QueueActivity(new Attack(Target.FromPos(bridge.CenterPosition), WRange.FromCells(4))); attackingBridge = true; } if (attackingBridge && bridge.IsDead()) { if (!bridgeTank.IsDead()) bridgeTank.CancelActivity(); attackingBridge = false; } if (world.FrameNumber == frameInfiltrated + 1500 * 6) foreach (var attacker in townAttackers.Where(a => !a.IsDead() && a.IsInWorld)) { attacker.CancelActivity(); attacker.QueueActivity(new AttackMove.AttackMoveActivity(attacker, new Move.Move(reinforcementsUnloadPoint.Location + new CVec(10, -15), 3))); } } if (attackingTown) { foreach (var attacker in townAttackers.Where(u => u.IsIdle && !u.IsDead() && u.IsInWorld)) { var enemies = world.Actors.Where(u => u.Owner == creeps && u.HasTrait<ITargetable>() && ((u.HasTrait<Building>() && !u.HasTrait<Wall>() && !u.HasTrait<Bridge>()) || u.HasTrait<Mobile>()) && !u.IsDead() && u.IsInWorld); var enemy = enemies.ClosestTo(attacker); if (enemy != null) attacker.QueueActivity(new AttackMove.AttackMoveActivity(attacker, new Attack(Target.FromActor(enemy), WRange.FromCells(3)))); else { attackingTown = false; break; } } } foreach (var patrol in patrols) patrol.DoPatrol(); MissionUtils.CapOre(soviets); BaseGuardTick(); if (world.FrameNumber == nextCivilianMove) { var civilians = world.Actors.Where(a => !a.IsDead() && a.IsInWorld && a.Owner == creeps && a.HasTrait<Mobile>()); if (civilians.Any()) { var civilian = civilians.Random(world.SharedRandom); civilian.Trait<Mobile>().Nudge(civilian, civilian, true); nextCivilianMove += world.SharedRandom.Next(1, 75); } } world.AddFrameEndTask(w => { if ((allies1Spy.IsDead() && !allies1SpyInfiltratedLab) || (allies2Spy != null && allies2Spy.IsDead() && !allies2SpyInfiltratedLab)) { infiltrateLab.Status = ObjectiveStatus.Failed; OnObjectivesUpdated(true); MissionFailed("{0} spy was killed.".F(allies1 != allies2 ? "A" : "The")); } else if (lab.IsDead()) { if (infiltrateLab.Status == ObjectiveStatus.InProgress) infiltrateLab.Status = ObjectiveStatus.Failed; else if (destroyBase.Status == ObjectiveStatus.InProgress) destroyBase.Status = ObjectiveStatus.Failed; OnObjectivesUpdated(true); MissionFailed("The Soviet research laboratory was destroyed."); } else if (!world.Actors.Any(a => (a.Owner == allies1 || a.Owner == allies2) && !a.IsDead() && (a.HasTrait<Building>() && !a.HasTrait<Wall>()) || a.HasTrait<BaseBuilding>())) { destroyBase.Status = ObjectiveStatus.Failed; OnObjectivesUpdated(true); MissionFailed("The remaining Allied forces in the area have been wiped out."); } else if (SovietBaseDestroyed() && infiltrateLab.Status == ObjectiveStatus.Completed) { destroyBase.Status = ObjectiveStatus.Completed; OnObjectivesUpdated(true); MissionAccomplished("The Soviet research laboratory has been secured successfully."); } }); }
void ReinforcementsTimerExpired(CountdownTimer countdownTimer) { reinforcementsTimerWidget.Visible = false; SendReinforcements(); Sound.Play("aarrivs1.aud"); }
public CountdownTimerWidget(CountdownTimer timer, string format) { Timer = timer; Format = format; }
public CountdownTimerWidget(CountdownTimer timer, string format) { Timer = timer; Format = format; }
public CountdownTimerWidget(CountdownTimer timer, string format, float2 position) { Timer = timer; Format = format; Position = position; }
public CountdownTimerWidget(CountdownTimer timer, string format, float2 position) { Timer = timer; Format = format; Position = position; }