예제 #1
0
        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);
            }
        }
예제 #2
0
 private void cmdSort_Click(object sender, EventArgs e)
 {
     if (ActivePlan != null)
     {
         ActivePlan.SortOnTimeLeft();
     }
 }
예제 #3
0
        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();
            }
        }
예제 #4
0
 private void Timer_Tick(object sender, EventArgs e)
 {
     if (ActivePlan != null)
     {
         ActivePlan.UpdateDisplay();
     }
 }
예제 #5
0
        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();
            }
        }
예제 #6
0
 internal void RemoveActivePlan(ActivePlan activePlan)
 {
     _activePlans.Remove(activePlan);
     if (_activePlans.Count == 0)
     {
         Dispose();
     }
 }
예제 #7
0
        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();
            }
        }
예제 #8
0
 public void AddActivePlan(ActivePlan activePlan)
 {
     _activePlans.Add(activePlan);
 }