public void TestGridDraw() { spaceGrid testGrid = new spaceGrid(); AssembledShip testShip = new AssembledShip(new Frigate(), 5, 5); SpaceshipGame.SpaceGame.Grid.GridDraw.DrawShipGrid(testGrid); }
public Player() { Console.WriteLine("Enter player name:"); PlayerName = Console.ReadLine(); Console.WriteLine("----SHIP ASSEMBLY----"); PlayerShips.Add(AssembledShip.AssembleMenu()); }
public CPU(String CPUname, List <AssembledShip> CPUships) { Console.WriteLine("Enter player name:"); CPUName = Console.ReadLine(); Console.WriteLine("----SHIP ASSEMBLY----"); CPUships.Add(AssembledShip.AssembleMenu()); }
public void TestShipPlacement() { spaceGrid testGrid2 = new spaceGrid(); AssembledShip testShip = new AssembledShip(new Frigate(), 5, 5); testGrid2.AddShip(testShip, 5, 5); Assert.IsTrue(testGrid2.isObstaclePresent(5, 5) == 1); }
public void TestShipMovement() { spaceGrid testGrid = new spaceGrid(); AssembledShip testShip = new AssembledShip(new Frigate(), 5, 5); testGrid.AddShip(testShip, 5, 5); Assert.IsTrue(testGrid.isObstaclePresent(5, 5) == 1); spaceGrid.MoveShip(testShip, 4, 4, testGrid); Assert.IsTrue(testGrid.isObstaclePresent(5, 5) == 0); Assert.IsTrue(testGrid.isObstaclePresent(4, 4) == 1); }
///AddShip: adds a ship object at the selected row / col in the ShipGrid. //TODO: Check for existing ship or asteroid at row / col. public void AddShip(AssembledShip ship, int row, int col) { if (ship != null) { if (spacegrid[row, col] == true && (shipGrid[row, col] == null)) { shipGrid[row, col] = ship; ship.setLocationRow(row); ship.setLocationCol(col); } } }
//TODO: Finish implementing this method, make design decisions on how to move a vessel. public static void MoveShip(AssembledShip selectedShip, int destRow, int destCol, spaceGrid gameGrid) { //Null-Check before assigning variables based off the selectedShip and gameGrid if (selectedShip != null && gameGrid != null) { //Determine current position of object (ship). int currentRow = selectedShip.getLocationRow(); int currentCol = selectedShip.getLocationCol(); if (isValidMove(destRow, destCol, gameGrid) == true) { //place selectedShip in desired Col/Row gameGrid.shipGrid[destRow, destCol] = selectedShip; gameGrid.shipGrid[currentRow, currentCol] = null; //set the location on each ship object selectedShip.setLocationCol(destCol); selectedShip.setLocationRow(destRow); } } }
private void PlayerMoveShip(AssembledShip currentShip) { Console.WriteLine($"You selected 'MOVE'. Moving {0}\n", currentShip); Console.WriteLine("Enter destination Column:"); string responseColString = Console.ReadLine(); int responseCol = Int32.Parse(responseColString); Console.WriteLine("Enter destination Row:"); string responseRowString = Console.ReadLine(); int responseRow = Int32.Parse(responseRowString); Console.WriteLine($"Moving to Column {responseCol}, Row: {responseRow}"); spaceGrid.MoveShip(currentShip, responseRow, responseRow, grid); Console.WriteLine($"Moved to Column {responseCol}, Row: {responseRow}"); return; }
public void PerformCombat(AssembledShip ship1, AssembledShip ship2) { }
public void PerformEncounter(AssembledShip ship1, AssembledShip ship2) { }
public void MoveShipDirection(AssembledShip selectedShip, int Direction) { int shipLocationCol = selectedShip.getLocationCol(); int shipLocationRow = selectedShip.getLocationRow(); if (Direction == UP) { selectedShip.setLocationCol(shipLocationCol); selectedShip.setLocationRow(shipLocationRow - 1); this.shipGrid[shipLocationRow - 1, shipLocationCol] = selectedShip; this.shipGrid[shipLocationRow, shipLocationCol] = null; } if (Direction == DOWN) { selectedShip.setLocationCol(shipLocationCol); selectedShip.setLocationRow(shipLocationRow + 1); this.shipGrid[shipLocationRow + 1, shipLocationCol] = selectedShip; this.shipGrid[shipLocationRow, shipLocationCol] = null; } if (Direction == LEFT) { selectedShip.setLocationCol(shipLocationCol - 1); selectedShip.setLocationRow(shipLocationRow); this.shipGrid[shipLocationRow, shipLocationCol - 1] = selectedShip; this.shipGrid[shipLocationRow, shipLocationCol] = null; } if (Direction == RIGHT) { selectedShip.setLocationCol(shipLocationCol + 1); selectedShip.setLocationRow(shipLocationRow); this.shipGrid[shipLocationRow, shipLocationCol + 1] = selectedShip; this.shipGrid[shipLocationRow, shipLocationCol] = null; } if (Direction == UP_AND_LEFT) { selectedShip.setLocationCol(shipLocationCol - 1); selectedShip.setLocationRow(shipLocationRow - 1); this.shipGrid[shipLocationRow - 1, shipLocationCol - 1] = selectedShip; this.shipGrid[shipLocationRow, shipLocationCol] = null; } if (Direction == UP_AND_RIGHT) { selectedShip.setLocationCol(shipLocationCol + 1); selectedShip.setLocationRow(shipLocationRow - 1); this.shipGrid[shipLocationRow - 1, shipLocationCol + 1] = selectedShip; this.shipGrid[shipLocationRow, shipLocationCol] = null; } if (Direction == DOWN_AND_LEFT) { selectedShip.setLocationCol(shipLocationCol - 1); selectedShip.setLocationRow(shipLocationRow + 1); this.shipGrid[shipLocationRow + 1, shipLocationCol - 1] = selectedShip; this.shipGrid[shipLocationRow, shipLocationCol] = null; } if (Direction == DOWN_AND_RIGHT) { selectedShip.setLocationCol(shipLocationCol + 1); selectedShip.setLocationRow(shipLocationRow + 1); this.shipGrid[shipLocationRow + 1, shipLocationCol + 1] = selectedShip; this.shipGrid[shipLocationRow, shipLocationCol] = null; } if (Direction == CENTER) { //Staying put. No action. return; } }