public void SetCell(WinMode WinMode) { GameField Game = ((App)(Application.Current)).Game; int CellSize = Game.CellSize; FillFieldItem.Width = CellSize; FillFieldItem.Height = CellSize; FillFieldItem.Opacity = 0.5; switch (WinMode) { case WinMode.Player1: FillFieldItem.Fill = Brushes.Blue; break; case WinMode.Player2: FillFieldItem.Fill = Brushes.Green; break; case WinMode.Computer: FillFieldItem.Fill = Brushes.Red; break; case WinMode.None: FillFieldItem.Fill = Brushes.Transparent; break; } Canvas.SetLeft(FillFieldItem, x * CellSize); Canvas.SetTop(FillFieldItem, y * CellSize); this.WinMode = WinMode; //Game.UpdateWinStatus(WinMode); Game.UpdateWinStatus(true); }
public bool CheckWinCells() { GameField Game = ((App)(Application.Current)).Game; bool f = false; GameCell Cell1, Cell2; WinMode Win = WinMode.None; Cell1 = Game.fileldArray[x + 1, y]; Cell2 = Game.fileldArray[x, y + 1]; switch (Game.PlayerMode) { case PlayerMode.Player1: Win = WinMode.Player1; break; case PlayerMode.Player2: Win = WinMode.Player2; break; case PlayerMode.Computer: Win = WinMode.Computer; break; } if (WinMode == WinMode.None && Horizontal != CellMode.Empty && Vertical != CellMode.Empty && Cell1.Vertical != CellMode.Empty && Cell2.Horizontal != CellMode.Empty) { SetCell(Win); f = true; } if (y > 0) { Cell1 = Game.fileldArray[x, y - 1]; Cell2 = Game.fileldArray[x + 1, y - 1]; if (Cell1.WinMode == WinMode.None && Horizontal != CellMode.Empty && Cell1.Horizontal != CellMode.Empty && Cell1.Vertical != CellMode.Empty && Cell2.Vertical != CellMode.Empty) { Cell1.SetCell(Win); f = true; } } if (x > 0) { Cell1 = Game.fileldArray[x - 1, y]; Cell2 = Game.fileldArray[x - 1, y + 1]; if (Cell1.WinMode == WinMode.None && Vertical != CellMode.Empty && Cell1.Horizontal != CellMode.Empty && Cell1.Vertical != CellMode.Empty && Cell2.Horizontal != CellMode.Empty) { Cell1.SetCell(Win); f = true; } } return(f); }
public GameCell(int x, int y, CellMode Horizontal, CellMode Vertical, WinMode WinMode) { this.x = x; this.y = y; Canvas FieldCanvas = ((MainWindow)(App.Current.MainWindow)).GameFieldCanvas; FieldItem = new Line(); FieldCanvas.Children.Add(FieldItem); HorizontalFieldItem = new Line(); FieldCanvas.Children.Add(HorizontalFieldItem); VerticalFieldItem = new Line(); FieldCanvas.Children.Add(VerticalFieldItem); FillFieldItem = new Rectangle(); FieldCanvas.Children.Add(FillFieldItem); SetCell(Horizontal, Vertical); }
public CellSave(CellMode Horizontal, CellMode Vertical, WinMode WinMode) { this.Horizontal = Horizontal; this.Vertical = Vertical; this.WinMode = WinMode; }