public void PerformAction(UnitPiece piece, Action action, Point tile, bool free = false) { if (!free) { piece.unit.hasActionLeft = false; } action.Perform(mapManager, tile); piece.PerformingAction(action); piece.Animation(action.type); if (action.type == ActionType.Attack) { Unit target = GetUnit(tile).unit; if (!target.IsAlive()) { RemoveUnit(tile); } } }
public bool PerformAction(Point tile) { bool found = false; foreach (TargetTile targetTile in targets) { if (targetTile.point == tile) { found = targetTile.type == TargetType.Valid; break; } } if (found) { if (!action.CanUse()) { // ToDo: Show lack of energy return(false); } actionPerformed = true; targets.Clear(); mapManager.RemoveMarkings(); action.Perform(mapManager, tile); selectedUnit.PerformingAction(action); selectedUnit.Animation(action.type); if (action.type == ActionType.Attack) { Unit target = GetUnit(tile).unit; if (!target.IsAlive()) { RemoveUnit(tile); } } combatManager.EndTurn(); return(true); } return(false); }