public void landPlayer() { playerLanded = true; Interaction.stopAndMute(true, true); moveSound.Stop(); Common.fadeMusic(); playMessage(DSound.SoundPath + "\\ac" + ((landedBefore) ? "6" : "5") + ".ogg"); landedBefore = true; long mark = Environment.TickCount; ((Aircraft)Mission.player).rearm(); ((Aircraft)Mission.player).restoreDamage(0); while (message.isPlaying()) { if ((Environment.TickCount - mark) / 1000 >= 3 && (DXInput.isKeyHeldDown() || DXInput.isJSButtonHeldDown())) { break; } Thread.Sleep(50); } message.stopOgg(); playMessage(DSound.SoundPath + "\\ac7.ogg"); while (message.isPlaying()) { Thread.Sleep(500); } ((Aircraft)Mission.player).catapult(); Common.startMusic(); ((Aircraft)Mission.player).requestRefuel(); playSound(moveSound, true, true); Interaction.resumeAndUnmute(); }
public static void startGame() { if (!KeyMap.readFromFile()) { OggBuffer kError = DSound.playOgg(DSound.NSoundPath + "\\kme.ogg"); while (kError.isPlaying()) { if (dxInput.isKeyHeldDown()) { break; } Thread.Sleep(10); } //while kError.stopOgg(); kError = null; } Options.setDifficulty(Options.difficulties.easy); Interaction.clearData(); mainMenu(); if (!Options.requestedShutdown) { Common.startGame(); if (Common.firstTimeLoad) { Common.firstTimeLoad = false; while (!Common.threadNotifier) { Thread.Sleep(6000); } } } }
public static void startGame(bool firstTimeLoad) { if (!firstTimeLoad) { return; } try { textBox1 = new TextBox(); textBox1.Location = new System.Drawing.Point(0, 0); textBox1.Name = "textBox1"; textBox1.ReadOnly = true; textBox1.Size = new System.Drawing.Size(100, 20); textBox1.TabIndex = 0; SapiSpeech.initialize(); DSound.initialize(textBox1.Handle); dxInput.DInputInit(textBox1); DSound.initializeOgg(); Options.readFromFile(); KeyMap.initialize(); //this.Deactivate += new EventHandler(GUI_Deactivate); //this.Activated += new EventHandler(GUI_Activated); if (!Common.isRegistered()) { MessageBox.Show("This game is not registered. Please contact" + " BPCPrograms SD to obtain a license.", "Registration"); } register(); OggBuffer introSound = DSound.playOgg(DSound.SoundPath + "\\i.ogg"); while ((introSound.isPlaying() && !dxInput.isKeyHeldDown())) { Thread.Sleep(5); } introSound.stopOgg(); introSound = null; } catch (Exception err) { MessageBox.Show(err.Message + " " + err.StackTrace, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(0); } }
private void playMessage(String o, bool wait) { if (message != null) { message.stopOgg(); } message = DSound.loadOgg(o); message.play(); if (wait) { Interaction.stopAndMute(true); while (message.isPlaying()) { Thread.Sleep(100); } message.stopOgg(); Interaction.resumeAndUnmute(); } //if wait }
public static void mainMenu() { Common.music = DSound.playOgg(DSound.SoundPath + "\\ms1.ogg", true); string[] m1 = { "mainmenu_1.wav", "mainmenu_2.wav", "mainmenu_3.wav", "mainmenu_5.wav", "mainmenu_4.wav" }; bool exitMenu = false; while (!exitMenu) { short index = Common.sVGenerateMenu("mainmenu_i.wav", m1); switch (index) { case 0: ////start game if (Options.mode == Options.Modes.racing) { if (selectTrack()) { exitMenu = true; } } if (Options.mode == Options.Modes.deathMatch) { exitMenu = true; } if (Options.mode == Options.Modes.mission) { exitMenu = true; } break; case 1: ////select racing mode string[] modeOptions = { "mainmenu_2_1.wav", "mainmenu_2_2.wav", "mainmenu_2_3.wav" }; short modeIndex = Common.sVGenerateMenu("", modeOptions); if (modeIndex == -1) { break; } Options.mode = (Options.Modes)(modeIndex + 1); if (Options.mode == Options.Modes.mission) { Mission.isMission = true; } else { Mission.isMission = false; ////reset in case coming ////out of mission mode } break; case 2: ////speaker test OggBuffer speakerTest = DSound.playOgg(DSound.SoundPath + "\\speakertest.ogg"); while (speakerTest.isPlaying()) { Application.DoEvents(); } speakerTest = null; break; case 3: ////options string[] oArray = { "mainmenu_5_1.wav", "mainmenu_5_2.wav" }; short oIndex = 0; while (oIndex != -1) { oIndex = Common.sVGenerateMenu("mainmenu_5_i.wav", oArray); switch (oIndex) { case 0: ////mapkeys buildKeyMapMenu(); break; case 1: ////switch input device showDevices(); break; } } break; case 4: ////exit Options.requestedShutdown = true; exitMenu = true; break; } } Common.fadeMusic(); if (Options.requestedShutdown) { Options.requestedShutdown = false; Common.shutdown(); return; } }
/// <summary> /// Initializes a joystick device using the specified global unique identifier. /// </summary> /// <param name="handle">A pointer to the application's master form.</param> /// <param name="g">The GUID of the device to initialize.</param> public static void DInputInit(IntPtr handle, Guid g) { if (JSDevice != null) { JSDevice.Unacquire(); JSDevice = null; } JSDevice = new Joystick(input, g); int xAxisOffset = 0, yAxisOffset = 0; int nextOffset = 0; // JSDevice.Properties.AutoCenter = true; foreach (DeviceObjectInstance d in JSDevice.GetObjects()) { if ((d.ObjectId.Flags & DeviceObjectTypeFlags.ForceFeedbackActuator) == DeviceObjectTypeFlags.ForceFeedbackActuator) { if (nextOffset == 0) { xAxisOffset = d.Offset; } else { yAxisOffset = d.Offset; } nextOffset++; } if (d.ObjectType == ObjectGuid.XAxis) { JSDevice.GetObjectPropertiesById( d.ObjectId).Range = new InputRange(-5, 5); JSDevice.GetObjectPropertiesById( d.ObjectId).DeadZone = 1000; } if (d.ObjectType == ObjectGuid.YAxis) { JSDevice.GetObjectPropertiesById(d.ObjectId).Range = new InputRange(-9, 9); JSDevice.GetObjectPropertiesById( d.ObjectId).DeadZone = 1000; } if (d.ObjectType == ObjectGuid.Slider) { JSDevice.GetObjectPropertiesById( d.ObjectId).Range = new InputRange(0, 11); JSSliderId = d.ObjectId; useSlider = true; } if (d.ObjectType == ObjectGuid.ZAxis) { JSDevice.GetObjectPropertiesById( d.ObjectId).Range = new InputRange(0, 11); jsZId = d.ObjectId; useZ = true; } if (d.ObjectType == ObjectGuid.RzAxis) { JSDevice.GetObjectPropertiesById( d.ObjectId).Range = new InputRange(-5, 5); } } //for if (useSlider && useZ) { useSlider = false; } JSDevice.SetCooperativeLevel(handle, CooperativeLevel.Background | CooperativeLevel.Exclusive); JSDevice.Acquire(); updateJSState(); TheJSButtons = JSState.Buttons; if (nextOffset > 0) { if (!dInputInitFD(JSDevice, xAxisOffset, yAxisOffset, nextOffset)) { OggBuffer error = DSound.loadOgg(DSound.SoundPath + "\\ffbd.ogg"); error.play(); while (error.isPlaying()) { Thread.Sleep(10); } error.stopOgg(); error = null; forceFeedbackEnabled = false; } else { forceFeedbackEnabled = true; } } }