private void Rectangle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Keyboard.Focus(Gridd); TopLabel.Content = "You can rotate the ship by pressing: R"; Logger.Log("dragging true..."); _dragging = true; var pos = new Vector(Grid.GetColumn((Rectangle)sender), Grid.GetRow((Rectangle)sender)); for (int i = 0; i < 5; i++) { foreach (Model.Data.Vector v in _ships[i].Coordinates) { if (v == pos) { _draggedShip = _ships[i]; _lastPosition = pos; _difference = _ships[i].Coordinates[0] - pos; _lastIsHorizontal = _ships[i].IsHorizontal; return; } } } Logger.Log("Ship not found!!!"); _draggedShip = null; }
private void MainGridRect_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Logger.Log($"you clicked {((Grid)((Rectangle)sender).Parent).Name}"); var pos = new Model.Data.Vector(Grid.GetColumn((Rectangle)sender), Grid.GetRow((Rectangle)sender)); if (_canInteract && (_game.GetTheOtherPlayer().GetTerritory()[pos.X, pos.Y] == 0)) { _canInteract = false; _game.GetCurrentPlayer().AimAt(pos); _game.Next(); } }