public Square(NumShip ship, ShipState s, int x, int y) { this.x = x; this.y = y; if (s == ShipState.clear) state = 0; else if (s == ShipState.shot) state = -1; else state = 1; // ShipState.hit if (ship == NumShip.four_ship) nship = 41; else if (ship == NumShip.three_ship_1) nship = 31; else if (ship == NumShip.three_ship_2) nship = 32; else if (ship == NumShip.double_ship_1) nship = 21; else if (ship == NumShip.double_ship_2) nship = 22; else if (ship == NumShip.double_ship_3) nship = 23; else if (ship == NumShip.single_ship_1) nship = 11; else if (ship == NumShip.single_ship_2) nship = 12; else if (ship == NumShip.single_ship_3) nship = 13; else if (ship == NumShip.single_ship_4) nship = 14; else nship = 0; // NumShip.empty }
public Ship(NumShip ship, Direction direction, Square coord) { square = coord; int length; if ((int)ship == 1) { length = 4; hitpoint = 4; } else if ((int)ship > 1 && (int)ship <= 3) { length = 3; hitpoint = 3; } else if ((int)ship > 3 && (int)ship <= 6) { length = 2; hitpoint = 2; } else if ((int)ship > 6 && (int)ship <= 10) { length = 1; hitpoint = 1; } else { length = 0; hitpoint = 0; } for(int i = 0; i < length; i++) { Square s = new Square(coord.nship, coord.state, coord.x, coord.y); s.Move(i, direction); coordinateslist.Add(s); } }