public void DrawField(GameField field, CellType[,] pt, bool isYours) { lock (lck) { Bitmap newBitmap = isYours ? TempBitmapYours : TempBitmapEnemy; Graphics g = Graphics.FromImage(newBitmap); using (g) { g.Clear(Color.White); g.DrawImage(grid, 0, 0); for (int i = 0; i < pt.GetLength(0); i++) { for (int j = 0; j < pt.GetLength(1); j++) { if (pt[i, j] == CellType.Point) g.FillEllipse(Brushes.Green, i * StructMap.BlockSize + 10, j * StructMap.BlockSize + 10, 10, 10); } } for (int i = 0; i < field.ships.Count; i++) { for (int j = 0; j < field.ships[i].palub.Count; j++) { if (field.ships[i].palub[j].type == DeckType.Live) { g.FillRectangle(Brushes.Red, field.ships[i].palub[j].point.X * StructMap.BlockSize + 1, field.ships[i].palub[j].point.Y * StructMap.BlockSize + 1, StructMap.BlockSize - 1, StructMap.BlockSize - 1); } else if (field.ships[i].palub[j].type == DeckType.Hurt) { g.FillRectangle(Brushes.Orange, field.ships[i].palub[j].point.X * StructMap.BlockSize + 1, field.ships[i].palub[j].point.Y * StructMap.BlockSize + 1, StructMap.BlockSize - 1, StructMap.BlockSize - 1); } else if (field.ships[i].palub[j].type == DeckType.Dead) { g.FillRectangle(Brushes.Black, field.ships[i].palub[j].point.X * StructMap.BlockSize + 1, field.ships[i].palub[j].point.Y * StructMap.BlockSize + 1, StructMap.BlockSize - 1, StructMap.BlockSize - 1); } } } } Graphics tmp = isYours ? Graphics.FromImage(MainBitmapYours) : Graphics.FromImage(MainBitmapEnemy); using (tmp) { tmp.Clear(Color.White); tmp.DrawImage(newBitmap, 0, 0); } } }
public void ReDraw(GameField you, GameField enemy) { draw.DrawField(you, you.field, true); form.InvalidateYou(); draw.DrawField(enemy, enemy.field, false); form.InvalidateEnemy(); }
public CreateField(GameField field) { this.field = field; }
public StartGameMessage(GameField you, GameField enemy, bool turn) { this.you = you; this.enemy = enemy; this.turn = turn; }
public SearchMessage(GameField field) { this.field = field; }
public GameField GetForEnemy() { GameField res = new GameField(); res.ships = this.ships.Select(x => x.GetForEnemy()).ToList(); res.field = this.field; return res; }
public void ReDraw(GameField your, GameField enemy, bool turn) { actGame.ReDraw(your, enemy); Turn = turn; }