protected virtual void OnShipChanged(ShipPlayer previousShip, ShipPlayer newShip) { if (this.ShipChanged != null) { this.ShipChanged(this, new ShipChangedArgs(previousShip, newShip)); } }
private readonly double _tangent = Math.Tan(Math1D.DegreesToRadians(45 / 2)); // camera's field of view is 45, half of that is a right triangle //TODO: If this stays being used, get constants from CameraHelper private void ShowCameraView() { Transform transform = GetMapToCanvasTransform(); ShipPlayer ship = _map.GetItems <ShipPlayer>(false).First(); Point3D position = ship.PositionWorld; Point positionView = transform.Transform(new Point(position.X, -position.Y)); position = new Point3D(position.X, -position.Y, 0); double cameraZ = 30 * ship.Radius; // multiply by radius so that bigger ships see more //tan(theta)=rise/run //rise=tan(theta)*run double halfWidth = _tangent * cameraZ; DrawBox(position, halfWidth, new SolidColorBrush(UtilityWPF.ColorFromHex("70EEEEEE")), transform); // These are for the stars //double starMin = _boundryMin.Z * 20; //double starMax = _boundryMin.Z * 1.5; //halfWidth = _tangent * (cameraZ + Math.Abs(starMax)); //DrawBox(position, halfWidth, Brushes.Orange, transform); //halfWidth = _tangent * (cameraZ + Math.Abs(starMin)); //DrawBox(position, halfWidth, Brushes.Orange, transform); }
/// <summary> /// This creates a new ship and puts syncronizes part /// </summary> public bool ShipEdited() { ShipDNA newDNA = GetDNAFromEditor(_editor); ShipPlayer newShip = null; try { // Create the new ship newShip = ShipPlayer.GetNewShip(newDNA, _world, _material_Ship, _map, _shipExtra); } catch (Exception ex) { return(false); } TransferContainers(_player.Ship, newShip); List <ShipPartDNA> unaccountedParts = newDNA.PartsByLayer. SelectMany(o => o.Value). ToList(); Cargo[] remainder = TransferCargo(_player.Ship, newShip, unaccountedParts); RedistributeParts(remainder, unaccountedParts); newShip.RecalculateMass(); SwapShip(_player, newShip); return(true); }
private static void SwapShip(Player player, ShipPlayer newShip) { Point3D position = player.Ship.PositionWorld; player.Ship = null; newShip.PhysicsBody.Position = position; newShip.PhysicsBody.Velocity = new Vector3D(0, 0, 0); newShip.PhysicsBody.AngularVelocity = new Vector3D(0, 0, 0); player.Ship = newShip; }
public ShipChangedArgs(ShipPlayer previousShip, ShipPlayer newShip) { this.PreviousShip = previousShip; this.NewShip = newShip; }