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); } } } }
private void stopRain() { isRaining = false; if ((rain != null)) { rain.stopOgg(); } if ((thunder != null)) { thunder.stopOgg(); } rainElapsed = 0; rainTime = 0; }
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 }
private static void buildKeyMapMenu() { string[] devices = { "mainmenu_5_1_1.wav", "mainmenu_5_1_2.wav" }; short dO = Common.sVGenerateMenu("mainmenu_5_1_i.wav", devices); if (dO == -1) { return; } bool mapKeyboard = false; bool mapJoystick = false; if (dO == 0) { mapKeyboard = true; } else { mapJoystick = true; } short index = -1; Key[] r = null; Key[] m = null; ////modifiers will only be assigned if keyboard is used int[] jsKey = null; while (index != 0) { r = null; m = null; jsKey = null; string[] strKeys = null; if (mapKeyboard) { strKeys = KeyMap.getKeyStrings(null); } else { strKeys = KeyMap.getKeyStrings(Vehicle.Action.throttleUp, Vehicle.Action.throttleDown, Vehicle.Action.turnLeft, Vehicle.Action.turnRight, Vehicle.Action.bankLeft, Vehicle.Action.bankRight, Vehicle.Action.rollLeft, Vehicle.Action.rollRight, Vehicle.Action.brakeLeft, Vehicle.Action.brakeRight, Vehicle.Action.highGTurn, Vehicle.Action.ascend, Vehicle.Action.descend, Vehicle.Action.level, Vehicle.Action.togglePointOfView, Vehicle.Action.increaseMusicVolume, Vehicle.Action.decreaseMusicVolume); } index = (short)(Common.sVGenerateMenu("ki.wav", strKeys) + 1); if (index > 0) { if (mapKeyboard) { OggBuffer prompt = DSound.playOgg(DSound.NSoundPath + "\\kmp1.ogg"); while (dxInput.isKeyHeldDown()) { ////wait till the user lets up on enter. Application.DoEvents(); } while (m == null) { m = dxInput.getKeys(); } prompt.stopOgg(); prompt = null; prompt = DSound.playOgg(DSound.NSoundPath + "\\kmp2.ogg"); while ((dxInput.isKeyHeldDown())) { ////wait till the user lets up on enter. Application.DoEvents(); } ////Next, get a key while (r == null) { r = dxInput.getKeys(); } prompt.stopOgg(); prompt = null; if (m[0] == Key.Return) { KeyMap.addKey((Vehicle.Action)index, r[0]); } else { KeyMap.addKey((Vehicle.Action)index, m[0], r[0]); } } else { ////joystick OggBuffer prompt = DSound.playOgg(DSound.NSoundPath + "\\kmp3.ogg"); while (dxInput.isJSButtonHeldDown()) { Application.DoEvents(); } while (jsKey == null) { jsKey = dxInput.getJSKeys(); Application.DoEvents(); } prompt.stopOgg(); prompt = null; KeyMap.addKey((Vehicle.Action)index, dxInput.getJSKeys()[0]); } ////joystick } ////index>=0 } ////Since the parent loop has been broken, the user has pressed escape. ////We need to save the new keymap data to a file now so that it will be restored when the game loads KeyMap.saveToFile(); }
/// <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; } } }