// Use this for initialization (must Awake, since start of GameLoop will set states) void Awake() { state = State.SELECT_OBJECTIVE; intercepts = null; time_to_moon_phys = TIME_TO_MOON_SEC / GravityScaler.GetGameSecondPerPhysicsSecond(); if (targets.Length == 0) { Debug.LogError("No targets configured"); } // Player is spaceship 1, others are objectives // take first ship to tbe the player target = targets[0]; // Need to configure objective chooser SetObjectiveOptions(targets); SetState(state); // add a trajectory intercepts component (it need to handle markers so it has // a monobehaviour base class). // The pair of spaceships to be checked will be selected dynamically trajIntercepts = gameObject.AddComponent <TrajectoryIntercepts>(); trajIntercepts.interceptSymbol = interceptMarker; trajIntercepts.rendezvousSymbol = rendezvousMarker; spaceshipGO = spaceshipCtrl.transform.parent.gameObject; // optional spaceshipOrbit = spaceshipGO.GetComponent <OrbitUniversal>(); // only record the elements that are active at the start of the scene orbitPredictors = new List <OrbitPredictor>(); foreach (OrbitPredictor op in (OrbitPredictor[])Object.FindObjectsOfType(typeof(OrbitPredictor))) { if (op.gameObject.activeInHierarchy) { orbitPredictors.Add(op); if (op.transform.parent == spaceshipGO.transform) { shipOrbitPredictor = op; } } } if (shipOrbitPredictor == null) { Debug.LogError("Did not find orbit predictor for ship"); } orbitRenderers = new List <OrbitRenderer>(); foreach (OrbitRenderer or in (OrbitRenderer[])Object.FindObjectsOfType(typeof(OrbitRenderer))) { if (or.gameObject.activeInHierarchy) { orbitRenderers.Add(or); } } }
void Awake() { // Convert from real world units // Rocket engine thrust is given in SI units, so acceleration is in SI units // For Orbital scale need to convert to km/hr^2 accelerationConversion = GravityScaler.AccelSItoGEUnits(); // and convert to the physics scale used in the engine accelerationConversion = accelerationConversion * GravityScaler.AccelGEtoInternalUnits(); burnStart = new double[MAX_STAGES]; burnRateScale = GravityScaler.GetGameSecondPerPhysicsSecond(); fuelLevel = new double[MAX_STAGES]; for (int i = 0; i < numStages; i++) { fuelLevel[i] = massFuel[i]; } // acceleration will be opposite to thrust direction accelDirection = -thrustAxis; activeStage = 0; activeState = GravityEngine.Instance().GetWorldState(); SetEngine(engineOn); }
void Start() { SetEngine(engineOn); // Convert from real world units // Rocket engine thrust is given in SI units, so acceleration is in SI units // For Orbital scale need to convert to km/hr^2 accelerationConversion = GravityScaler.AccelSItoGEUnits(); // and convert to the physics scale used in the engine accelerationConversion = accelerationConversion * GravityScaler.AccelGEtoInternalUnits(); burnRateScaled = burnRate * GravityScaler.GetGameSecondPerPhysicsSecond(); thrustDirection = thrustAxis; }
/// <summary> /// Set the maneuver time in world units (e.g. in ORBITAL units in /// hours). /// </summary> /// <param name="time"></param> public void SetTimeScaled(float time) { worldTime = time / GravityScaler.GetGameSecondPerPhysicsSecond(); }