public BattleShipModel() { ShipStrength.Add("SUBMARINE", 4); ShipStrength.Add("DESTROYER", 2); ShipStrength.Add("CRUISER", 3); ShipStrength.Add("CARRIER", 5); for (int i = 0; i < TotalShipStrength; i++) { P1ShipStrength.Add(0); P2ShipStrength.Add(0); } FlatStone Default = new FlatStone("-"); for (int i = 0; i < 100; i++) { P1Board.Add(Default); P2Board.Add(Default); P1Land.Add(Default); P2Land.Add(Default); } string[] ShipList = new string[] { "SUBMARINE", "DESTROYER", "CRUISER", "CARRIER" }; foreach (string item in ShipList) { P1Ships.Add(item); P2Ships.Add(item); } }
public void WriteBoard_4_SHIP2(string ship, int position, string ori) { FlatStone shipOF = GetShipInitial(ship); if (GetOrientation(ori).Equals(Orientation.H)) { List <FlatStone> ToBind = GetShipImageH(ship); if (CheckSpace4_SHIP2(position, ship, ori)) { int s = 0; for (int i = position; i < ((int)GetShip(ship) + position); i++) { P2Board[i] = ToBind[s++]; } P2Ships.Remove(ship); } } else if (GetOrientation(ori).Equals(Orientation.V)) { List <FlatStone> ToBind = GetShipImageV(ship); if (CheckSpace4_SHIP2(position, ship, ori)) { int s = 0; for (int i = position; i < ((int)GetShip(ship) * 10) + position; i += 10) { P2Board[i] = ToBind[s++]; } P2Ships.Remove(ship); } } }
public void AttackP2Land(int index) { if (P2Board[index].Stone[0] == 'S') { if (P2Land[index].Stone == "-") { P2Land[index] = new FlatStone("A"); P2ShipStrength.RemoveAt(0); } } else { P2Land[index] = new FlatStone("M"); } }