void Awake() { controlBoard = GameObject.FindGameObjectWithTag("GameController").GetComponent <SilantroControls> (); if (controlBoard == null) { Debug.LogError("Control Board is missing, Place Control Board in scene and restart!"); } // startEngine = controlBoard.engineStart; stopEngine = controlBoard.engineShutdown; throttleUp = controlBoard.engineThrottleUp; throttleDown = controlBoard.engineThrottleDown; // GameObject brain = GameObject.FindGameObjectWithTag("Brain"); if (brain != null && brain.transform.root == gameObject.transform.root) { instrumentation = brain.GetComponent <SilantroInstrumentation> (); } if (instrumentation == null) { //instrumentation.Store (); Debug.LogError("Instrumentation is missing!! If Engine is just for Test, add Instrumentation Prefab to the Scene"); } }
// Use this for initialization void Start() { aerofoilCollider = (BoxCollider)gameObject.GetComponent <Collider>(); AirplaneBody = transform.root.gameObject.GetComponent <Rigidbody> (); // GameObject brain = GameObject.FindGameObjectWithTag("Brain"); if (brain != null && brain.transform.root == gameObject.transform.root) { instrumentation = brain.GetComponent <SilantroInstrumentation> (); } if (instrumentation == null) { //instrumentation.Store (); Debug.LogError("Instrumentation is missing!! If Engine is just for Test, add Instrumentation Prefab to the Scene"); } }
// // Use this for initialization void Start() { aircraft = GetComponent <Rigidbody> (); if (aircraft == null) { Debug.Log("Add Rigidbody component to airplane body"); } // datalog = aircraft.gameObject.GetComponentInChildren <SilantroInstrumentation>(); currentTank = fuelsystem.internalFuelTank; //AIRCRAFT SETUP if (engineType == AircraftType.TurboFan) { turbofans = GetComponentsInChildren <SilantroTurboFan> (); foreach (SilantroTurboFan turbofan in turbofans) { turbofan.attachedFuelTank = currentTank; } AvailableEngines = turbofans.Length; // } else if (engineType == AircraftType.TurboJet) { turboJet = GetComponentsInChildren <SilantroTurboJet> (); AvailableEngines = turboJet.Length; foreach (SilantroTurboJet jet in turboJet) { jet.attachedFuelTank = currentTank; } } else if (engineType == AircraftType.TurboProp) { turboprop = GetComponentsInChildren <SilantroTurboProp> (); AvailableEngines = turboprop.Length; foreach (SilantroTurboProp turboProp in turboprop) { turboProp.attachedFuelTank = currentTank; } } // wings = GetComponentsInChildren <SilantroAerofoil>(); wingArea = 0; if (wings.Length > 0) { foreach (SilantroAerofoil wing in wings) { wingArea += wing.aerofoilArea; } } // GameObject brain = GameObject.FindGameObjectWithTag("Brain"); if (brain.transform.root == gameObject.transform.root) { cog = brain; } // Collider col = gameObject.GetComponent <CapsuleCollider>(); if (col == null) { Debug.Log("Attach a capsule collider to the airplane and restart!!"); } float r = dragSystem.averagefuselargeDiameter / 2f; fuselargeArea = (3.142f * r * r) + (2 * 3.142f * r * dragSystem.averagefuselargeLength); // // if (isDestructible && GetComponent <SilantroHealth> () != null) { GetComponent <SilantroHealth> ().isDistructible = true; SilantroAerofoilHealth[] healths = GetComponentsInChildren <SilantroAerofoilHealth> (); foreach (SilantroAerofoilHealth hlt in healths) { hlt.isDistructible = true; } } else if (!isDestructible && GetComponent <SilantroHealth> () != null) { GetComponent <SilantroHealth> ().isDistructible = false; SilantroAerofoilHealth[] healths = GetComponentsInChildren <SilantroAerofoilHealth> (); foreach (SilantroAerofoilHealth hlt in healths) { hlt.isDistructible = false; } } // //CALCULATE EXTRA DRAG OBJECTS extraDrags = GetComponentsInChildren <SilantroDragMultiplier>(); extraDrag = 0; foreach (SilantroDragMultiplier drag in extraDrags) { if (drag.dragActive) { extraDrag += drag.dragCoefficient; } } // // // AerodynamicSurfaces = wings.Length.ToString(); Engines = AvailableEngines.ToString(); if (datalog != null) { InstrumentBoard = "Active"; } if (fuelsystem != null) { FuelSystem = "Active"; } if (gearHelper != null) { WheelSystem = "Active"; } }
//StreamWriter streamWriter; //INDIVIDUAL PART HEALTHS.....COMING SOON // Use this for initialization void Start() { // if (Aircraft == null) { Debug.Log("No Aircraft is connected to the Black Box"); } datalog = Aircraft.GetComponentInChildren <SilantroInstrumentation>(); // //Property of Oyedoyin Dada //cc [email protected] // // // if (datalog == null) { Debug.Log("No instrumentation is connected to the Black Box"); } control = Aircraft.GetComponent <SilantroController> (); if (control == null) { Debug.Log("Controller has not been added to the Airplane"); } if (control.engineType == SilantroController.AircraftType.TurboFan) { isTurboFan = true; jetengines = control.turbofans; } // if (control.engineType == SilantroController.AircraftType.TurboJet) { isTurbojet = true; turboengines = control.turboJet; } // if (control.engineType == SilantroController.AircraftType.TurboProp) { isTurboProp = true; propengines = control.turboprop; } // if (dataExtension == FileExtension.csv) { csv = true; txt = false; } else if (dataExtension == FileExtension.txt) { txt = true; csv = false; } // timer = 0.0f; // if (logRate != 0) { actualLogRate = 1.0f / logRate; } else { actualLogRate = 0.10f; } // aircraftName = control.gameObject.name; takeoffweight = control.currentWeight; noOfEngines = control.AvailableEngines; startFuel = control.fuelsystem.TotalFuelRemaining; // engines = aircraft.Engines; // if (dataType == DataType.FlightData) { //WRITE INITIAL TXT FILE if (txt) { File.WriteAllText(saveLocation + "" + savefileName + ".txt", "Flight Data"); // using (System.IO.StreamWriter writeText = System.IO.File.AppendText(saveLocation + "" + savefileName + ".txt")) { writeText.WriteLine("<<>>"); writeText.WriteLine("<<>>"); writeText.WriteLine("Aircraft Name: " + aircraftName); writeText.WriteLine("Gross Weight: " + takeoffweight.ToString() + " kg"); writeText.WriteLine("No of Engines: " + noOfEngines.ToString()); writeText.WriteLine("Available Fuel: " + startFuel.ToString() + " kg"); writeText.WriteLine("Date: " + DateTime.Now.ToString("f")); //writeText.WriteLine ("Current Time: " + DateTime.Now.ToString (")); writeText.WriteLine("<<>>"); writeText.WriteLine("Flight Time " + "Current Speed " + " Climb Rate " + " Heading " + " Current Altitude " + " Fuel Remaining " + " Thrust Generated " + " Current Health"); } } else if (csv) { //WRITE INITIAL CSV FILE string[] dataRowTemp = new string[8]; dataRowTemp [0] = "Flight Time"; dataRowTemp [1] = "Current Speed"; dataRowTemp [2] = "Climb Rate"; dataRowTemp [3] = "Heading"; dataRowTemp [4] = "Current Altitude"; dataRowTemp [5] = "Fuel Remaining"; dataRowTemp [6] = "Total Thrust Generated"; dataRowTemp [7] = "Current Health"; dataRow.Add(dataRowTemp); // } } }
void Awake() { // //ADD AUDIOSOURCES if (null != EngineStartSound) { EngineStart = Thruster.gameObject.AddComponent <AudioSource>(); EngineStart.clip = EngineStartSound; EngineStart.loop = false; EngineStart.dopplerLevel = 0f; EngineStart.spatialBlend = 1f; EngineStart.rolloffMode = AudioRolloffMode.Custom; EngineStart.maxDistance = 650f; } if (null != EngineIdleSound) { GameObject soundPoint = new GameObject(); soundPoint.transform.parent = this.transform; soundPoint.transform.localPosition = new Vector3(0, 0, 0); soundPoint.name = this.name + " Sound Point"; // EngineRun = soundPoint.gameObject.AddComponent <AudioSource>(); EngineRun.clip = EngineIdleSound; EngineRun.loop = true; EngineRun.Play(); engineSoundVolume = EngineRun.volume * 2f; EngineRun.spatialBlend = 1f; EngineRun.dopplerLevel = 0f; EngineRun.rolloffMode = AudioRolloffMode.Custom; EngineRun.maxDistance = 600f; } if (null != EngineShutdownSound) { EngineShutdown = Thruster.gameObject.AddComponent <AudioSource>(); EngineShutdown.clip = EngineShutdownSound; EngineShutdown.loop = false; EngineShutdown.dopplerLevel = 0f; EngineShutdown.spatialBlend = 1f; EngineShutdown.rolloffMode = AudioRolloffMode.Custom; EngineShutdown.maxDistance = 650f; } // GameObject brain = GameObject.FindGameObjectWithTag("Brain"); if (brain.transform.root == gameObject.transform.root) { instrumentation = brain.GetComponent <SilantroInstrumentation> (); } if (instrumentation == null) { Debug.LogError("Instrumentation System is Missing!! Add COG to aircraft"); } else { instrumentation.boom = EngineRun; } // controlBoard = GameObject.FindGameObjectWithTag("GameController").GetComponent <SilantroControls> (); panelControls = GameObject.FindGameObjectWithTag("PanelControls").GetComponent <PanelControls> (); if (controlBoard == null) { Debug.LogError("Control Board is missing, Place Control Board in scene and restart!"); } startEngine = controlBoard.engineStart; stopEngine = controlBoard.engineShutdown; throttleUp = controlBoard.engineThrottleUp; throttleDown = controlBoard.engineThrottleDown; afterburnerControl = controlBoard.AfterburnerControl; // LPIdleRPM = LowPressureFanRPM * 0.1f; HPIdleRPM = HighPressureFanRPM * 0.09f; // if (reheatSystem == ReheatSystem.Afterburning) { canUseAfterburner = true; } else if (reheatSystem == ReheatSystem.noReheat) { canUseAfterburner = false; } // AfterburnerOperative = false; }