private void startRain() { if (isRaining) { rainElapsed += 1; if (rainElapsed >= rainTime) { stopRain(); } return; ////already raining } if (Common.getRandom(1, 50) == 25) { if (!isRaining) { rainIntensity = (WeatherTypes)Common.getRandom(1, 3); rain = DSound.loadOgg(DSound.SoundPath + "\\wr" + rainIntensity + ".ogg"); rain.play(true); isRaining = true; } ////if !isRaining } ////if random }
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 }
/// <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; } } }