public void GeneratePonorka() { Position pivot = new Position() { PosX = 1, PosY = 1 }; List <Position> LodObsah = new List <Position>(); LodObsah.Add(new Position { PosX = -1, PosY = -1 }); Lod lod = new Lod("Ponorka", pivot, LodObsah, LodObsah, LodObsah, LodObsah); TemplateShips.Add(lod); }
public void GenerateParnik() { Position pivot = new Position() { PosX = 2, PosY = 2 }; List <Position> LodObsah1 = new List <Position>(); LodObsah1.Add(new Position { PosX = -1, PosY = -2 }); LodObsah1.Add(new Position { PosX = -3, PosY = -2 }); LodObsah1.Add(new Position { PosX = 0, PosY = -1 }); LodObsah1.Add(new Position { PosX = -1, PosY = -1 }); LodObsah1.Add(new Position { PosX = -2, PosY = -1 }); LodObsah1.Add(new Position { PosX = -3, PosY = -1 }); LodObsah1.Add(new Position { PosX = -4, PosY = -1 }); List <Position> LodObsah2 = new List <Position>(); LodObsah2.Add(new Position { PosX = -1, PosY = -0 }); LodObsah2.Add(new Position { PosX = -1, PosY = -1 }); LodObsah2.Add(new Position { PosX = 0, PosY = -1 }); LodObsah2.Add(new Position { PosX = -1, PosY = -2 }); LodObsah2.Add(new Position { PosX = -1, PosY = -3 }); LodObsah2.Add(new Position { PosX = 0, PosY = -3 }); LodObsah2.Add(new Position { PosX = -1, PosY = -4 }); List <Position> LodObsah3 = new List <Position>(); LodObsah3.Add(new Position { PosX = -1, PosY = 0 }); LodObsah3.Add(new Position { PosX = -3, PosY = 0 }); LodObsah3.Add(new Position { PosX = 0, PosY = -1 }); LodObsah3.Add(new Position { PosX = -1, PosY = -1 }); LodObsah3.Add(new Position { PosX = -2, PosY = -1 }); LodObsah3.Add(new Position { PosX = -3, PosY = -1 }); LodObsah3.Add(new Position { PosX = -4, PosY = -1 }); List <Position> LodObsah4 = new List <Position>(); LodObsah4.Add(new Position { PosX = -1, PosY = -0 }); LodObsah4.Add(new Position { PosX = -1, PosY = -1 }); LodObsah4.Add(new Position { PosX = -2, PosY = -1 }); LodObsah4.Add(new Position { PosX = -1, PosY = -2 }); LodObsah4.Add(new Position { PosX = -1, PosY = -3 }); LodObsah4.Add(new Position { PosX = -2, PosY = -3 }); LodObsah4.Add(new Position { PosX = -1, PosY = -4 }); Lod lod = new Lod("Parník", pivot, LodObsah1, LodObsah2, LodObsah3, LodObsah4); TemplateShips.Add(lod); }
public void GenerateTorpedoborec() { Position pivot = new Position() { PosX = 1, PosY = 1 }; List <Position> LodObsah1 = new List <Position>(); LodObsah1.Add(new Position { PosX = -1, PosY = 0 }); LodObsah1.Add(new Position { PosX = -1, PosY = -1 }); List <Position> LodObsah2 = new List <Position>(); LodObsah2.Add(new Position { PosX = -1, PosY = -1 }); LodObsah2.Add(new Position { PosX = -2, PosY = -1 }); List <Position> LodObsah3 = new List <Position>(); LodObsah3.Add(new Position { PosX = -1, PosY = -1 }); LodObsah3.Add(new Position { PosX = -1, PosY = -2 }); List <Position> LodObsah4 = new List <Position>(); LodObsah4.Add(new Position { PosX = -0, PosY = -1 }); LodObsah4.Add(new Position { PosX = -1, PosY = -1 }); Lod lod = new Lod("Torpedoborec", pivot, LodObsah1, LodObsah2, LodObsah3, LodObsah4); TemplateShips.Add(lod); }
public void GenerateHydroplan() { Position pivot = new Position() { PosX = 2, PosY = 2 }; List <Position> LodObsah1 = new List <Position>(); LodObsah1.Add(new Position { PosX = -1, PosY = -2 }); LodObsah1.Add(new Position { PosX = -0, PosY = -1 }); LodObsah1.Add(new Position { PosX = -2, PosY = -1 }); List <Position> LodObsah2 = new List <Position>(); LodObsah2.Add(new Position { PosX = -1, PosY = -2 }); LodObsah2.Add(new Position { PosX = -0, PosY = -1 }); LodObsah2.Add(new Position { PosX = -1, PosY = -0 }); List <Position> LodObsah3 = new List <Position>(); LodObsah3.Add(new Position { PosX = -1, PosY = -0 }); LodObsah3.Add(new Position { PosX = -0, PosY = -1 }); LodObsah3.Add(new Position { PosX = -2, PosY = -1 }); List <Position> LodObsah4 = new List <Position>(); LodObsah4.Add(new Position { PosX = -1, PosY = -2 }); LodObsah4.Add(new Position { PosX = -2, PosY = -1 }); LodObsah4.Add(new Position { PosX = -1, PosY = -0 }); Lod lod = new Lod("Hydroplán", pivot, LodObsah1, LodObsah2, LodObsah3, LodObsah4); TemplateShips.Add(lod); }
public void GenerateLetadlova() { Position pivot = new Position() { PosX = 1, PosY = 1 }; List <Position> LodObsah1 = new List <Position>(); LodObsah1.Add(new Position { PosX = -1, PosY = 0 }); LodObsah1.Add(new Position { PosX = -1, PosY = -1 }); LodObsah1.Add(new Position { PosX = -1, PosY = -2 }); LodObsah1.Add(new Position { PosX = -1, PosY = -3 }); LodObsah1.Add(new Position { PosX = -1, PosY = -4 }); List <Position> LodObsah2 = new List <Position>(); LodObsah2.Add(new Position { PosX = -0, PosY = -1 }); LodObsah2.Add(new Position { PosX = -1, PosY = -1 }); LodObsah2.Add(new Position { PosX = -2, PosY = -1 }); LodObsah2.Add(new Position { PosX = -3, PosY = -1 }); LodObsah2.Add(new Position { PosX = -4, PosY = -1 }); List <Position> LodObsah3 = new List <Position>(); LodObsah3.Add(new Position { PosX = -1, PosY = 0 }); LodObsah3.Add(new Position { PosX = -1, PosY = -1 }); LodObsah3.Add(new Position { PosX = -1, PosY = -2 }); LodObsah3.Add(new Position { PosX = -1, PosY = -3 }); LodObsah3.Add(new Position { PosX = -1, PosY = -4 }); List <Position> LodObsah4 = new List <Position>(); LodObsah4.Add(new Position { PosX = -0, PosY = -1 }); LodObsah4.Add(new Position { PosX = -1, PosY = -1 }); LodObsah4.Add(new Position { PosX = -2, PosY = -1 }); LodObsah4.Add(new Position { PosX = -3, PosY = -1 }); LodObsah4.Add(new Position { PosX = -4, PosY = -1 }); Lod lod = new Lod("Letadlová lod", pivot, LodObsah1, LodObsah2, LodObsah3, LodObsah4); TemplateShips.Add(lod); }
public void Discover(Lod Input) { if (Rotate != RotationState.Unset) { Input.ShipRotate(Rotate); } List <int> MapShipShoot = new List <int>(); TextToPlayer = "Používáš slepou munici"; Kurzor = Input.pivot; int ShipMaxIndex = Input.ShipTiles.Count; int BadCount = 0; Position ShipTile = new Position(); int ShipInt; int KurzorInt = (Kurzor.PosX) + ((Kurzor.PosY) * MapSize); AbleToPlace = true; for (int i = 0; i < ShipMaxIndex; i++) { ShipTile = Input.ShipTiles[i]; ShipInt = (ShipTile.PosX + Kurzor.PosX) + ((ShipTile.PosY + Kurzor.PosY) * MapSize); if (ShipTile.PosX + Kurzor.PosX >= 0 && ShipTile.PosX + Kurzor.PosX <= MapSize - 1) { } else { TextToPlayer = "Zde nemůžeš střílet"; BadCount++; } if (ShipInt < MapMaxIndex && ShipInt >= 0)/*&& MapSize * (b - 1) <= ShipInt && MapSize * b >= ShipInt*/ { if (MapState[ShipInt] == 2 || MapState[ShipInt] == 0) { MapShipShoot.Add(ShipInt); } MapStatePlayer[ShipInt] = 3; } else { //not able place!!! TextToPlayer = "Zde nemůžeš střílet"; BadCount++; } } if (BadCount == 0 && Place == true) { MapStatePlayer = MapStatePlayerReal.ToList(); for (int i = 0; i < MapShipShoot.Count(); i++) { ShipInt = MapShipShoot[i]; if (MapStateReal[ShipInt] == 2) { MapStatePlayer[ShipInt] = 2; } else { MapStatePlayer[ShipInt] = 3; } } MapStatePlayerReal = MapStatePlayer.ToList(); MapStateReal = MapState.ToList(); HitShipsReal = HitShips.ToList(); } }
public void Shoot(Lod Input) { if (Rotate != RotationState.Unset) { Input.ShipRotate(Rotate); } List <int> MapShipShoot = new List <int>(); TextToPlayer = "Používáš ostrou munici"; Kurzor = Input.pivot; int ShipMaxIndex = Input.ShipTiles.Count; int BadCount = 0; Position ShipTile = new Position(); int ShipInt; int KurzorInt = (Kurzor.PosX) + ((Kurzor.PosY) * MapSize); AbleToPlace = true; for (int i = 0; i < ShipMaxIndex; i++) { ShipTile = Input.ShipTiles[i]; ShipInt = (ShipTile.PosX + Kurzor.PosX) + ((ShipTile.PosY + Kurzor.PosY) * MapSize); if (ShipTile.PosX + Kurzor.PosX >= 0 && ShipTile.PosX + Kurzor.PosX <= MapSize - 1) { } else { TextToPlayer = "Zde nemůžeš střílet"; BadCount++; } if (ShipInt < MapMaxIndex && ShipInt >= 0)/*&& MapSize * (b - 1) <= ShipInt && MapSize * b >= ShipInt*/ { if (MapState[ShipInt] == 2 || MapState[ShipInt] == 0) { MapShipShoot.Add(ShipInt); } MapStatePlayer[ShipInt] = 3; } else { //not able place!!! TextToPlayer = "Zde nemůžeš střílet"; BadCount++; } } if (BadCount == 0 && Place == true) { MapStatePlayer = MapStatePlayerReal.ToList(); MapState = MapStateReal.ToList(); for (int i = 0; i < MapShipShoot.Count(); i++) { ShipInt = MapShipShoot[i]; if (MapStateReal[ShipInt] == 2) { MapState[ShipInt] = 4; MapStatePlayer[ShipInt] = 4; for (int d = 0; d < HitShips.Count; d++) { for (int g = 1; g < HitShips[d].Count; g++) { if (HitShips[d][g] == ShipInt) { HitShips[d][0]++; if (HitShips[d][0] == HitShips[d].Count - 1) { for (int f = 1; f < HitShips[d].Count; f++) { MapState[HitShips[d][f]] = 1; MapStatePlayer[HitShips[d][f]] = 1; } DestroyedShipsCount++; HitShips[d][0] = 9999999; } } } } } else if (MapStateReal[ShipInt] == 0) { MapStatePlayer[ShipInt] = 3; } } MapStatePlayerReal = MapStatePlayer.ToList(); MapStateReal = MapState.ToList(); HitShipsReal = HitShips.ToList(); } }
public void PlaceShip(Lod Input) { if (Rotate != RotationState.Unset) { Input.ShipRotate(Rotate); } TextToPlayer = "Pokládáš: " + Input.ShipType; List <Position> ValidShip = new List <Position>(); Kurzor = Input.pivot; int ShipMaxIndex = Input.ShipTiles.Count; int BadCount = 0; Position ShipTile = new Position(); int ShipInt; int KurzorInt = (Kurzor.PosX) + ((Kurzor.PosY) * MapSize); AbleToPlace = true; HitShips.Add(new List <int> { 0 }); for (int i = 0; i < ShipMaxIndex; i++) { ShipTile = Input.ShipTiles[i]; ShipInt = (ShipTile.PosX + Kurzor.PosX) + ((ShipTile.PosY + Kurzor.PosY) * MapSize); ValidShip.Add(new Position { PosX = ShipTile.PosX + Kurzor.PosX + 1, PosY = ShipTile.PosY + Kurzor.PosY }); ValidShip.Add(new Position { PosX = ShipTile.PosX + Kurzor.PosX - 1, PosY = ShipTile.PosY + Kurzor.PosY }); ValidShip.Add(new Position { PosX = ShipTile.PosX + Kurzor.PosX, PosY = ShipTile.PosY + Kurzor.PosY + 1 }); ValidShip.Add(new Position { PosX = ShipTile.PosX + Kurzor.PosX, PosY = ShipTile.PosY + Kurzor.PosY - 1 }); if (ShipTile.PosX + Kurzor.PosX >= 0 && ShipTile.PosX + Kurzor.PosX <= MapSize - 1) { } else { TextToPlayer = "Zde nelze položit lod"; BadCount++; } if (ShipInt < MapMaxIndex && ShipInt >= 0) /*&& MapSize * (b - 1) <= ShipInt && MapSize * b >= ShipInt*/ { if (MapState[ShipInt] != 0) { BadCount++; TextToPlayer = "Zde nelze polozit lod"; } MapState[ShipInt] = 2; HitShips[HitShipsIndex].Add(ShipInt); } else { //not able place!!! TextToPlayer = "Zde nelze polozit lod"; BadCount++; } } if (BadCount == 0 && Place == true) { int ShipValidInt; Position ShipValidTile = new Position(); for (int i = 0; i < ValidShip.Count; i++) { AbleToPlace = true; ShipValidTile = ValidShip[i]; ShipValidInt = (ShipValidTile.PosX) + ((ShipValidTile.PosY) * MapSize); if (ShipValidTile.PosX >= 0 && ShipValidTile.PosX <= MapSize - 1) { } else { AbleToPlace = false; } if (ShipValidInt < MapMaxIndex && ShipValidInt >= 0) { if (MapState[ShipValidInt] == 0 && AbleToPlace == true) { MapState[ShipValidInt] = 5; } } else { AbleToPlace = false; } } NumOFShips++; MapStateReal = MapState.ToList(); HitShipsReal = HitShips.ToList(); HitShipsIndex++; } }