private void PointGrid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (_currentPoint == null)
return;
int x = (int)e.GetPosition(PointGrid).X;
int y = (int)e.GetPosition(PointGrid).Y;
if (x < _currentPoint.X || x > _currentPoint.X + MyPoint.WIDTH ||
y < _currentPoint.Y || y > _currentPoint.Y + MyPoint.HEIGHT ||
!_game.JumpToCell(x, y, _currentPoint))
{
Cell tmp = _currentPoint.CurrentCell;
_currentPoint.SetNewLocation(tmp.X, tmp.Y);
}
ShowState();
if (_game.FreeCellsAmount == 0)
MessageBox.Show(String.Format("Game over! The winner is {0}", _game.DarkCount < _game.LightCount ? "Red team" : "Green team"));
else
if (_game.IsLocked)
{
int lightCount = _game.LightCount + (_game.IsLightTurn ? 0 : _game.FreeCellsAmount);
int darkCount = _game.DarkCount + (_game.IsLightTurn ? _game.FreeCellsAmount : 0);
MessageBox.Show(String.Format("Game over! The winner is: {0}", (lightCount > darkCount) ? "Red team" : "Green team"));
}
_currentPoint.SetToBack();
_currentPoint = null;
}