private async void btnShipChallenge2_Click(object sender, RoutedEventArgs e) { try { EnsureWorldStarted(); ClearCurrent(); List<ShipPartDNA> parts = new List<ShipPartDNA>(); parts.Add(new ShipPartDNA() { PartType = FuelTank.PARTTYPE, Position = new Point3D(0.611527511599856, 0, 0.0153375982352619), Orientation = new Quaternion(0, -0.706493084706277, 0, 0.707719945502605), Scale = new Vector3D(4.70545346938791, 4.70545346938791, 1.04748080326409) }); parts.Add(new ThrusterDNA() { PartType = Thruster.PARTTYPE, Position = new Point3D(-1.48216852903668, 0, 0), Orientation = Quaternion.Identity, Scale = new Vector3D(1.65021551755816, 1.65021551755816, 1.65021551755816), ThrusterDirections = ThrusterDesign.GetThrusterDirections(ThrusterType.Two), ThrusterType = ThrusterType.Two }); parts.Add(new ThrusterDNA() { PartType = Thruster.PARTTYPE, Position = new Point3D(-2.60730396412872, 1.18811621237628, -0.0147591913688635), Orientation = new Quaternion(0, 0, -0.846976393198269, 0.531630500784946), Scale = new Vector3D(0.71390056433019, 0.71390056433019, 0.71390056433019), ThrusterDirections = ThrusterDesign.GetThrusterDirections(ThrusterType.Two_Two_One), ThrusterType = ThrusterType.Two_Two_One }); parts.Add(new ThrusterDNA() { PartType = Thruster.PARTTYPE, Position = new Point3D(-2.60721450068017, -1.18828382189838, -0.0147591913688617), Orientation = new Quaternion(0, 0, -0.496864090131338, 0.867828367788216), Scale = new Vector3D(0.71390056433019, 0.71390056433019, 0.71390056433019), ThrusterDirections = ThrusterDesign.GetThrusterDirections(ThrusterType.Two_Two_One), ThrusterType = ThrusterType.Two_Two_One }); ShipDNA shipDNA = ShipDNA.Create(parts); ShipCoreArgs core = new ShipCoreArgs() { Map = _map, Material_Ship = _material_Bot, World = _world, }; ShipExtraArgs extra = new ShipExtraArgs() { Options = _editorOptions, ItemOptions = _itemOptions, Material_Projectile = _material_Bot, Radiation = _radiation, Gravity = _gravity, RunNeural = false, RepairPartPositions = false, }; //Ship ship = await Ship.GetNewShipAsync(shipDNA, _world, _material_Bot, _map, extra); Bot bot = new Bot(BotConstructor.ConstructBot(shipDNA, core, extra)); ClearCurrent(); _shipDNA = shipDNA; _bot = bot; _bot.PhysicsBody.ApplyForceAndTorque += new EventHandler<BodyApplyForceAndTorqueArgs>(Ship_ApplyForceAndTorque); _thrustController = new ThrustController(_bot, _viewport, _itemOptions); //double mass = _ship.PhysicsBody.Mass; _bot.Fuel.QuantityCurrent = _bot.Fuel.QuantityMax; _bot.RecalculateMass(); _thrustController.MassChanged(chkShipSimple.IsChecked.Value); if (chkShipDebugVisuals.IsChecked.Value) { _thrustController.DrawDebugVisuals_Pre(); } //mass = _ship.PhysicsBody.Mass; _map.AddItem(_bot); grdViewPort.Focus(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error); } }
private async void btnLoadShip_Click(object sender, RoutedEventArgs e) { try { string errMsg; ShipDNA shipDNA = ShipEditorWindow.LoadShip(out errMsg); if (shipDNA == null) { if (!string.IsNullOrEmpty(errMsg)) { MessageBox.Show(errMsg, this.Title, MessageBoxButton.OK, MessageBoxImage.Warning); } return; } EnsureWorldStarted(); ShipCoreArgs core = new ShipCoreArgs() { Map = _map, Material_Ship = _material_Bot, World = _world, }; ShipExtraArgs extra = new ShipExtraArgs() { Options = _editorOptions, ItemOptions = _itemOptions, Material_Projectile = _material_Bot, Radiation = _radiation, Gravity = _gravity, RunNeural = false, RepairPartPositions = chkLoadRepairPositions.IsChecked.Value, }; //Ship ship = await Ship.GetNewShipAsync(shipDNA, _world, _material_Bot, _map, extra); Bot bot = new Bot(BotConstructor.ConstructBot(shipDNA, core, extra)); ClearCurrent(); _shipDNA = shipDNA; _bot = bot; _bot.PhysicsBody.ApplyForceAndTorque += new EventHandler<BodyApplyForceAndTorqueArgs>(Ship_ApplyForceAndTorque); _thrustController = new ThrustController(_bot, _viewport, _itemOptions); if (_bot.Fuel != null) { _bot.Fuel.QuantityCurrent = _bot.Fuel.QuantityMax; } _bot.RecalculateMass(); _thrustController.MassChanged(chkShipSimple.IsChecked.Value); if (chkShipDebugVisuals.IsChecked.Value) { _thrustController.DrawDebugVisuals_Pre(); } _map.AddItem(_bot); grdViewPort.Focus(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error); } }
private async void btnShipWackyFlyer_Click(object sender, RoutedEventArgs e) { try { EnsureWorldStarted(); ClearCurrent(); List<ShipPartDNA> parts = new List<ShipPartDNA>(); parts.Add(new ShipPartDNA() { PartType = FuelTank.PARTTYPE, Position = new Point3D(0, 0, 0), Orientation = Quaternion.Identity, Scale = new Vector3D(3, 3, 1) }); ThrusterType thrustType = UtilityCore.GetRandomEnum<ThrusterType>(ThrusterType.Custom); parts.Add(new ThrusterDNA() { PartType = Thruster.PARTTYPE, Position = new Point3D(1, 0, 0), Orientation = Math3D.GetRandomRotation(), Scale = new Vector3D(.5d, .5d, .5d), ThrusterDirections = ThrusterDesign.GetThrusterDirections(thrustType), ThrusterType = thrustType }); thrustType = UtilityCore.GetRandomEnum<ThrusterType>(ThrusterType.Custom); parts.Add(new ThrusterDNA() { PartType = Thruster.PARTTYPE, Position = new Point3D(-1, 0, 0), Orientation = Math3D.GetRandomRotation(), Scale = new Vector3D(.5d, .5d, .5d), ThrusterDirections = ThrusterDesign.GetThrusterDirections(thrustType), ThrusterType = thrustType }); thrustType = UtilityCore.GetRandomEnum<ThrusterType>(ThrusterType.Custom); parts.Add(new ThrusterDNA() { PartType = Thruster.PARTTYPE, Position = new Point3D(0, 1, 0), Orientation = Math3D.GetRandomRotation(), Scale = new Vector3D(.5d, .5d, .5d), ThrusterDirections = ThrusterDesign.GetThrusterDirections(thrustType), ThrusterType = thrustType }); thrustType = UtilityCore.GetRandomEnum<ThrusterType>(ThrusterType.Custom); parts.Add(new ThrusterDNA() { PartType = Thruster.PARTTYPE, Position = new Point3D(0, -1, 0), Orientation = Math3D.GetRandomRotation(), Scale = new Vector3D(.5d, .5d, .5d), ThrusterDirections = ThrusterDesign.GetThrusterDirections(thrustType), ThrusterType = thrustType }); ShipDNA shipDNA = ShipDNA.Create(parts); ShipCoreArgs core = new ShipCoreArgs() { Map = _map, Material_Ship = _material_Bot, World = _world, }; ShipExtraArgs extra = new ShipExtraArgs() { Options = _editorOptions, ItemOptions = _itemOptions, Material_Projectile = _material_Bot, Radiation = _radiation, Gravity = _gravity, RunNeural = false, RepairPartPositions = false, }; //Ship ship = await Ship.GetNewShipAsync(shipDNA, _world, _material_Bot, _map, extra); Bot bot = new Bot(BotConstructor.ConstructBot(shipDNA, core, extra)); ClearCurrent(); _shipDNA = shipDNA; _bot = bot; _bot.PhysicsBody.ApplyForceAndTorque += new EventHandler<BodyApplyForceAndTorqueArgs>(Ship_ApplyForceAndTorque); _thrustController = new ThrustController(_bot, _viewport, _itemOptions); //double mass = _ship.PhysicsBody.Mass; _bot.Fuel.QuantityCurrent = _bot.Fuel.QuantityMax; _bot.RecalculateMass(); _thrustController.MassChanged(chkShipSimple.IsChecked.Value); if (chkShipDebugVisuals.IsChecked.Value) { _thrustController.DrawDebugVisuals_Pre(); } //mass = _ship.PhysicsBody.Mass; _map.AddItem(_bot); grdViewPort.Focus(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error); } }