private void doActionAction() { if (MemUnit != null && (MemUnit.getUnit().getPlayer() == game.turn.currentPlayer)) { UnitAPI currunit = memUnit.getUnit(); if (SelectedTile.getEnemy() != null) { if (currunit.canAttack(SelectedTile.getEnemy())) { UnitAPI loser = currunit.attack(SelectedTile.getEnemy()); MessageBox.Show(loser.getPlayer().name + " loses the battle!"); if (loser.lifePoints <= 0) { MessageBox.Show(loser.getPlayer().name + " is dead!"); } } else { MessageBox.Show("Attack action not possible"); } } else { if (currunit.canMove(SelectedTile.X, SelectedTile.Y)) { currunit.move(SelectedTile.X, SelectedTile.Y); } else { MessageBox.Show("Move action not possible"); } } //Global Refresh memUnit.Refresh(); updateTiles(); this.Refresh(); } else { MessageBox.Show("No unit selected"); } this.isFinished(); }
private void selectAction() { if (selectedUnit != null) { if (selectedUnit.getPlayer() == game.turn.currentPlayer) { this.MemUnit = new SelectedUnitViewModel(selectedUnit); updateTiles(); } else { MessageBox.Show("Unit selection not allowed"); } } else { MessageBox.Show("No unit to select"); } }
public UnitAPI getEnemy() { int max = 0; UnitAPI maxDefenceUnit = tileUnits.FirstOrDefault(); if ((maxDefenceUnit == null) || (gameView.MemUnit.getUnit().getPlayer() == maxDefenceUnit.getPlayer())) { return(null); } tileUnits.ForEach(delegate(UnitAPI u) { if (u.defencePoints > max) { maxDefenceUnit = u; } } ); return(maxDefenceUnit); }