public override bool doAction() { if (actor.canOpenDoors) { if (_chest.closed) { _chest.closed = false; if (_chest.isTrapped) { EffectDescription description = new EffectDescription(EffectType.Explosion, actor.location); level.queueEffect(description); const int chestTrapMaxDamage = 10; int damage = Util.random.Next(1, chestTrapMaxDamage); actor.hp -= damage; MessageLog.log("The chest was trapped! " + actor.name + " hit for " + damage + " damage"); } else { Item chestItem = _chest.takeItem(); ((Hero) actor).giveItem(chestItem); MessageLog.log(actor.name + " opened a chest and recieved " + chestItem.name); } } } return true; }
private void button6_Click(object sender, System.EventArgs e) { //Create and setup the sound device. // Device dev = new Device(); // dev.SetCooperativeLevel(this,CooperativeLevel.Normal); //Create and setup the buffer description. BufferDescription buffer_desc = new BufferDescription(); buffer_desc.ControlEffects = false; //this has to be true to use effects. buffer_desc.GlobalFocus = true; //play sound even if application loses focus. //Create and setup the buffer for playing the sound. // SecondaryBuffer buffer = new SecondaryBuffer( // @"C:\WINDOWS\Media\ding.wav", // buffer_desc, // dev); //Create an array of effects descriptions, //set the effect objects to echo and chorus and //set it in the buffer. EffectDescription[] effects = new EffectDescription[0]; // effects[0].GuidEffectClass = DSoundHelper.StandardEchoGuid; // effects[1].GuidEffectClass = DSoundHelper.StandardChorusGuid; bufferx.SetEffects(effects); //bufferx. //Play Buffer. // buffer.Play(0,BufferPlayFlags.Default); }
public static void CompareEffect(BytecodeContainer container, byte[] effectBytecode, string testName) { var device = new Device( DriverType.Warp, DeviceCreationFlags.Debug, FeatureLevel.Level_10_1); Effect effectReflection = null; if (container == null) { effectReflection = new Effect(device, effectBytecode, EffectFlags.None); Warn.If(true, "Container is null"); return; } var chunk = container.Chunks.OfType <EffectChunk>().First(); if (chunk.IsChildEffect) { effectReflection = new Effect(device, effectBytecode, EffectFlags.None); //var effectPool = new EffectPool(device, effectBytecode, EffectFlags.None); //effectReflection = effectPool.AsEffect(); } else { effectReflection = new Effect(device, effectBytecode, EffectFlags.None); } EffectDescription desc = effectReflection.Description; var header = chunk.Header; //Assert.AreEqual((bool)desc.IsChildEffect, header.SharedConstantBuffers > 0); Assert.AreEqual(desc.ConstantBufferCount, header.ConstantBuffers); //Assert.AreEqual(desc.SharedConstantBufferCount, header.SharedConstantBuffers); Assert.AreEqual(desc.GlobalVariableCount, header.GlobalVariables + header.ObjectCount); //Assert.AreEqual(desc.SharedGlobalVariableCount, header.SharedGlobalVariables); Assert.AreEqual(desc.TechniqueCount, header.Techniques); var reflectionConstantBufferCount = GetBufferCount(effectReflection); Assert.AreEqual(reflectionConstantBufferCount, header.ConstantBuffers + header.SharedConstantBuffers); var reflectionVariableCount = GetVariableCount(effectReflection); Assert.AreEqual(reflectionVariableCount, header.ObjectCount + header.SharedObjectCount + header.GlobalVariables + header.SharedGlobalVariables); var variables = chunk.AllVariables.ToList(); var reflectionVariables = GetEffectVariables(effectReflection); var reflectionNames = reflectionVariables .Select(v => $"{v.Description.Name}, {v.TypeInfo.Description.Type}, {v.TypeInfo.Description.Class}") .ToList(); for (int i = 0; i < desc.GlobalVariableCount; i++) { CompareVariable(reflectionVariables[i], variables[i]); } var buffers = chunk.AllBuffers.ToList(); for (int i = 0; i < desc.ConstantBufferCount; i++) { var cb = effectReflection.GetConstantBufferByIndex(i); //CompareConstantBuffer(cb, buffers[i]); } }
public void Test1ReadDescription() { var descInstance = new EffectDescription(); var description = GenerateDummySEDescription(); var resultInstance = JsonConvert.DeserializeObject <EffectDescription>(description); Assert.AreEqual(descInstance, resultInstance); }
public static void CompareEffect(BytecodeContainer container, byte[] effectBytecode, string testName) { var chunk = container.Chunks.OfType <Fx10.EffectChunk>().First(); if (chunk.Header.Techniques == 0) { return; } if (chunk.Header.Version.MinorVersion == 1) { Assert.Warn("Version fx_4_1 is not supported by SharpDX"); return; } if (chunk.IsChildEffect) { Assert.Warn("Child Effects are not supported by SharpDX"); return; } var device = new Device(DriverType.Warp, DeviceCreationFlags.Debug); var effectReflection = new Effect(device, effectBytecode, EffectFlags.None); EffectDescription desc = effectReflection.Description; var header = chunk.Header; Assert.AreEqual((bool)desc.IsChildEffect, header.SharedConstantBuffers > 0); Assert.AreEqual(desc.ConstantBufferCount, header.ConstantBuffers); Assert.AreEqual(desc.SharedConstantBufferCount, header.SharedConstantBuffers); Assert.AreEqual(desc.GlobalVariableCount, header.GlobalVariables + header.ObjectCount); Assert.AreEqual(desc.SharedGlobalVariableCount, header.SharedGlobalVariables); Assert.AreEqual(desc.TechniqueCount, header.Techniques); var variables = chunk.AllVariables.ToList(); var reflectionVariables = GetEffectVariables(effectReflection); var reflectionNames = reflectionVariables .Select(v => $"{v.Description.Name}, {v.TypeInfo.Description.Type}, {v.TypeInfo.Description.Class}") .ToList(); for (int i = 0; i < desc.GlobalVariableCount + desc.SharedGlobalVariableCount; i++) { CompareVariable(reflectionVariables[i], variables[i]); } var buffers = chunk.AllBuffers.ToList(); var reflectionBuffers = effectReflection.GetConstantBuffers(); for (int i = 0; i < desc.ConstantBufferCount + desc.SharedConstantBufferCount; i++) { CompareConstantBuffer(reflectionBuffers[i], buffers[i]); } var techniques = effectReflection.GetTechniques(); for (int i = 0; i < desc.TechniqueCount; i++) { CompareTechniques(techniques[i], chunk.Techniques[i]); } }
private void button3_Click(object sender, System.EventArgs e) { //Create and setup the sound device. Device dev = new Device(); devx = dev; dev.SetCooperativeLevel(this, CooperativeLevel.Normal); //Create and setup the buffer description. buffer_desc = new BufferDescription(); buffer_desc.ControlEffects = true; //this has to be true to use effects. buffer_desc.GlobalFocus = true; //play sound even if application loses focus. buffer_desc.ControlFrequency = true; //Create and setup the buffer for playing the sound. SecondaryBuffer buffer = new SecondaryBuffer( //@"C:\WINDOWS\Media\ding.wav", @"Z:\My Documents\My Programming\Pong\qbytespong.wav", buffer_desc, dev); timer1.Enabled = true; //Create an array of effects descriptions, //set the effect objects to echo and chorus and //set it in the buffer. EffectDescription[] effects = new EffectDescription[3]; //effects[0].GuidEffectClass = DSoundHelper.StandardEchoGuid; effects[1].GuidEffectClass = DSoundHelper.StandardChorusGuid; effects[0].GuidEffectClass = DSoundHelper.StandardFlangerGuid; effects[2].GuidEffectClass = DSoundHelper.StandardParamEqGuid; buffer.SetEffects(effects); //public class EchoEffect : System.MarshalByRefObject // Member of Microsoft.DirectX.DirectSound //System.IntPtr lp=Application.lp; //EchoEffect efx = new EchoEffect(lp,buffer); //efx. Microsoft.DirectX.DirectSound.WaveFormat wfm = buffer_desc.Format; int bps = wfm.BitsPerSample; sps = wfm.AverageBytesPerSecond; msps = wfm.SamplesPerSecond; //Play Buffer. buffer.Play(0, BufferPlayFlags.Default); bufferx = buffer; trackBar1.Value = msps; label1.Text = trackBar1.Value.ToString(); }
public EffectDescriptionBuilder() { effect = new EffectDescription(); EffectAdvancement effectAdvancement = new EffectAdvancement(); effectAdvancement.SetIncrementMultiplier(1); effect.SetEffectAdvancement(effectAdvancement); var particleParams = new EffectParticleParameters(); particleParams.Copy(DatabaseHelper.SpellDefinitions.MagicWeapon.EffectDescription.EffectParticleParameters); effect.SetEffectParticleParameters(particleParams); }
/// <summary> Fills this field with information about a move effect. </summary> /// <param name="effect"> Effect's description to place onto field. </param> public void FillField(EffectDescription effect) { /* Update Text */ identifier_text.text = effect.identifier; description_text.text = effect.description; tooltip_text.text = effect.toolTipDescription; /* Update Description Color */ if (effect.useCustomColor) { description.color = new Color( effect.descriptionColor.r, effect.descriptionColor.g, effect.descriptionColor.b, description.color.a); } /* Update Subtext */ if (effect.useSubtext) { subtext.text = effect.subtext; subtext.color = new Color( effect.subtextColor.r, effect.subtextColor.g, effect.subtextColor.b, subtext.color.a); } /* Else Clear Subtext */ else { subtext.text = ""; } /* Record Whether The Tooltip Is Activatable */ tooltipActivatable = effect.useToolTip; }
public static T SetEffectDescription <T>(this T entity, EffectDescription value) where T : MonsterAttackDefinition { entity.SetField("effectDescription", value); return(entity); }
public void SetEffectDescription(EffectDescription effectDescription) { Traverse.Create(power).Field("effectDescription").SetValue(effectDescription); }
protected virtual void ParseModifier(SimulationDescriptor simulationDescriptor, SimulationModifierDescriptor modifierDescriptor, StaticString defaultClass, SimulationObject context, bool isContextSource, out EffectDescription effectMapperElementDescription, bool isForceOn = false) { effectMapperElementDescription = null; bool forcePercent = false; GuiElement guiElement; if (this.GuiService.GuiPanelHelper.TryGetGuiElement(modifierDescriptor.TargetPropertyName, out guiElement) && guiElement is ExtendedGuiElement) { ExtendedGuiElement extendedGuiElement = guiElement as ExtendedGuiElement; if (extendedGuiElement.TooltipElement != null) { if (extendedGuiElement.TooltipElement.Ignore) { return; } forcePercent = extendedGuiElement.TooltipElement.Percent; } } SimulationObject simulationObject = context; if (!isContextSource) { simulationObject = null; } if (modifierDescriptor is SingleSimulationModifierDescriptor) { effectMapperElementDescription = this.ParseSingleModifier(simulationDescriptor, modifierDescriptor as SingleSimulationModifierDescriptor, simulationObject, forcePercent); } else if (modifierDescriptor is BinarySimulationModifierDescriptor) { effectMapperElementDescription = this.ParseBinaryModifier(simulationDescriptor, modifierDescriptor as BinarySimulationModifierDescriptor, simulationObject, forcePercent); } else if (modifierDescriptor is CountSimulationModifierDescriptor) { effectMapperElementDescription = this.ParseCountModifier(simulationDescriptor, modifierDescriptor as CountSimulationModifierDescriptor, simulationObject, forcePercent); } if (effectMapperElementDescription == null || string.IsNullOrEmpty(effectMapperElementDescription.Value)) { return; } if (!string.IsNullOrEmpty(modifierDescriptor.TooltipOverride)) { if (modifierDescriptor.LocalizeTooltipOverride) { effectMapperElementDescription.Format = AgeLocalizer.Instance.LocalizeString(modifierDescriptor.TooltipOverride); } else { effectMapperElementDescription.Format = modifierDescriptor.TooltipOverride; } } effectMapperElementDescription.Symbol = this.ComputePropertySymbol(modifierDescriptor.TargetPropertyName); if (simulationObject != null) { } if (simulationObject == null || isForceOn) { string on = string.Empty; if (modifierDescriptor.Path != null && modifierDescriptor.Path.Length > 0 && modifierDescriptor.Path[0].Length > 0) { this.GetScope(modifierDescriptor.Path, out on); } else { on = this.ComputeReadableString(defaultClass, true); } effectMapperElementDescription.On = on; } string condition = string.Empty; if (modifierDescriptor.Path != null && modifierDescriptor.Path.Length > 0 && modifierDescriptor.Path[0].Length > 0) { condition = this.ComputeDuringString(modifierDescriptor.Path); } effectMapperElementDescription.Condition = condition; }
public static T SetEffectDescription <T>(this T entity, EffectDescription value) where T : FeatureDefinitionPower { entity.SetField("effectDescription", value); return(entity); }
protected EffectDescription ParseCountModifier(SimulationDescriptor simulationDescriptor, CountSimulationModifierDescriptor modifierDescriptor, SimulationObject context = null, bool forcePercent = false) { EffectDescription effectDescription = new EffectDescription(); bool round = false; string valueFormat = string.Empty; string empty = string.Empty; float neutralValue = this.ComputeOperationTypeToken(modifierDescriptor.Operation, ref empty, ref valueFormat, ref round); effectDescription.Operator = empty; if (forcePercent) { valueFormat = "#####0%"; } object obj = modifierDescriptor.PrecomputedValue; if (obj is float) { effectDescription.ValueFloat = (float)obj; effectDescription.ValueFormat = valueFormat; effectDescription.Value = this.ComputeReadableFloat((float)obj, round, valueFormat, neutralValue); if (string.IsNullOrEmpty(effectDescription.Value)) { return(null); } if ((float)obj < 0f && (modifierDescriptor.Operation == SimulationModifierDescriptor.ModifierOperation.Addition || modifierDescriptor.Operation == SimulationModifierDescriptor.ModifierOperation.Percent)) { effectDescription.Operator = string.Empty; } } else if (obj is StaticString) { if (context != null) { obj = context.GetPropertyValue(obj as StaticString); } else if (simulationDescriptor.SimulationPropertyDescriptors != null) { StaticString staticString = obj as StaticString; for (int i = 0; i < simulationDescriptor.SimulationPropertyDescriptors.Length; i++) { if (staticString != null && simulationDescriptor.SimulationPropertyDescriptors[i].Name == staticString) { obj = simulationDescriptor.SimulationPropertyDescriptors[i].BaseValue; break; } } } if (obj is StaticString) { effectDescription.Value = this.ComputePropertySymbol(obj.ToString()); } else { effectDescription.ValueFloat = (float)obj; effectDescription.ValueFormat = valueFormat; effectDescription.Value = this.ComputeReadableFloat((float)obj, round, valueFormat, neutralValue); if (string.IsNullOrEmpty(effectDescription.Value)) { return(null); } } } string empty2 = string.Empty; if (modifierDescriptor.CountPath != null && modifierDescriptor.CountPath.Length > 0 && modifierDescriptor.CountPath[0].Length > 0) { this.GetScope(modifierDescriptor.CountPath, out empty2); } effectDescription.By = empty2; return(effectDescription); }
protected EffectDescription ParseBinaryModifier(SimulationDescriptor simulationDescriptor, BinarySimulationModifierDescriptor modifierDescriptor, SimulationObject context = null, bool forcePercent = false) { EffectDescription effectDescription = new EffectDescription(); bool round = false; string valueFormat = string.Empty; string empty = string.Empty; float neutralValue = this.ComputeOperationTypeToken(modifierDescriptor.Operation, ref empty, ref valueFormat, ref round); effectDescription.Operator = empty; if (forcePercent) { valueFormat = "#####0%"; } bool flag = false; string empty2 = string.Empty; string empty3 = string.Empty; float num = this.ComputeOperationTypeToken(modifierDescriptor.BinaryOperation, ref empty3, ref empty2, ref flag); object obj = modifierDescriptor.LeftPrecomputedValue; object obj2 = modifierDescriptor.RightPrecomputedValue; if (context != null && !modifierDescriptor.IsBindOnSource) { if (obj is StaticString) { obj = context.GetPropertyValue(obj as StaticString); } if (obj2 is StaticString) { obj2 = context.GetPropertyValue(obj2 as StaticString); } } else if (simulationDescriptor.SimulationPropertyDescriptors != null) { StaticString staticString = obj as StaticString; StaticString staticString2 = obj2 as StaticString; for (int i = 0; i < simulationDescriptor.SimulationPropertyDescriptors.Length; i++) { if (staticString != null && simulationDescriptor.SimulationPropertyDescriptors[i].Name == staticString && simulationDescriptor.SimulationPropertyDescriptors[i].BaseValue != 0f) { obj = simulationDescriptor.SimulationPropertyDescriptors[i].BaseValue; staticString = null; } if (staticString2 != null && simulationDescriptor.SimulationPropertyDescriptors[i].Name == staticString2 && simulationDescriptor.SimulationPropertyDescriptors[i].BaseValue != 0f) { obj2 = simulationDescriptor.SimulationPropertyDescriptors[i].BaseValue; staticString2 = null; } } } if (context != null && modifierDescriptor.FindStringValueForParserCalculation) { if (obj is StaticString) { obj = context.GetPropertyValue(obj as StaticString); } if (obj2 is StaticString) { obj2 = context.GetPropertyValue(obj2 as StaticString); } } if (obj is float && obj2 is float) { float num2 = this.ExecuteOperation(modifierDescriptor.BinaryOperation, (float)obj, (float)obj2); if (num2 < 0f && (modifierDescriptor.Operation == SimulationModifierDescriptor.ModifierOperation.Addition || modifierDescriptor.Operation == SimulationModifierDescriptor.ModifierOperation.Percent)) { effectDescription.Operator = string.Empty; } effectDescription.ValueFloat = num2; effectDescription.ValueFormat = valueFormat; effectDescription.Value = this.ComputeReadableFloat(num2, round, valueFormat, neutralValue); } else if (modifierDescriptor.BinaryOperation == SimulationModifierDescriptor.ModifierOperation.Multiplication && (obj is StaticString || obj2 is StaticString)) { if (obj is StaticString && obj2 is float) { obj = obj2; obj2 = modifierDescriptor.LeftPrecomputedValue; } if (obj2 is StaticString) { effectDescription.Per = this.ComputePropertySymbol(obj2 as StaticString); } if (obj is float) { effectDescription.ValueFloat = (float)obj; effectDescription.ValueFormat = valueFormat; effectDescription.Value = this.ComputeReadableFloat((float)obj, round, valueFormat, neutralValue); } else if (obj is StaticString) { effectDescription.Value = this.ComputePropertySymbol(obj as StaticString); } } else if (obj is float) { effectDescription.ValueFloat = (float)obj; effectDescription.ValueFormat = valueFormat; effectDescription.Value = this.ComputeReadableFloat((float)obj, round, valueFormat, neutralValue); } else { effectDescription.Value = string.Concat(new string[] { obj.ToString(), " ", empty3, " ", obj2.ToString() }); } if (string.IsNullOrEmpty(effectDescription.Value)) { return(null); } return(effectDescription); }
private void setEffects() { //Interactive3DLevel2ReverbEffect en = (Interactive3DLevel2ReverbEffect)_sound.GetEffects(0); //EffectsInteractive3DLevel2Reverb enviroEffect = en.AllParameters; //enviroEffect. //enviroEffects.DecayHfRatio = 2.0f; //enviroEffects.DecayTime = 20.0f; //enviroEffects.Density = 1.0f; //enviroEffects.Diffusion = 2.0f; //enviroEffect.Reflections = 1000; //en.AllParameters = enviroEffect; //return; if (Configer.Effects.Count > 0) { EffectDescription[] effs = new EffectDescription[Configer.Effects.Count]; for (int i = 0; i < effs.Length; i++) { switch (Configer.Effects[i]) { case AudioEffects.Chorus: effs[i].GuidEffectClass = DSoundHelper.StandardChorusGuid; break; case AudioEffects.Compressor: effs[i].GuidEffectClass = DSoundHelper.StandardCompressorGuid; break; case AudioEffects.Distortion: effs[i].GuidEffectClass = DSoundHelper.StandardDistortionGuid; break; case AudioEffects.Echo: effs[i].GuidEffectClass = DSoundHelper.StandardEchoGuid; break; case AudioEffects.Flanger: effs[i].GuidEffectClass = DSoundHelper.StandardFlangerGuid; break; case AudioEffects.Gargle: effs[i].GuidEffectClass = DSoundHelper.StandardGargleGuid; break; case AudioEffects.I3DLevel2Reverb: effs[i].GuidEffectClass = DSoundHelper.StandardInteractive3DLevel2ReverbGuid; break; case AudioEffects.ParamEq: effs[i].GuidEffectClass = DSoundHelper.StandardParamEqGuid; break; case AudioEffects.WavesReverb: effs[i].GuidEffectClass = DSoundHelper.StandardWavesReverbGuid; break; default: break; } } _sound.SetEffects(effs); for (int i = 0; i < effs.Length; i++) { switch (Configer.Effects[i]) { case AudioEffects.Chorus: ChorusEffect chorus = (ChorusEffect)_sound.GetEffects(i); EffectsChorus chorus_params = chorus.AllParameters; chorus_params.Delay = 15.0f; chorus_params.Depth = ChorusEffect.DepthMax; chorus_params.Phase = ChorusEffect.PhaseNegative90; chorus_params.Waveform = ChorusEffect.WaveSin; chorus_params.WetDryMix = 50.0f; chorus.AllParameters = chorus_params; break; case AudioEffects.Compressor: break; case AudioEffects.Distortion: break; case AudioEffects.Echo: EchoEffect echo = (EchoEffect)_sound.GetEffects(i); EffectsEcho echo_params = echo.AllParameters; echo_params.LeftDelay = 0.9f; /*echo_params.RightDelay = 77.0f; * echo_params.Feedback = 9.0f; * echo_params.PanDelay = 1; * echo_params.WetDryMix = 9.0f; * echo.AllParameters = echo_params;*/ break; case AudioEffects.Flanger: break; case AudioEffects.Gargle: break; case AudioEffects.I3DLevel2Reverb: Interactive3DLevel2ReverbEffect env = (Interactive3DLevel2ReverbEffect)_sound.GetEffects(i); EffectsInteractive3DLevel2Reverb enviroEffects = env.AllParameters; //enviroEffects.DecayHfRatio = 2.0f; //enviroEffects.DecayTime = 20.0f; //enviroEffects.Density = 1.0f; //enviroEffects.Diffusion = 2.0f; enviroEffects.Reflections = 1000; //enviroEffects.Reverb = 2; env.AllParameters = enviroEffects; break; case AudioEffects.ParamEq: break; case AudioEffects.WavesReverb: break; default: break; } } } }
public static T SetEffectDescription <T>(this T entity, EffectDescription value) where T : AmmunitionDescription { entity.SetField("effectDescription", value); return(entity); }
/// <summary> /// Initializes DirectInput. /// </summary> private bool InitializeDirectInput() { try { //Enumerate all joysticks that are attached to the system and have FF capabilities foreach (DeviceInstance instanceDevice in Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.ForceFeeback | EnumDevicesFlags.AttachedOnly)) { applicationDevice = new Device(instanceDevice.InstanceGuid); foreach (DeviceObjectInstance instanceObject in applicationDevice.GetObjects(DeviceObjectTypeFlags.Axis)) // Get info about all the FF axis on the device { int[] temp; if ((instanceObject.Flags & (int)ObjectInstanceFlags.Actuator) != 0) { if (null != axis) { temp = new int[axis.Length + 1]; axis.CopyTo(temp,0); axis = temp; } else { axis = new int[1]; } // Store the offset of each axis. axis[axis.Length - 1] = instanceObject.Offset; // Don't need to enumerate any more if 2 were found. if (2 == axis.Length) break; } } if (null == applicationDevice) { MessageBox.Show("No force feedback devices found attached to the system. Sample will now exit.", "No suitable device", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } if (axis.Length - 1 >= 1) // Grab any device that contains at least one axis. break; else { axis = null; applicationDevice.Dispose(); applicationDevice = null; } } //Turn off autocenter applicationDevice.Properties.AutoCenter = false; //Set the format of the device to that of a joystick applicationDevice.SetDataFormat(DeviceDataFormat.Joystick); //Enumerate all the effects on the device foreach (EffectInformation ei in applicationDevice.GetEffects(EffectType.All)) { // Handles the enumeration of effects. EffectObject effectSelected; EffectDescription description = new EffectDescription(); Effect eff; if (DInputHelper.GetTypeCode(ei.EffectType) == (int)EffectType.CustomForce) { // Can't create a custom force without info from the hardware vendor, so skip this effect. continue; } /*else if (DInputHelper.GetTypeCode(ei.EffectType) == (int)EffectType.Periodic) { // This is to filter out any Periodic effects. There are known // issues with Periodic effects that will be addressed post-developer preview. continue; }*/ else if (DInputHelper.GetTypeCode(ei.EffectType) == (int)EffectType.Hardware) { if ((ei.StaticParams & (int)EffectParameterFlags.TypeSpecificParams) != 0) // Can't create a hardware force without info from the hardware vendor. continue; } // Fill in some generic values for the effect. eff = FillEffStruct((EffectType)ei.EffectType); // Create the effect, using the passed in guid. effectSelected = new EffectObject(ei.EffectGuid, eff, applicationDevice); // Fill in the EffectDescription structure. description.effectSelected = effectSelected; description.info = ei; // Add this effect to the listbox, displaying the name of the effect. lstEffects.Items.Add(description); } if (0 == lstEffects.Items.Count) { // If this device has no downloadable effects, end the app. MessageBox.Show("This device does not contain any downloadable effects, app will exit."); // The app will validate all DirectInput objects in the frmMain_Load() event. // When one is found missing, this will cause the app to exit. } // Set the cooperative level of the device as an exclusive // foreground device, and attach it to the form's window handle. applicationDevice.SetCooperativeLevel(this, CooperativeLevelFlags.Foreground | CooperativeLevelFlags.Exclusive); // Make the first index of the listbox selected lstEffects.SelectedIndex = 0; return true; } catch { MessageBox.Show("No force feedback devices found attached to the system. Sample will now exit.", "No suitable device", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } }
public void ParseSimulationDescriptor(SimulationDescriptor descriptor, List <EffectDescription> effectDescriptions, StaticString defaultClass, bool displayEmptyDescriptors = false, SimulationObject context = null, bool isContextTheSource = true, bool isForceOn = false, bool parseTitle = false) { if (descriptor == null) { throw new ArgumentNullException("descriptor"); } GuiElement guiElement; if (this.GuiService.GuiPanelHelper.TryGetGuiElement(descriptor.Name, out guiElement) && guiElement is ExtendedGuiElement) { ExtendedGuiElement extendedGuiElement = guiElement as ExtendedGuiElement; if (extendedGuiElement.TooltipElement != null) { if (!string.IsNullOrEmpty(extendedGuiElement.TooltipElement.EffectOverride)) { EffectDescription effectDescription = new EffectDescription(); effectDescription.Override = AgeLocalizer.Instance.LocalizeString(extendedGuiElement.TooltipElement.EffectOverride); if (extendedGuiElement.Name.ToString().Contains("Bonus1Value")) { effectDescription.Override = effectDescription.Override.Replace("+500", "+" + 500f * (float)this.GetGameSpeed() / 2f); } else if (extendedGuiElement.Name.ToString().Contains("Bonus2Value")) { effectDescription.Override = effectDescription.Override.Replace("+1000", "+" + 1000f * (float)this.GetGameSpeed() / 2f); } if (parseTitle) { effectDescription.Title = AgeLocalizer.Instance.LocalizeString(guiElement.Title); } effectDescriptions.Add(effectDescription); } if (extendedGuiElement.TooltipElement.Ignore) { return; } } } if (descriptor.SimulationModifierDescriptors == null) { if (this.GuiService.GuiPanelHelper.TryGetGuiElement(descriptor.Name, out guiElement)) { if (guiElement is ExtendedGuiElement) { ExtendedGuiElement extendedGuiElement2 = guiElement as ExtendedGuiElement; if (extendedGuiElement2.TooltipElement != null && extendedGuiElement2.TooltipElement.Ignore) { return; } } EffectDescription effectDescription2 = new EffectDescription(); effectDescription2.Override = AgeLocalizer.Instance.LocalizeString(guiElement.Title); if (guiElement.Name == "TechnologyNecrophages8") { effectDescription2.Override = effectDescription2.Override.Replace("+1", "+" + this.GetGameSpeed()); } if (parseTitle) { effectDescription2.Title = AgeLocalizer.Instance.LocalizeString(guiElement.Title); } effectDescription2.On = this.ComputeReadableString(defaultClass, false); effectDescriptions.Add(effectDescription2); } return; } bool flag = false; if (parseTitle) { flag = true; } for (int i = 0; i < descriptor.SimulationModifierDescriptors.Length; i++) { SimulationModifierDescriptor simulationModifierDescriptor = descriptor.SimulationModifierDescriptors[i]; if (simulationModifierDescriptor.Operation != SimulationModifierDescriptor.ModifierOperation.Force && !simulationModifierDescriptor.TooltipHidden) { EffectDescription effectDescription3 = null; this.ParseModifier(descriptor, simulationModifierDescriptor, defaultClass, context, isContextTheSource, out effectDescription3, isForceOn); if (effectDescription3 != null) { if (context != null && isContextTheSource) { effectDescription3.From = this.ComputeReadableString(descriptor.Name, true); } if (flag) { effectDescription3.Title = AgeLocalizer.Instance.LocalizeString("%" + descriptor.Name + "Title"); flag = false; } effectDescriptions.Add(effectDescription3); } } } }
public SpellBuilder SetEffectDescription(EffectDescription effectDescription) { Definition.SetEffectDescription(effectDescription); return(this); }
private void updateSoundEffects(bool newEffects) { if (_conf.SoundEffects.Count == 0) { _conf.SoundEffects[AudioEffects.ParamEq] = 1; } int i = 0; bool wasPlayed = _sound.Status.Looping || _sound.Status.Playing; bool looped = _sound.Status.Looping; if (newEffects) { EffectDescription[] effs = new EffectDescription[_conf.SoundEffects.Count]; foreach (AudioEffects eff in _conf.SoundEffects.Keys) { switch (eff) { case AudioEffects.Chorus: effs[i].GuidEffectClass = DSoundHelper.StandardChorusGuid; break; case AudioEffects.Compressor: effs[i].GuidEffectClass = DSoundHelper.StandardCompressorGuid; break; case AudioEffects.Distortion: effs[i].GuidEffectClass = DSoundHelper.StandardDistortionGuid; break; case AudioEffects.Echo: effs[i].GuidEffectClass = DSoundHelper.StandardEchoGuid; break; case AudioEffects.Flanger: effs[i].GuidEffectClass = DSoundHelper.StandardFlangerGuid; break; case AudioEffects.Gargle: effs[i].GuidEffectClass = DSoundHelper.StandardGargleGuid; break; case AudioEffects.I3DLevel2Reverb: effs[i].GuidEffectClass = DSoundHelper.StandardInteractive3DLevel2ReverbGuid; break; case AudioEffects.ParamEq: effs[i].GuidEffectClass = DSoundHelper.StandardParamEqGuid; break; case AudioEffects.WavesReverb: effs[i].GuidEffectClass = DSoundHelper.StandardWavesReverbGuid; break; default: break; } i += 1; } _sound.Stop(); _sound.SetEffects(effs); } i = 0; foreach (AudioEffects eff in _conf.SoundEffects.Keys) { float val = (float)_conf.SoundEffects[eff]; switch (eff) { case AudioEffects.Chorus: val += 40; ChorusEffect chorus = (ChorusEffect)_sound.GetEffects(i); EffectsChorus chorus_params = chorus.AllParameters; chorus_params.Delay = 10 + val / (float)10; // 15.0f; chorus_params.Depth = ChorusEffect.DepthMax - 80 + val; chorus_params.Phase = ChorusEffect.PhaseNegative180; chorus_params.Waveform = ChorusEffect.WaveTriangle; chorus_params.WetDryMix = val + val / 5 - 20; // 50.0f; chorus.AllParameters = chorus_params; break; case AudioEffects.Compressor: //CompressorEffect com = (CompressorEffect)_sound.GetEffects(i); //EffectsCompressor ecom = com.AllParameters; // ecom.Threshold = ((CompressorEffect.ThresholdMax - CompressorEffect.ThresholdMin) / 100) * val; // com.AllParameters = ecom; break; case AudioEffects.Distortion: val += 10; DistortionEffect dis = (DistortionEffect)_sound.GetEffects(i); EffectsDistortion dis_params = dis.AllParameters; dis_params.Gain = -35 + val; dis_params.Edge = val - 5; dis_params.PostEqBandwidth = (float)(val % 99) * 20 + 2000; dis_params.PostEqCenterFrequency = (float)(val % 99) * 20 + 2000; // dis_params.PreLowpassCutoff = (float)(_conf.SoundEffects[eff] + 1) ; dis.AllParameters = dis_params; break; case AudioEffects.Gargle: GargleEffect gar = (GargleEffect)_sound.GetEffects(i); EffectsGargle egar = (EffectsGargle)gar.AllParameters; egar.RateHz = (int)val * 25; gar.AllParameters = egar; break; case AudioEffects.Echo: /*Interactive3DLevel2ReverbEffect env1 = (Interactive3DLevel2ReverbEffect)_sound.GetEffects(i); * EffectsInteractive3DLevel2Reverb enviroEffects1 = env1.AllParameters; * enviroEffects1.Reflections = 10 * _conf.SoundEffects[eff]; * enviroEffects1.Reverb = 2 * _conf.SoundEffects[eff]; * enviroEffects1.Diffusion = 0.1f * _conf.SoundEffects[eff]; * env1.AllParameters = enviroEffects1; * break;*/ EchoEffect echo = (EchoEffect)_sound.GetEffects(i); EffectsEcho echo_params = echo.AllParameters; echo_params.LeftDelay = (_conf.SoundEffects[eff] + 1) * 5; // 250.0f; echo_params.RightDelay = (_conf.SoundEffects[eff] + 1) * 5; // 250.0f; //echo_params.RightDelay = 1.0f * _conf.SoundEffects[eff]; echo_params.Feedback = val; //20;//1 + _conf.SoundEffects[eff] ;// 85.0f; echo_params.PanDelay = 1; echo_params.WetDryMix = (_conf.SoundEffects[eff]) + 1; echo.AllParameters = echo_params; break; case AudioEffects.Flanger: FlangerEffect flan = (FlangerEffect)_sound.GetEffects(i); EffectsFlanger eflan = flan.AllParameters; val += 40; //eflan.Delay = FlangerEffect.DelayMax + 80 - val; eflan.Depth = FlangerEffect.DepthMax - 80 + val; eflan.Phase = FlangerEffect.Phase90; eflan.Waveform = FlangerEffect.WaveTriangle; eflan.WetDryMix = FlangerEffect.WetDryMixMax - val / 5; // +val / 5 - 20;// 50.0f; flan.AllParameters = eflan; break; case AudioEffects.I3DLevel2Reverb: Interactive3DLevel2ReverbEffect env = (Interactive3DLevel2ReverbEffect)_sound.GetEffects(i); EffectsInteractive3DLevel2Reverb enviroEffects = env.AllParameters; enviroEffects.DecayHfRatio = 2.0f; enviroEffects.DecayTime = 20.0f; enviroEffects.Density = 1.0f; enviroEffects.Diffusion = 2.0f; enviroEffects.Reflections = (int)(val / 10); enviroEffects.Reverb = 2; env.AllParameters = enviroEffects; break; case AudioEffects.ParamEq: break; case AudioEffects.WavesReverb: val += 85; WavesReverbEffect wrev = (WavesReverbEffect)_sound.GetEffects(i); EffectsWavesReverb ewrev = wrev.AllParameters; //ewrev.ReverbMix = (float)_conf.SoundEffects[eff] / (float)100; ewrev.ReverbTime = val * 20; //ewrev.HighFrequencyRtRatio = (float)val / (float)100; ewrev.ReverbMix = -95.5f + (float)val; // (val >= 96) ? 0 : val - 96; //MessageBox.Show(String.Format("{0} / {1}, {2} / {3}", WavesReverbEffect.ReverbMixMin, WavesReverbEffect.ReverbTimeMax, WavesReverbEffect.ReverbTimeMin, WavesReverbEffect.ReverbTimeMax)); //MessageBox.Show(string.Format("{0} - {1} - {2}", WavesReverbEffect.ReverbTimeMin,WavesReverbEffect.ReverbMixMin, WavesReverbEffect.HighFrequencyRtRatioMin), ""); wrev.AllParameters = ewrev; break; default: break; } i += 1; } if (newEffects && wasPlayed) { _sound.Play(0, looped ? BufferPlayFlags.Looping : BufferPlayFlags.Default); } }