private void ksdfj(object sender, MouseButtonEventArgs e) { AddShipButtonControl Target = sender as AddShipButtonControl; Target.Inventory--; Ship NewShip = new Ship(Target.NewVesselClass); NewShip.ShipOrientation = Orientation.Horizontal; playingField.Children.Add(NewShip); Point Spawn = playingField.GetSpawn(); PlayingField.SetElementPosition(NewShip, new Point((int)NewShip.Vessel, (int)NewShip.Vessel)); }
private void DragCanvasOverlay_Drag(object sender, MouseEventArgs e) { Ship TargetShip = sender as Ship; Rect ShipHitBox = GetHitBox(TargetShip, this); Rect TargetGridHitBox = GetHitBox(playingField, this); if (HitBoxOverlap(ShipHitBox, TargetGridHitBox)) { Rect DerivedHitbox = GetHitBox(TargetShip, playingField); Point TargetShipLoc = playingField.SnapInt(DerivedHitbox.Location); PlayingField.SetElementPosition(playingField.Children[0], TargetShipLoc); } }
private void PlaceShip(Point p, Ship s) { playingField.Children.Add(s); PlayingField.SetElementPosition(s, p); }
private void playingField_PositionChanged(object sender, MouseEventArgs e) { PlayingField P = sender as PlayingField; PlayingField.SetElementPosition(P.Children[0], P.CurrentGridPosition); }