// '' <summary> // '' Create the SeaGridAdapter, with the grid, and it will allow it to be changed // '' </summary> // '' <param name="grid">the grid that needs to be adapted</param> public SeaGridAdapter(SeaGrid grid) { _myGrid = grid; _myGrid.Changed += new EventHandler(MyGrid_Changed); Changed += new EventHandler(GameController.GridChanged); }
public void SeaGridHitTileTest() { seaGrid = new SeaGrid(Ships); seaGrid.MoveShip(0, 0, ShipName.Tug, Direction.LeftRight); AttackResult ar = seaGrid.HitTile(0, 0); Assert.AreEqual(ar.Value, ResultOfAttack.Destroyed); }
public void reset(SeaGrid pPlayerGrid, ISeaGrid pEnemyGrid) { _hits = 0; _misses = 0; _shots = 0; PlayerGrid = pPlayerGrid; EnemyGrid = pEnemyGrid; }
public void SeaGridItemTest() { seaGrid = new SeaGrid(Ships); //the sea grid should be empty. Check to make sure though. for (int x = 0; x < seaGrid.Width; x++) { for (int y = 0; y < seaGrid.Height; y++) { Assert.AreEqual(seaGrid.Item(x, y), TileView.Sea); } } }
public void TestShipDeployed() { int offset = 0; SeaGrid seaGrid = new SeaGrid(_ships); foreach (KeyValuePair <ShipName, Ship> entry in _ships) { ShipName name = entry.Key; Ship ship = entry.Value; seaGrid.MoveShip(0, offset++, name, Direction.UpDown); Assert.IsTrue(ship.IsDeployed); } }
public Player(BattleShipsGame controller) { _game = controller; _playerGrid = new SeaGrid(_Ships); //for each ship add the ships name so the seagrid knows about them foreach (ShipName name in Enum.GetValues(typeof(ShipName))) { if (name != ShipName.None) { _Ships.Add(name, new Ship(name)); } } RandomizeDeployment(); }
public void SeaGridInitTest() { //build an array of ships. foreach (ShipName s in System.Enum.GetValues(typeof(ShipName))) { if (s != ShipName.None) { Ships.Add(s, new Ship(s)); } } //now add the new seagrid seaGrid = new SeaGrid(Ships); }
public void SetUp() { // initialize ships _ships.Clear(); foreach (ShipName name in Enum.GetValues(typeof(ShipName))) { if (name != ShipName.None) { _ships.Add(name, new Ship(name)); } } // initialize seagrid _seaGrid = new SeaGrid(_ships); }
public void AlldeployedProperty() { Ship ship1 = new Ship(ShipName.Battleship); Dictionary <ShipName, Ship> ships = new Dictionary <ShipName, Ship> { [ShipName.Battleship] = ship1 }; SeaGrid seagrid = new SeaGrid(ships); bool expected = false; bool actual = seagrid.AllDeployed; Assert.AreEqual(expected, actual, "correct value is false"); }
/// <summary> /// Player Constructor. /// Initializes a new instance of the Player class. /// </summary> public Player(BattleShipsGame controller) { // VBConversions Note: Non-static class variable initialization is below. Class variables cannot be initially assigned non-static values in C#. _playerGrid = new SeaGrid(_Ships); _game = controller; //for each ship add the ships name so the seagrid knows about them foreach (ShipName name in Enum.GetValues(typeof(ShipName))) { if (name != ShipName.None) { _Ships.Add(name, new Ship(name)); } } RandomizeDeployment(); }
public Player(BattleShipsGame controller) { _game = controller; _playerGrid = new SeaGrid(_Ships); //for each ship add the ships name so the seagrid knows about them foreach (ShipName name in Enum.GetValues(typeof(ShipName))) { if (name != ShipName.None) { _Ships.Add(name, new Ship(name)); } } #pragma warning disable RECS0021 // Warns about calls to virtual member functions occuring in the constructor RandomizeDeployment(); #pragma warning restore RECS0021 // Warns about calls to virtual member functions occuring in the constructor }
public FormGame() { InitializeComponent(); //sea_user = new Море(); //sea_pc = new Море(); sea_user = new едактор(); sea_user.ShowShip = ShowUserShip;//инициализация делегатов sea_user.ShowFight = ShowUserFight; sea_pc = new едактор(); sea_pc.ShowShip = ShowPcShip; sea_pc.ShowFight = ShowPcFight; GridUser = new SeaGrid(grid_user); GridComp = new SeaGrid(grid_pc); // InitGrid(grid_user); // InitGrid(grid_pc); Restart(); timer1.Enabled = true;//для ходов компьютера }
/// <summary> /// Create the SeaGridAdapter, with the grid, and it will allow it to be changed /// </summary> /// <param name="grid">the grid that needs to be adapted</param> public SeaGridAdapter(SeaGrid grid) { _MyGrid = grid; _MyGrid.Changed += new EventHandler(MyGrid_Changed); }
// <summary> // Create the SeaGridAdapter, with the grid, and it will allow it to be changed // </summary> // <param name="grid">the grid that needs to be adapted</param> public SeaGridAdapter(SeaGrid grid) { _MyGrid = grid; _MyGrid.Changed += new EventHandler(MyGrid_Changed); }
Player() { _playerGrid = new SeaGrid(_Ships); }
private void InitializeInstanceFields() { _Ships = new Dictionary <ShipName, Ship>(); _playerGrid = new SeaGrid(_Ships); }
private void InitializePlayer(BattleShipsGame controller) { _game = controller; _playerGrid = new SeaGrid(_Ships); RandomizeDeployment(_Ships); }
public void SeaGridMoveShipTest() { seaGrid = new SeaGrid(Ships); seaGrid.MoveShip(0, 0, ShipName.Tug, Direction.LeftRight); Assert.AreEqual(seaGrid.Item(0, 0), TileView.Ship); }
// '' <summary> // '' Create the SeaGridAdapter, with the grid, and it will allow it to be changed // '' </summary> // '' <param name="grid">the grid that needs to be adapted</param> public SeaGridAdapter(SeaGrid grid) { _MyGrid = grid; _MyGrid.Changed += new EventHandler(// TODO: Warning!!!! NULL EXPRESSION DETECTED... .); }
/// <summary> /// Create the SeaGridAdapter, with the grid, and it will allow it to be changed /// </summary> /// <param name="grid">the grid that needs to be adapted</param> public SeaGridAdapter(SeaGrid grid) { _MyGrid = grid; _MyGrid.Changed += MyGrid_Changed; }