예제 #1
0
        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);
        }
예제 #2
0
 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;
 }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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;
                        }
                    }
                }
            }
        }
예제 #6
0
 public override TParameters CalculateDamage(TShip damager, TShip defenser, TDirection direction)
 {
     // TODO
     throw new NotImplementedException();
 }
예제 #7
0
 public abstract TParameters CalculateDamage(TShip damager, TShip defenser, TDirection direction);
예제 #8
0
 public override void Execute(TBaseShipController shipController, TShip ship, object obj)
 {
     Execute(shipController, ship, (TDirection)obj);
 }
예제 #9
0
 public abstract void Execute(TBaseShipController shipController, TShip ship, Object obj);