/// <summary>
 /// Resets the battle field.
 /// </summary>
 private void DoClearBattleField()
 {
     while (ListRedUnits.Any())
     {
         ListRedUnits.First().Dead();
     }
     while (ListBlueUnits.Any())
     {
         ListBlueUnits.First().Dead();
     }
     FormVisible = false;
     BluePoints  = MAX_TEAM_POINTS;
     RedPoints   = MAX_TEAM_POINTS;
 }
        /// <summary>
        /// When a unit dies, the MainViewModel unsubscribes the unit events, restores unit points to the
        /// total of the team points and remove it from the field of battle.
        /// </summary>
        /// <param name="sender">The dead unit</param>
        /// <param name="Team">The team of the dead unit</param>
        private void Unit_UnitDied(object sender, UnitTeam Team)
        {
            var unit = sender as UnitViewModel;

            unit.UnitAttack -= Unit_UnitAttack;
            unit.UnitDied   -= Unit_UnitDied;
            if (Team == UnitTeam.Red)
            {
                ListRedUnits.Remove(unit);
                ObserverHelper <MainViewModel, int> .NotifyObservers(unit, RedPoints + unit.UsedPoints);
            }
            else
            {
                ListBlueUnits.Remove(unit);
                ObserverHelper <MainViewModel, int> .NotifyObservers(unit, BluePoints + unit.UsedPoints);
            }
        }
 /// <summary>
 /// Starts the battle. Closes the form. disable all buttons.
 /// </summary>
 private async void DoStartBattle()
 {
     if (ListBlueUnits.Any() && ListRedUnits.Any())
     {
         IsBattleGoingOn = true;
         foreach (var one in ListRedUnits)
         {
             one.StartAttack();
         }
         foreach (var one in ListBlueUnits)
         {
             one.StartAttack();
         }
         FormVisible = false;
     }
     else
     {
         var message = new MessageDialog("Each team must have at least one unit");
         await message.ShowAsync();
     }
 }
 private void OnNewRedCavalryClicked()
 {
     ListRedUnits.Add(HookCallBacks(UnitViewModel.GetNewCavalry(UnitTeam.Red, RedPoints)));
 }