Пример #1
0
        public void WaitClick(object sender, System.Windows.RoutedEventArgs e)
        {
            string actionText = "Unitstack wait...";

            ActionCompleted = true;
            OnActionCompleted?.Invoke(actionText);
        }
Пример #2
0
        public void AttackClick(object sender, System.Windows.RoutedEventArgs e)
        {
            string actionText = GameField.SelectedCell.UnitStack.Attack(GameField.CellToAttack.UnitStack);

            if (GameField.CellToAttack.UnitStack != null &&
                GameField.CellToAttack.UnitStack != GameField.SelectedCell.UnitStack &&
                GameField.CellToAttack.UnitStack.Units.Count < GameField.CellToAttack.MaxUnitNumber)
            {
                if (GameField.CellToAttack.UnitStack.Units.Count > 1)
                {
                    GameField.CellToAttack.CurrentUnitNumber =
                        (GameField.CellToAttack.UnitStack.Units.Count - 1) *
                        GameField.CellToAttack.UnitStack.Units.FirstOrDefault().HitPoints +
                        GameField.CellToAttack.UnitStack.Units.Peek().CurrentHitPoints;
                }
                else if (GameField.CellToAttack.UnitStack.Units.Count == 1)
                {
                    GameField.CellToAttack.CurrentUnitNumber =
                        GameField.CellToAttack.UnitStack.Units.Peek().CurrentHitPoints;
                }
                else
                {
                    GameField.CellToAttack.CurrentUnitNumber = 0;
                    Player2.UnitStacks.Remove(GameField.CellToAttack.UnitStack);
                    Player1.UnitStacks.Remove(GameField.CellToAttack.UnitStack);

                    if (IsPlayer1Selected)
                    {
                        GameEnded = Player2.UnitStacks.Count > 0 ? false : true;
                    }
                    else
                    {
                        GameEnded = Player1.UnitStacks.Count > 0 ? false : true;
                    }

                    GameField.CellToAttack.ClearCell();
                }
            }

            ActionCompleted = true;
            OnActionCompleted?.Invoke(actionText);
        }
Пример #3
0
 public void TriggerActionCompleted(Action action)
 {
     OnActionCompleted?.Invoke(action);
 }