本文整理汇总了C#中Connection.SpaceCenter方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.SpaceCenter方法的具体用法?C# Connection.SpaceCenter怎么用?C# Connection.SpaceCenter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection.SpaceCenter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main () {
var connection = new Connection (name: "Kerbal Alarm Clock Example");
var kac = connection.KerbalAlarmClock ();
var alarm = kac.CreateAlarm (AlarmType.Raw, "My New Alarm", connection.SpaceCenter ().UT + 10);
alarm.Notes = "10 seconds have now passed since the alarm was created.";
alarm.Action = AlarmAction.MessageOnly;
}
示例2: Main
public static void Main ()
{
var conn = new Connection ();
var vessel = conn.SpaceCenter ().ActiveVessel;
var part = vessel.Parts.WithTitle ("Clamp-O-Tron Docking Port") [0];
vessel.Parts.Controlling = part;
}
示例3: Main
public static void Main ()
{
var connection = new Connection ();
var vessel = connection.SpaceCenter ().ActiveVessel;
foreach (var parachute in vessel.Parts.Parachutes)
parachute.Deploy ();
}
示例4: Main
public static void Main () {
var connection = new Connection ();
var spaceCenter = connection.SpaceCenter ();
var vessel = spaceCenter.ActiveVessel;
Tuple<double,double,double,double> q = vessel.Flight ().Rotation;
Console.WriteLine (q.Item1 + "," + q.Item2 + "," + q.Item3 + "," + q.Item4);
}
示例5: Main
public static void Main ()
{
var connection = new Connection (name : "Vessel Name");
var spaceCenter = connection.SpaceCenter ();
var vessel = spaceCenter.ActiveVessel;
System.Console.WriteLine (vessel.Name);
}
示例6: Main
public static void Main ()
{
var conn = new Connection ("Angle of attack");
var vessel = conn.SpaceCenter ().ActiveVessel;
while (true) {
var d = vessel.Direction (vessel.Orbit.Body.ReferenceFrame);
var v = vessel.Velocity (vessel.Orbit.Body.ReferenceFrame);
// Compute the dot product of d and v
var dotProd = d.Item1 * v.Item1 + d.Item2 * v.Item2 + d.Item3 * v.Item3;
// Compute the magnitude of v
var vMag = Math.Sqrt (v.Item1 * v.Item1 + v.Item2 * v.Item2 + v.Item3 * v.Item3);
// Note: don't need to magnitude of d as it is a unit vector
// Compute the angle between the vectors
double angle = 0;
if (dotProd > 0)
angle = Math.Abs (Math.Acos (dotProd / vMag) * (180.0 / Math.PI));
Console.WriteLine ("Angle of attack = " + Math.Round (angle, 2) + " degrees");
System.Threading.Thread.Sleep (1000);
}
}
示例7: Main
public static void Main ()
{
var connection = new Connection ();
var vessel = connection.SpaceCenter ().ActiveVessel;
Tuple<double,double,double> v = vessel.Flight ().Prograde;
Console.WriteLine (v.Item1 + "," + v.Item2 + "," + v.Item3);
}
示例8: Main
public static void Main () {
var connection = new Connection ();
var spaceCenter = connection.SpaceCenter ();
var vessel = spaceCenter.ActiveVessel;
var refframe = vessel.Orbit.Body.ReferenceFrame;
while (true)
Console.Out.WriteLine(vessel.Position(refframe));
}
示例9: Main
public static void Main ()
{
var conn = new Connection ("Angle of attack");
var vessel = conn.SpaceCenter ().ActiveVessel;
while (true) {
var vesselDirection = vessel.Direction (vessel.SurfaceReferenceFrame);
// Get the direction of the vessel in the horizon plane
var horizonDirection = new Vector3 (0, vesselDirection.Item2, vesselDirection.Item3);
// Compute the pitch - the angle between the vessels direction and the direction in the horizon plane
double pitch = AngleBetweenVectors (vesselDirection, horizonDirection);
if (vesselDirection.Item1 < 0)
pitch = -pitch;
// Compute the heading - the angle between north and the direction in the horizon plane
var north = new Vector3 (0, 1, 0);
double heading = AngleBetweenVectors (north, horizonDirection);
if (horizonDirection.Item3 < 0)
heading = 360 - heading;
// Compute the roll
// Compute the plane running through the vessels direction and the upwards direction
var up = new Vector3 (1, 0, 0);
var planeNormal = CrossProduct (vesselDirection, up);
// Compute the upwards direction of the vessel
var vesselUp = conn.SpaceCenter ().TransformDirection (
new Vector3 (0, 0, -1), vessel.ReferenceFrame, vessel.SurfaceReferenceFrame);
// Compute the angle between the upwards direction of the vessel and the plane normal
double roll = AngleBetweenVectors (vesselUp, planeNormal);
// Adjust so that the angle is between -180 and 180 and
// rolling right is +ve and left is -ve
if (vesselUp.Item1 > 0)
roll *= -1;
else if (roll < 0)
roll += 180;
else
roll -= 180;
Console.WriteLine ("pitch = " + pitch + ", heading = " + heading + ", roll = " + roll);
System.Threading.Thread.Sleep (1000);
}
}
示例10: Main
public static void Main ()
{
var connection = new Connection (name : "Surface prograde");
var vessel = connection.SpaceCenter ().ActiveVessel;
var ap = vessel.AutoPilot;
ap.ReferenceFrame = vessel.SurfaceVelocityReferenceFrame;
ap.TargetDirection = new Tuple<double,double,double> (0, 1, 0);
ap.Engage ();
ap.Wait ();
ap.Disengage ();
}
示例11: Main
public static void Main () {
var connection = new Connection ();
var vessel = connection.SpaceCenter ().ActiveVessel;
var root = vessel.Parts.Root;
var stack = new Stack<Tuple<Part,int>> ();
stack.Push (new Tuple<Part,int> (root, 0));
while (stack.Count > 0) {
var item = stack.Pop ();
Part part = item.Item1;
int depth = item.Item2;
Console.WriteLine (new String (' ', depth) + part.Title);
foreach (var child in part.Children)
stack.Push (new Tuple<Part,int> (child, depth + 1));
}
}
示例12: Main
public static void Main ()
{
var connection = new Connection ();
var vessel = connection.SpaceCenter ().ActiveVessel;
var activeEngines = vessel.Parts.Engines.Where (e => e.Active && e.HasFuel).ToList ();
Console.WriteLine ("Active engines:");
foreach (var engine in activeEngines)
Console.WriteLine (" " + engine.Part.Title + " in stage " + engine.Part.Stage);
double thrust = activeEngines.Sum (e => e.Thrust);
double fuel_consumption = activeEngines.Sum (e => e.Thrust / e.SpecificImpulse);
double isp = thrust / fuel_consumption;
Console.WriteLine ("Combined vacuum Isp = " + isp + " seconds");
}
示例13: Main
public static void Main ()
{
var connection = new Connection ("RemoteTech Example");
var sc = connection.SpaceCenter ();
var rt = connection.RemoteTech ();
var vessel = sc.ActiveVessel;
// Set a dish target
var part = vessel.Parts.WithTitle ("Reflectron KR-7") [0];
var antenna = rt.Antenna (part);
antenna.TargetBody = sc.Bodies ["Jool"];
// Get info about the vessels communications
var comms = rt.Comms (vessel);
Console.WriteLine ("Signal delay = " + comms.SignalDelay);
}
示例14: Main
public static void Main () {
var connection = new Connection (name: "InfernalRobotics Example");
var vessel = connection.SpaceCenter ().ActiveVessel;
var ir = connection.InfernalRobotics ();
var group = ir.ServoGroupWithName (vessel, "MyGroup");
if (group == null) {
Console.WriteLine ("Group not found");
return;
}
foreach (var servo in group.Servos)
Console.WriteLine (servo.Name + " " + servo.Position);
group.MoveRight ();
Thread.Sleep (1000);
group.Stop ();
}
示例15: Main
public static void Main ()
{
var conn = new Connection ("Launch into orbit");
var vessel = conn.SpaceCenter ().ActiveVessel;
float turnStartAltitude = 250;
float turnEndAltitude = 45000;
float targetAltitude = 150000;
// Set up streams for telemetry
var ut = conn.AddStream (() => conn.SpaceCenter ().UT);
var flight = vessel.Flight ();
var altitude = conn.AddStream (() => flight.MeanAltitude);
var apoapsis = conn.AddStream (() => vessel.Orbit.ApoapsisAltitude);
var stage3Resources = vessel.ResourcesInDecoupleStage (stage: 3, cumulative: false);
var srbFuel = conn.AddStream (() => stage3Resources.Amount ("SolidFuel"));
// Pre-launch setup
vessel.Control.SAS = false;
vessel.Control.RCS = false;
vessel.Control.Throttle = 1;
// Countdown...
Console.WriteLine ("3...");
System.Threading.Thread.Sleep (1000);
Console.WriteLine ("2...");
System.Threading.Thread.Sleep (1000);
Console.WriteLine ("1...");
System.Threading.Thread.Sleep (1000);
Console.WriteLine ("Launch!");
// Activate the first stage
vessel.Control.ActivateNextStage ();
vessel.AutoPilot.Engage ();
vessel.AutoPilot.TargetPitchAndHeading (90, 90);
// Main ascent loop
bool srbsSeparated = false;
double turnAngle = 0;
while (true) {
// Gravity turn
if (altitude.Get () > turnStartAltitude && altitude.Get () < turnEndAltitude) {
double frac = (altitude.Get () - turnStartAltitude) / (turnEndAltitude - turnStartAltitude);
double newTurnAngle = frac * 90.0;
if (Math.Abs (newTurnAngle - turnAngle) > 0.5) {
turnAngle = newTurnAngle;
vessel.AutoPilot.TargetPitchAndHeading ((float)(90 - turnAngle), 90);
}
}
// Separate SRBs when finished
if (!srbsSeparated) {
if (srbFuel.Get () < 0.1) {
vessel.Control.ActivateNextStage ();
srbsSeparated = true;
Console.WriteLine ("SRBs separated");
}
}
// Decrease throttle when approaching target apoapsis
if (apoapsis.Get () > targetAltitude * 0.9) {
Console.WriteLine ("Approaching target apoapsis");
break;
}
}
// Disable engines when target apoapsis is reached
vessel.Control.Throttle = 0.25f;
while (apoapsis.Get () < targetAltitude) {
}
Console.WriteLine ("Target apoapsis reached");
vessel.Control.Throttle = 0;
// Wait until out of atmosphere
Console.WriteLine ("Coasting out of atmosphere");
while (altitude.Get () < 70500) {
}
// Plan circularization burn (using vis-viva equation)
Console.WriteLine ("Planning circularization burn");
double mu = vessel.Orbit.Body.GravitationalParameter;
double r = vessel.Orbit.Apoapsis;
double a1 = vessel.Orbit.SemiMajorAxis;
double a2 = r;
double v1 = Math.Sqrt (mu * ((2.0 / r) - (1.0 / a1)));
double v2 = Math.Sqrt (mu * ((2.0 / r) - (1.0 / a2)));
double deltaV = v2 - v1;
var node = vessel.Control.AddNode (ut.Get () + vessel.Orbit.TimeToApoapsis, prograde: (float)deltaV);
// Calculate burn time (using rocket equation)
double F = vessel.AvailableThrust;
double Isp = vessel.SpecificImpulse * 9.82;
double m0 = vessel.Mass;
double m1 = m0 / Math.Exp (deltaV / Isp);
double flowRate = F / Isp;
double burnTime = (m0 - m1) / flowRate;
// Orientate ship
Console.WriteLine ("Orientating ship for circularization burn");
//.........这里部分代码省略.........