Exemplo n.º 1
0
        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);
                }

            }
        }
Exemplo n.º 2
0
        public void ReDraw(GameField you, GameField enemy)
        {
            draw.DrawField(you, you.field, true);
                form.InvalidateYou();

                draw.DrawField(enemy, enemy.field, false);
                form.InvalidateEnemy();
        }
Exemplo n.º 3
0
 public CreateField(GameField field)
 {
     this.field = field;
 }
Exemplo n.º 4
0
 public StartGameMessage(GameField you, GameField enemy, bool turn)
 {
     this.you = you;
     this.enemy = enemy;
     this.turn = turn;
 }
Exemplo n.º 5
0
 public SearchMessage(GameField field)
 {
     this.field = field;
 }
Exemplo n.º 6
0
        public GameField GetForEnemy()
        {
            GameField res = new GameField();
            res.ships = this.ships.Select(x => x.GetForEnemy()).ToList();
            res.field = this.field;

            return res;
        }
Exemplo n.º 7
0
 public void ReDraw(GameField your, GameField enemy, bool turn)
 {
     actGame.ReDraw(your, enemy);
     Turn = turn;
 }