public void Execute(TBaseShipController shipController, TShip ship, TDirection direction) { TParameters damage = _damageController.CalculateDamage(shipController.CurrentShip, ship, direction); TShipParts oldHitPoints = ship.Current.Parameters.HitPoints; ship.Current.Parameters -= damage; ship.Storage.OnDamage(oldHitPoints, ship.Current.Parameters.HitPoints); }
public void AddShip(TShip ship, TCell cell) { if (!IsRoundPlay) { _ships.Add(ship, cell); } else { _nextStepShips.Add(ship, cell); } Map[cell.X, cell.Y].IsFree = false; }
public override void Execute(TBaseShipController shipController, TCell cell) { if (!cell.IsAvailableRouteCell) { throw new ArgumentOutOfRangeException(); } TShip ship = shipController.CurrentShip; shipController.SubShip(ship); ship.Current.Parameters -= cell.Bonus; shipController.AddShip(ship, cell); }
public void SubShip(TShip ship) { int index = 0; for (int i = 0; i < _ships.Count; i++) { if (_ships.Keys[i].Equals(ship)) { index = i; break; } } Map[_ships.Values[index].X, _ships.Values[index].Y].IsFree = true; _ships.RemoveAt(index); }
public void CalculateAvailableArea(TShip ship, TCell cell) { for (int i = 0; i < _residualLength.GetLength(0); i++) { for (int j = 0; j < _residualLength.GetLength(1); j++) { _residualLength[i, j] = 0; } } _residualLength[cell.X, cell.Y] = ship.Current.Parameters.Speed * roundTime; Int32 x = cell.X; Int32 y = cell.Y; while (_residualLength[x, y] != 0) { _map[x, y].IsAvailableRouteCell = true; var enumerator = _map.GetNeighbours(x, y).GetEnumerator(); while (enumerator.MoveNext()) { Int32 curX = enumerator.Current.X; Int32 curY = enumerator.Current.Y; if (_map[curX, curY].IsFree) { _residualLength[curX, curY] = Math.Max(_residualLength[curX, curY], _residualLength[x, y] - cellHeight / (1 - 0.5 * (_map[x, y].Bonus.Speed + _map[curX, curY].Bonus.Speed) / ship.Current.Parameters.Speed)); } } for (int i = 0; i < _residualLength.GetLength(0); i++) { for (int j = 0; j < _residualLength.GetLength(1); j++) { if (_map[i, j].IsFree && !_map[i, j].IsAvailableRouteCell && (x <0 || _residualLength[i, j]> _residualLength[x, y])) { x = i; y = j; } } } } }
public override TParameters CalculateDamage(TShip damager, TShip defenser, TDirection direction) { // TODO throw new NotImplementedException(); }
public abstract TParameters CalculateDamage(TShip damager, TShip defenser, TDirection direction);
public override void Execute(TBaseShipController shipController, TShip ship, object obj) { Execute(shipController, ship, (TDirection)obj); }
public abstract void Execute(TBaseShipController shipController, TShip ship, Object obj);