示例#1
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;
 }
示例#2
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);
        }
示例#3
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;
                        }
                    }
                }
            }
        }
示例#4
0
 public abstract void Execute(TBaseShipController shipController, TCell cell);
示例#5
0
 public IEnumerable <TCell> GetNeighbours(TCell current)
 {
     return(GetNeighbours(current.X, current.Y));
 }