public bool AddToGridCell(Vector gridCoordinates) { GridCellState gridCellState = (GridCellState)board[gridCoordinates]; bool canAdd = IsGridCellEmpty(gridCoordinates); if (canAdd) { Image imgGridCell = new Image(); BitmapImage imgSource = DetermineImageAndUpdateState(gridCoordinates); Grid.SetColumn(imgGridCell, (int)gridCoordinates.X); Grid.SetRow(imgGridCell, (int)gridCoordinates.Y); imgGridCell.Source = imgSource; boardGrid.Children.Add(imgGridCell); currentTurn++; if (currentTurn >= 5) { DetermineIfGameOver(gridCoordinates); } } return(canAdd); }
public void PreviewResult(Vector gridCoordinates) { GridCellState gridCellState = (GridCellState)board[gridCoordinates]; bool canAdd = IsGridCellEmpty(gridCoordinates); if (canAdd) { Image imgGridCell = new Image(); BitmapImage imgSource = DetermineImage(gridCoordinates); Grid.SetColumn(imgGridCell, (int)gridCoordinates.X); Grid.SetRow(imgGridCell, (int)gridCoordinates.Y); imgGridCell.Source = imgSource; boardGrid.Children.Add(imgGridCell); var timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(250) }; timer.Start(); timer.Tick += (sender, args) => { timer.Stop(); boardGrid.Children.Remove(imgGridCell); }; } }
public bool IsGridCellX(Vector gridCoordinates) { bool isX; GridCellState gridCellState = (GridCellState)board[gridCoordinates]; if (gridCellState == GridCellState.X) { isX = true; } else { isX = false; } return(isX); }
public bool IsGridCellO(Vector gridCoordinates) { bool isO; GridCellState gridCellState = (GridCellState)board[gridCoordinates]; if (gridCellState == GridCellState.O) { isO = true; } else { isO = false; } return(isO); }
public bool IsGridCellEmpty(Vector gridCoordinates) { bool isEmpty; GridCellState gridCellState = (GridCellState)board[gridCoordinates]; if (gridCellState == GridCellState.Empty) { isEmpty = true; } else { isEmpty = false; } return(isEmpty); }