/// <summary> /// Draws the player's grid and ships. /// </summary> /// <param name="grid">the grid to show</param> /// <param name="thePlayer">the player to show the ships of</param> /// <param name="small">true if the small grid is shown</param> /// <param name="showShips">true if ships are to be shown</param> /// <param name="left">the left side of the grid</param> /// <param name="top">the top of the grid</param> /// <param name="width">the width of the grid</param> /// <param name="height">the height of the grid</param> /// <param name="cellWidth">the width of each cell</param> /// <param name="cellHeight">the height of each cell</param> /// <param name="cellGap">the gap between the cells</param> private static void DrawCustomField(ISeaGrid grid, Player thePlayer, bool small, bool showShips, int left, int top, int width, int height, int cellWidth, int cellHeight, int cellGap) { // SwinGame.FillRectangle(Color.Blue, left, top, width, height) int rowTop; int colLeft; // Draw the grid for (int row = 0; row <= 9; row++) { rowTop = top + (cellGap + cellHeight) * row; for (int col = 0; col <= 9; col++) { colLeft = left + (cellGap + cellWidth) * col; Color fillColor = default(Color); bool draw; draw = true; switch (grid.Item(row, col)) { case TileView.Ship: { draw = false; break; } case TileView.Miss: { if (small) { fillColor = SMALL_MISS; } else { fillColor = LARGE_MISS; } break; } case TileView.Hit: { if (small) { fillColor = SMALL_HIT; } else { fillColor = LARGE_HIT; } break; } case TileView.Sea: { if (small) { fillColor = SMALL_SEA; } else { draw = false; } break; } } if (draw) { SwinGame.FillRectangle(fillColor, colLeft, rowTop, cellWidth, cellHeight); if (!small) { SwinGame.DrawRectangle(OUTLINE_COLOR, colLeft, rowTop, cellWidth, cellHeight); } } } } if (!showShips) { return; } int shipHeight, shipWidth; string shipName; // Draw the ships foreach (Ship s in thePlayer) { if (s == null || !s.IsDeployed) { continue; } rowTop = top + (cellGap + cellHeight) * s.Row + SHIP_GAP; colLeft = left + (cellGap + cellWidth) * s.Column + SHIP_GAP; if (s.Direction == Direction.LeftRight) { shipName = "ShipLR" + s.Size; shipHeight = cellHeight - (SHIP_GAP * 2); shipWidth = (cellWidth + cellGap) * s.Size - (SHIP_GAP * 2) - cellGap; } else { // Up down shipName = "ShipUD" + s.Size; shipHeight = (cellHeight + cellGap) * s.Size - (SHIP_GAP * 2) - cellGap; shipWidth = cellWidth - (SHIP_GAP * 2); } if (!small) { SwinGame.DrawBitmap(GameResources.GameImage(shipName), colLeft, rowTop); } else { SwinGame.FillRectangle(SHIP_FILL_COLOR, colLeft, rowTop, shipWidth, shipHeight); SwinGame.DrawRectangle(SHIP_OUTLINE_COLOR, colLeft, rowTop, shipWidth, shipHeight); } } }
// '' <summary> // '' Draws the player's grid and ships. // '' </summary> // '' <param name="grid">the grid to show</param> // '' <param name="thePlayer">the player to show the ships of</param> // '' <param name="small">true if the small grid is shown</param> // '' <param name="showShips">true if ships are to be shown</param> // '' <param name="left">the left side of the grid</param> // '' <param name="top">the top of the grid</param> // '' <param name="width">the width of the grid</param> // '' <param name="height">the height of the grid</param> // '' <param name="cellWidth">the width of each cell</param> // '' <param name="cellHeight">the height of each cell</param> // '' <param name="cellGap">the gap between the cells</param> private static void DrawCustomField(ISeaGrid grid, Player thePlayer, bool small, bool showShips, int left, int top, int width, int height, int cellWidth, int cellHeight, int cellGap) { // SwinGame.FillRectangle(Color.Blue, left, top, width, height) int rowTop; int colLeft; // Draw the grid for (int row = 0; (row <= 9); row++) { rowTop = (top + ((cellGap + cellHeight) * row)); for (int col = 0; (col <= 9); col++) { colLeft = (left + ((cellGap + cellWidth) * col)); Color fillColor = Color.Gold; bool draw; draw = true; switch (grid.Item(row, col)) { case TileView.Ship: draw = false; break; case TileView.Miss: if (small) { fillColor = SMALL_MISS; } else { fillColor = LARGE_MISS; } break; case TileView.Hit: if (small) { fillColor = SMALL_HIT; } else { fillColor = LARGE_HIT; } break; case TileView.Sea: if (small) { fillColor = SMALL_SEA; } else { draw = false; } break; } if (draw) { SwinGame.FillRectangle(fillColor, colLeft, rowTop, cellWidth, cellHeight); if (!small) { SwinGame.DrawRectangle(OUTLINE_COLOR, colLeft, rowTop, cellWidth, cellHeight); } } } } if (!showShips) { return; } int shipHeight; int shipWidth; string shipName; // Draw the ships foreach (Ship s in thePlayer) { if (((s == null) || !s.IsDeployed)) { // TODO: Continue For... Warning!!! not translated } rowTop = (top + (((cellGap + cellHeight) * s.Row) + SHIP_GAP)); colLeft = (left + (((cellGap + cellWidth) * s.Column) + SHIP_GAP)); if ((s.Direction == Direction.LeftRight)) { shipName = ("ShipLR" + s.Size); shipHeight = (cellHeight - (SHIP_GAP * 2)); shipWidth = (((cellWidth + cellGap) * s.Size) - ((SHIP_GAP * 2) - cellGap)); } else { // Up down shipName = ("ShipUD" + s.Size); shipHeight = (((cellHeight + cellGap) * s.Size) - ((SHIP_GAP * 2) - cellGap)); shipWidth = (cellWidth - (SHIP_GAP * 2)); } if (!small) { SwinGame.DrawBitmap(GameResources.GameImage(shipName), colLeft, rowTop); } else { SwinGame.FillRectangle(SHIP_FILL_COLOR, colLeft, rowTop, shipWidth, shipHeight); SwinGame.DrawRectangle(SHIP_OUTLINE_COLOR, colLeft, rowTop, shipWidth, shipHeight); } } }
/// <summary> /// Draws the player's grid and ships. /// </summary> /// <param name="grid">the grid to show</param> /// <param name="thePlayer">the player to show the ships of</param> /// <param name="small">true if the small grid is shown</param> /// <param name="showShips">true if ships are to be shown</param> /// <param name="left">the left side of the grid</param> /// <param name="top">the top of the grid</param> /// <param name="width">the width of the grid</param> /// <param name="height">the height of the grid</param> /// <param name="cellWidth">the width of each cell</param> /// <param name="cellHeight">the height of each cell</param> /// <param name="cellGap">the gap between the cells</param> private static void DrawCustomField(ISeaGrid grid, Player thePlayer, bool small, bool showShips, int left, int top, int width, int height, int cellWidth, int cellHeight, int cellGap) { //SwinGame.FillRectangle(Color.Blue, left, top, width, height) int rowTop = 0; int colLeft = 0; //Draw the grid for (int row = 0; row <= 9; row++) { rowTop = top + (cellGap + cellHeight) * row; for (int col = 0; col <= 9; col++) { colLeft = left + (cellGap + cellWidth) * col; Color fillColor = default(Color); if (small) fillColor = SMALL_SHIP; else fillColor = LARGE_SHIP; bool draw = false; draw = true; switch (grid.Item(row, col)) { case TileView.Ship: draw = false; break; case TileView.Miss: if (small) fillColor = SMALL_MISS; else fillColor = LARGE_MISS; break; case TileView.Hit: if (small) fillColor = SMALL_HIT; else fillColor = LARGE_HIT; break; case TileView.Sea: if (small) fillColor = SMALL_SEA; else draw = false; break; } if (draw) { SwinGame.FillRectangle(fillColor, colLeft, rowTop, cellWidth, cellHeight); if (!small) { SwinGame.DrawRectangle(OUTLINE_COLOR, colLeft, rowTop, cellWidth, cellHeight); } } } } if (!showShips) { return; } int shipHeight = 0; int shipWidth = 0; string shipName = null; //Draw the ships foreach (Ship s in thePlayer) { if (s == null || !s.IsDeployed) continue; rowTop = top + (cellGap + cellHeight) * s.Row + SHIP_GAP; colLeft = left + (cellGap + cellWidth) * s.Column + SHIP_GAP; if (s.Direction == Direction.LeftRight) { shipName = "ShipLR" + s.Size; shipHeight = cellHeight - (SHIP_GAP * 2); shipWidth = (cellWidth + cellGap) * s.Size - (SHIP_GAP * 2) - cellGap; } else { //Up down shipName = "ShipUD" + s.Size; shipHeight = (cellHeight + cellGap) * s.Size - (SHIP_GAP * 2) - cellGap; shipWidth = cellWidth - (SHIP_GAP * 2); } if (!small) { SwinGame.DrawBitmap(GameResources.GameImage(shipName), colLeft, rowTop); } else { SwinGame.FillRectangle(SHIP_FILL_COLOR, colLeft, rowTop, shipWidth, shipHeight); SwinGame.DrawRectangle(SHIP_OUTLINE_COLOR, colLeft, rowTop, shipWidth, shipHeight); } } }
/// <summary> /// Draws the player's grid and ships. /// </summary> /// <param name="grid">the grid to show</param> /// <param name="thePlayer">the player to show the ships of</param> /// <param name="small">true if the small grid is shown</param> /// <param name="showShips">true if ships are to be shown</param> /// <param name="left">the left side of the grid</param> /// <param name="top">the top of the grid</param> /// <param name="width">the width of the grid</param> /// <param name="height">the height of the grid</param> /// <param name="cellWidth">the width of each cell</param> /// <param name="cellHeight">the height of each cell</param> /// <param name="cellGap">the gap between the cells</param> private static void DrawCustomField(ISeaGrid grid, Player thePlayer, bool small, bool showShips, int left, int top, int width, int height, int cellWidth, int cellHeight, int cellGap) { // SwinGame.FillRectangle(Color.Blue, left, top, width, height) int rowTop; int colLeft; // Draw the grid for (int row = 0; row <= 9; row++) { rowTop = top + (cellGap + cellHeight) * row; for (int column = 0; column <= 9; column++) { colLeft = left + (cellGap + cellWidth) * column; Color fillColor; bool draw; draw = true; switch (grid.Item(row, column)) { case object _ when TileView.Ship: { draw = false; break; } case object _ when TileView.Miss: { if (small) { fillColor = Small_Miss; } else { fillColor = Large_Miss; } break; } case object _ when TileView.Hit: { if (small) { fillColor = Small_Hit; } else { fillColor = Large_Hit; } break; } case object _ when TileView.Sea: case object _ when TileView.Ship: { if (small) { fillColor = Small_Sea; } else { draw = false; } break; } } if (draw) { SwinGame.FillRectangle(fillColor, colLeft, rowTop, cellWidth, cellHeight); if (!small) { SwinGame.DrawRectangle(Outline_Colour, colLeft, rowTop, cellWidth, cellHeight); } } } } if (!showShips) { return; } int shipHeight, shipWidth; string shipName; // Draw the ships foreach (Ship s in thePlayer) { if (s == null || !s.IsDeployed) { continue; } rowTop = top + (cellGap + cellHeight) * s.Row + Ship_Gap; colLeft = left + (cellGap + cellWidth) * s.Column + Ship_Gap; if (s.Direction == Direction.LeftRight) { shipName = "ShipLR" + s.Size; shipHeight = cellHeight - (Ship_Gap * 2); shipWidth = (cellWidth + cellGap) * s.Size - (Ship_Gap * 2) - cellGap; } else { // Up down shipName = "ShipUD" + s.Size; shipHeight = (cellHeight + cellGap) * s.Size - (Ship_Gap * 2) - cellGap; shipWidth = cellWidth - (Ship_Gap * 2); } if (!small) { SwinGame.DrawBitmap(GameImage(shipName), colLeft, rowTop); } else { SwinGame.FillRectangle(Ship_Fill_Colour, colLeft, rowTop, shipWidth, shipHeight); SwinGame.DrawRectangle(Ship_Outline_Colour, colLeft, rowTop, shipWidth, shipHeight); } } }