public void Start() { selectedColor = Color.blue; ConvertColors(defaultColor); defaultScale = transform.localScale; MapMovement.Instance.ZoomChanged += ChangeZoom; MapMovement.Instance.Moved += ChangePosition; pParams = new PhysicsParameters(transform); IsGasAlertActive = false; if (PlaneManager.Instance.PlaneVisibilityWhenOffMap || MapCommands.Instance.Contains(coords)) { IsVisible = true; } else { SetVisibility(false); } setPlaneName(); distanceText.transform.localScale /= transform.localScale.x; }
/*************************************************************************************************************************/ /// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // Update the screen size GameConstants.windowWidth = graphics.GraphicsDevice.Viewport.Width; GameConstants.windowHeight = graphics.GraphicsDevice.Viewport.Height; // Audio Initialisation audioEngine = new AudioEngine("Content\\Audio\\MyGameAudio.xgs"); waveBank = new WaveBank(audioEngine, "Content\\Audio\\Wave Bank.xwb"); soundBank = new SoundBank(audioEngine, "Content\\Audio\\Sound Bank.xsb"); // Camera Initialisation camera = new Camera(); camera.ViewMatrix = Matrix.CreateLookAt(camera.CameraPosition, camera.CameraFocusOn, Vector3.Up); camera.ProjectionMatrix = Matrix.CreatePerspectiveFieldOfView( MathHelper.ToRadians(GameConstants.perspective), aspectRatio, 1.0f, GameConstants.cameraMaxDistance); // Physics Initialisation PhysicsParameters parameters = new PhysicsParameters(); parameters.Gravity = new Vector3(0.0f, 0.0f, GameConstants.gravity); parameters.WindSpeed = new Vector3(0.0f, 0.0f, 0.0f); physics = new PhysicsEngine.Environment(); physics.PhysicsParameters = parameters; base.Initialize(); }
public static void CalculateFlightParameters(PhysicsParameters pParams) { pParams.Speed = pParams.Velocity.magnitude; pParams.AngleOfAttack = pParams.Rotation.x; if (pParams.Speed == 0) { pParams.AngleOfAscent = 0; } else { pParams.AngleOfAscent = Math.Asin(pParams.Velocity.y / pParams.Velocity.magnitude); } pParams.ParasiticDrag = 0.5 * CalculateAirPressure(pParams.Position) * Math.Pow(pParams.Speed, 2) * 0.4 * 162.1; pParams.Lift = Math.Cos(pParams.AngleOfAttack) * (hercMass * (pParams.Accelaration.y + gravityMag) + pParams.ParasiticDrag * Math.Sin(pParams.AngleOfAscent)) - Math.Sin(pParams.AngleOfAttack) * (hercMass * pParams.Accelaration.x + pParams.ParasiticDrag * Math.Cos(pParams.AngleOfAscent)); pParams.InducedDrag = pParams.Lift * Math.Sin(pParams.AngleOfAttack) * Math.Cos(pParams.AngleOfAscent); pParams.TotalDrag = pParams.InducedDrag + pParams.ParasiticDrag; pParams.Thrust = Math.Sin(pParams.AngleOfAttack) * (hercMass * (pParams.Accelaration.y + gravityMag) + pParams.ParasiticDrag * Math.Sin(pParams.AngleOfAscent)) + Math.Cos(pParams.AngleOfAttack) * (hercMass * Math.Sqrt(Math.Pow(pParams.Accelaration.x, 2) + Math.Pow(pParams.Accelaration.z, 2)) + pParams.ParasiticDrag * Math.Cos(pParams.AngleOfAscent)); }
/*************************************************************************************************************************/ /// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // Camera Initialisation camera = new Camera(); camera.ViewMatrix = Matrix.CreateLookAt(camera.CameraPosition, camera.CameraFocusOn, Vector3.Up); camera.ProjectionMatrix = Matrix.CreatePerspectiveFieldOfView( MathHelper.ToRadians(45.0f), aspectRatio, 1.0f, 10000.0f); // Physics Initialisation PhysicsParameters paramaters = new PhysicsParameters(); paramaters.Gravity = new Vector3(0.0f, -10.0f, 0.0f); paramaters.WindSpeed = new Vector3(0.0f, 0.0f, 0.0f); physics = new PhysicsEngine.Environment(); physics.PhysicsParameters = paramaters; base.Initialize(); }