private void EventPublisherOnTargetSelected(object sender, AttackEventArgs e) { if (ActivePlan == null || ActivePlan.Plan != e.Plan) { foreach (var attackDropDownItem in AttackDropDown.DropDownItems.OfType <ToolStripMenuItem>()) { attackDropDownItem.Checked = false; } if (e.Plan != null) { var selectedPlan = _plans[e.Plan]; selectedPlan.Item1.Checked = true; ActivePlan = selectedPlan.Item2; } else { ActivePlan = null; } } if (ActivePlan != null) { ActivePlan.SetActiveAttacker(e.Attacker); } }
private void cmdSort_Click(object sender, EventArgs e) { if (ActivePlan != null) { ActivePlan.SortOnTimeLeft(); } }
private void cmdFindPool_Click(object sender, EventArgs e) { if (World.Default.Map.Manipulators.AttackManipulator.IsAttackersPoolEmpty) { MessageBox.Show(ControlsRes.AttackPlanCollectionControl_EmptyAttackersPool, ControlsRes.AttackPlanCollectionControl_AttackersPoolTitle); } else if (ActivePlan != null && UnitInput.Unit != null) { VillageType?villageType = GetSelectedVillageTypeFilter(); bool depleted; var searchIn = World.Default.Map.Manipulators.AttackManipulator.GetAttackersFromPool(ActivePlan.Plan, UnitInput.Unit, villageType, out depleted); if (depleted) { MessageBox.Show(ControlsRes.AttackPlanCollectionControl_AttackersPoolDepleted, ControlsRes.AttackPlanCollectionControl_AttackersPoolTitle); } foreach (var attacker in searchIn) { var attackEventArgs = AttackUpdateEventArgs.AddAttackFrom(new AttackPlanFrom(ActivePlan.Plan, attacker.Village, attacker.Speed)); World.Default.Map.EventPublisher.AttackUpdateTarget(this, attackEventArgs); } ActivePlan.SortOnTimeLeft(); } }
private void Timer_Tick(object sender, EventArgs e) { if (ActivePlan != null) { ActivePlan.UpdateDisplay(); } }
private void EventPublisherOnTargetUpdated(object sender, AttackUpdateEventArgs e) { switch (e.Action) { case AttackUpdateEventArgs.ActionKind.Add: e.AttackFrom.ForEach(x => ActivePlan.AddAttacker(x)); break; case AttackUpdateEventArgs.ActionKind.Delete: e.AttackFrom.ForEach(x => ActivePlan.RemoveAttacker(x)); break; case AttackUpdateEventArgs.ActionKind.Update: break; default: Debug.Assert(false); break; } if (e.AttackFrom.Any()) { var plan = e.AttackFrom.First().Plan; _plans[plan].Item1.Text = GetAttackToolstripText(plan); } if (ActivePlan != null) { Debug.Assert(!e.AttackFrom.Any() || ActivePlan.Plan == e.AttackFrom.First().Plan); ActivePlan.SetActiveAttacker(e.AttackFrom.FirstOrDefault()); ActivePlan.UpdateDisplay(); } }
internal void RemoveActivePlan(ActivePlan activePlan) { _activePlans.Remove(activePlan); if (_activePlans.Count == 0) { Dispose(); } }
private void cmdFind_Click(object sender, EventArgs e) { if (World.Default.You.Empty) { ActivePlayerForm.AskToSetSelf(); } else if (ActivePlan != null) { VillageType?villageType = GetSelectedVillageTypeFilter(); var searchIn = World.Default.Map.Manipulators.AttackManipulator.GetAttackersFromYou(ActivePlan.Plan, UnitInput.Unit, villageType); foreach (var attacker in searchIn) { var attackEventArgs = AttackUpdateEventArgs.AddAttackFrom(new AttackPlanFrom(ActivePlan.Plan, attacker.Village, attacker.Speed)); World.Default.Map.EventPublisher.AttackUpdateTarget(this, attackEventArgs); } ActivePlan.SortOnTimeLeft(); } }
public void AddActivePlan(ActivePlan activePlan) { _activePlans.Add(activePlan); }