private void CreateShip(int[] len) { Random r = new Random(); int countShip = len.Length; int countCreate = 0; while (countCreate < countShip) { int x = r.Next(10); int y = r.Next(10); ShipType pos = (r.Next(2) == 1) ? ShipType.HORIZONTAL : ShipType.VERTICAL; Ship ship = FabricShips.GetShip(len[countCreate], pos, x, y); if (x + ship.Size < Field.Width && y + ship.Size < Field.Height) { bool result = PushShip(ship); if (result) { ++countCreate; } } } }
public void OnReleased(MouseReleasedEvent e) { dragging = false; if (Collisions.CheckCollisions(game.RPlayer.MapDimension, NewDimension)) { int TestX = NewDimension.X; int TestY = NewDimension.Y; RenderInfo.CalculateCoord(ref TestX, ref TestY, game.RPlayer); ship = FabricShips.GetShip(LenghtShips[currentPointer], shipType, TestX, TestY); bool NextShip = game.Player.PushShip(ship); if (NextShip) { ++currentPointer; if (currentPointer > 9) { NextState(game.WarState); } else { ResizeShip(); } } } else { RelocationShip(); } }