예제 #1
0
        protected virtual void Execute(object triggerMessage)
        {
            var effectParameters = new EffectParameters
            {
                Source         = this,
                TriggerMessage = triggerMessage
            };

            var effect = _p.Effect().Initialize(effectParameters, Game);

            if (_p.TargetSelector.Count > 0)
            {
                Enqueue(new SetTriggeredAbilityTarget(
                            OwningCard.Controller,
                            p =>
                {
                    p.Effect           = effect;
                    p.TargetSelector   = _p.TargetSelector;
                    p.MachineRules     = _p.Rules;
                    p.UsesStack        = _p.UsesStack;
                    p.DistributeAmount = _p.DistributeAmount;
                }));

                return;
            }
            Resolve(effect);
        }
예제 #2
0
        public virtual Effect Initialize(EffectParameters p, Game game, bool evaluateDynamicParameters = true)
        {
            Game            = game;
            Source          = p.Source;
            Targets         = p.Targets ?? new Targets();
            _triggerMessage = p.TriggerMessage;
            X  = p.X;
            Id = game.Recorder.CreateId(this);

            _wasResolved.Initialize(game.ChangeTracker);

            foreach (var parameter in _dynamicParameters)
            {
                parameter.Initialize(ChangeTracker);
            }

            if (evaluateDynamicParameters)
            {
                foreach (var parameter in _dynamicParameters)
                {
                    parameter.EvaluateOnInit(this, Game);
                }
            }

            Initialize();
            return(this);
        }
 //used to draw collidable primitives that a value associated with them e.g. health
 public PickupCollidablePrimitiveObject(string id, ActorType actorType, Transform3D transform,
                                        EffectParameters effectParameters, StatusType statusType, IVertexData vertexData,
                                        ICollisionPrimitive collisionPrimitive, ObjectManager objectManager, PickupParameters pickupParameters)
     : base(id, actorType, transform, effectParameters, statusType, vertexData, collisionPrimitive, objectManager)
 {
     this.pickupParameters = pickupParameters;
 }
예제 #4
0
        public new object Clone()
        {
            PathMoveTile pathMoveTile = new PathMoveTile(ID, ActorType, StatusType, Transform3D.Clone() as Transform3D,
                                                         EffectParameters.Clone() as OurEffectParameters, Model, IsBlocking, TileType);

            pathMoveTile.ControllerList.AddRange(GetControllerListClone());
            return(pathMoveTile);
        }
예제 #5
0
        public new object Clone()
        {
            Tile tile = new Tile("clone - " + ID, ActorType, StatusType, Transform3D.Clone() as Transform3D,
                                 EffectParameters.Clone() as OurEffectParameters, Model, IsBlocking, TileType);

            tile.ControllerList.AddRange(GetControllerListClone());
            return(tile);
        }
예제 #6
0
        /// <summary>
        /// This method updates the selected filter. This
        /// method is called once the user has hit the filter
        /// button in the filter queue on the MainWindow.
        /// </summary>
        public void UpdateFilter(String filterType, String inputElement, EffectParameters parameters)
        {
            FilterInfo info = new FilterInfo(filterType, parameters);

            filtersList[inputElement] = info;

            ApplyFilters(filterType);
        }
예제 #7
0
        public ModelObject(string id, ActorType actorType, StatusType statusType,
                           Transform3D transform, EffectParameters effectParameters, Model model)
            : base(id, actorType, statusType, transform, effectParameters)
        {
            this.model = model;

            InitializeBoneTransforms();
        }
예제 #8
0
        public new object Clone()
        {
            CollidablePrimitiveObject primitive = new CollidablePrimitiveObject(ID, ActorType, StatusType, Transform3D.Clone() as Transform3D,
                                                                                EffectParameters.Clone() as EffectParameters, IVertexData.Clone() as IVertexData, CollisionPrimitive.Clone() as ICollisionPrimitive,
                                                                                ObjectManager);

            primitive.ControllerList.AddRange(GetControllerListClone());
            return(primitive);
        }
예제 #9
0
 public new object Clone()
 {
     return(new CollidableObject("clone - " + ID,                              //deep
                                 ActorType,                                    //deep
                                 StatusType,
                                 Transform3D.Clone() as Transform3D,           //deep
                                 EffectParameters.Clone() as EffectParameters, //hybrid - shallow (texture and effect) and deep (all other fields)
                                 Model));                                      //shallow i.e. a reference
 }
        public new object Clone()
        {
            MovingObstacleSpawner spawner = new MovingObstacleSpawner(ID, ActorType, StatusType, Transform3D.Clone() as Transform3D,
                                                                      EffectParameters.Clone() as EffectParameters, IVertexData.Clone() as IVertexData, CollisionPrimitive.Clone() as ICollisionPrimitive,
                                                                      ObjectManager);

            spawner.ControllerList.AddRange(GetControllerListClone());
            return(spawner);
        }
        public new object Clone()
        {
            MovingPlatformTile platform = new MovingPlatformTile("clone - " + ID, ActorType, StatusType,
                                                                 Transform3D.Clone() as Transform3D,
                                                                 EffectParameters.Clone() as OurEffectParameters, Model, IsBlocking, TileType);

            platform.ControllerList.AddRange(GetControllerListClone());

            return(platform);
        }
예제 #12
0
        /// <summary>
        /// Initializes filter window. If call comes from
        /// the filter menu, the remove button is unenabled.
        /// </summary>
        public FilterWindow(String filterType, String inputElement, EffectParameters parameters)
        {
            InitializeComponent();
            this.filterType   = filterType;
            this.inputElement = inputElement;
            this.parameters   = parameters;

            FilterTitle.Text = filterType;

            if (inputElement == "MenuItem")
            {
                RemoveButton.IsEnabled = false;
            }
            else
            {
                RemoveButton.IsEnabled = true;
            }

            Parameter1.Visibility = Visibility.Hidden;
            value1.Visibility     = Visibility.Hidden;
            Parameter2.Visibility = Visibility.Hidden;
            value2.Visibility     = Visibility.Hidden;
            Parameter3.Visibility = Visibility.Hidden;
            value3.Visibility     = Visibility.Hidden;
            Parameter4.Visibility = Visibility.Hidden;
            value4.Visibility     = Visibility.Hidden;
            Parameter5.Visibility = Visibility.Hidden;
            value5.Visibility     = Visibility.Hidden;
            Parameter6.Visibility = Visibility.Hidden;
            value6.Visibility     = Visibility.Hidden;
            Parameter7.Visibility = Visibility.Hidden;
            value7.Visibility     = Visibility.Hidden;
            Parameter8.Visibility = Visibility.Hidden;
            value8.Visibility     = Visibility.Hidden;

            int       count = 1;
            TextBlock text;
            Slider    slide;

            foreach (Parameter parameter in parameters.GetParams().Values)
            {
                text            = (TextBlock)this.FindName("Parameter" + count);
                text.Text       = parameter.name;
                text.Visibility = Visibility.Visible;

                slide               = (Slider)this.FindName("value" + count);
                slide.Value         = parameter.value;
                slide.Minimum       = parameter.minValue;
                slide.Maximum       = parameter.maxValue;
                slide.TickFrequency = parameter.frequency;
                slide.Visibility    = Visibility.Visible;

                count++;
            }
        }
예제 #13
0
 public HeroPlayerObject(string id, ActorType actorType, StatusType statusType,
                         Transform3D transform, EffectParameters effectParameters, Model model,
                         Keys[] moveKeys, float radius, float height, float accelerationRate,
                         float decelerationRate, float jumpHeight, Vector3 translationOffset,
                         KeyboardManager keyboardManager)
     : base(id, actorType, statusType, transform, effectParameters, model, moveKeys,
            radius, height, accelerationRate, decelerationRate, jumpHeight, translationOffset, keyboardManager)
 {
     //step 1 - add code to listen for CDCR event
     this.Body.CollisionSkin.callbackFn += HandleCollision;
 }
예제 #14
0
        //used to draw collidable primitives that have a texture i.e. use VertexPositionColor vertex types only
        public CollidablePrimitiveObject(string id, ActorType actorType, StatusType statusType, Transform3D transform3D,
                                         EffectParameters effectParameters, IVertexData vertexData,
                                         ICollisionPrimitive collisionPrimitive, ObjectManager objectManager)
            : base(id, actorType, statusType, transform3D, effectParameters, vertexData)
        {
            this.effectParameters   = effectParameters;
            this.collisionPrimitive = collisionPrimitive;

            //unusual to pass this in but we use it to test for collisions - see Update();
            this.objectManager = objectManager;
        }
예제 #15
0
 void SetParamaters(Effect effect, EffectParameters parameters, EffectParameterFlags flags)
 {
     if (parameters == null)
     {
         return;
     }
     // Do not restart playing effect.
     flags |= effect.Status == EffectStatus.Playing
         ? EffectParameterFlags.NoRestart : EffectParameterFlags.Start;
     effect.SetParameters(parameters, flags);
 }
 public new object Clone()
 {
     return(new CollidablePickupObject("clone - " + ID,                                   //deep
                                       ActorType,                                         //deep
                                       StatusType,                                        //deep
                                       Transform3D.Clone() as Transform3D,                //deep
                                       EffectParameters.Clone() as EffectParameters,      //deep
                                       this.IVertexData,                                  //shallow - its ok if objects refer to the same vertices
                                       CollisionPrimitive.Clone() as ICollisionPrimitive, //deep
                                       ObjectManager,                                     //shallow - reference
                                       pickupParameters.Clone() as PickupParameters));    //deep
 }
예제 #17
0
        EffectParameters GetParameters()
        {
            var p = new EffectParameters();

            p.Flags                 = EffectFlags.Cartesian | EffectFlags.ObjectIds;
            p.StartDelay            = 0;
            p.Duration              = unchecked ((int)INFINITE);
            p.SamplePeriod          = 0;
            p.TriggerButton         = unchecked ((int)DIEB_NOTRIGGER);
            p.TriggerRepeatInterval = unchecked ((int)INFINITE);
            return(p);
        }
 public InteractableObject(string id,
                           ActorType actorType,
                           StatusType statusType,
                           Transform3D transform,
                           EffectParameters effectParameters,
                           Model model,
                           string name,
                           float interactDistance) :
     base(id, actorType, statusType, transform, effectParameters, model)
 {
     this.name             = name;
     this.interactDistance = interactDistance;
 }
예제 #19
0
 public PlayerObject(string id, ActorType actorType, StatusType statusType,
                     Transform3D transform,
                     EffectParameters effectParameters, Model model,
                     Keys[] moveKeys, float radius, float height, float accelerationRate,
                     float decelerationRate, float jumpHeight,
                     Vector3 translationOffset, KeyboardManager keyboardManager)
     : base(id, actorType, statusType, transform, effectParameters, model, radius, height, accelerationRate, decelerationRate)
 {
     this.moveKeys          = moveKeys;
     this.translationOffset = translationOffset;
     this.keyboardManager   = keyboardManager;
     this.jumpHeight        = jumpHeight;
 }
예제 #20
0
        public CharacterObject(string id, ActorType actorType, StatusType statusType,
                               Transform3D transform,
                               EffectParameters effectParameters, Model model,
                               float radius, float height, float accelerationRate, float decelerationRate)
            : base(id, actorType, statusType, transform, effectParameters, model)
        {
            Body               = new Character(accelerationRate, decelerationRate);
            Collision          = new CollisionSkin(Body);
            Body.ExternalData  = this;
            Body.CollisionSkin = Collision;
            Capsule capsule = new Capsule(Vector3.Zero, Matrix.CreateRotationX(MathHelper.PiOver2), radius, height);

            Collision.AddPrimitive(capsule, (int)MaterialTable.MaterialID.NormalSmooth);
        }
예제 #21
0
        /// <summary>
        /// This method adds the selected filter to the image. This
        /// method is called when the user hits the Apply button.
        /// This method takes the parameters and makes the call to
        /// apply the filter to the image.
        /// </summary>
        private void ApplyFilter(object sender, RoutedEventArgs e)
        {
            switch (filterType)
            {
            case "Echo":
                parameters = new EchoParameters(value1.Value, (float)value2.Value, Convert.ToInt32(value3.Value));
                break;

            case "Amplify":
                parameters = new AmplifyParameters((float)value1.Value);
                break;

            case "Bass Boost":
                parameters = new BassBoostParameters(value1.Value);
                break;

            case "Phaser":
                parameters = new PhaserParameters((int)value1.Value, (int)value2.Value, value3.Value, value4.Value, (int)value5.Value, (int)value6.Value, value7.Value);
                break;

            case "Fade In":
                parameters = new FadeInParameters((int)value1.Value);
                break;

            case "Fade Out":
                parameters = new FadeOutParameters((int)value1.Value);
                break;

            case "Distortion":
                parameters = new DistortionParameters((float)value1.Value, (int)value2.Value, value3.Value, value4.Value, value5.Value, (float)value6.Value, (float)value7.Value, (int)value8.Value);
                break;

            default:
                // Not a valid Filter
                break;
            }

            MainWindow window = (MainWindow)this.Owner;

            if (inputElement == "MenuItem")
            {
                Dispatcher.BeginInvoke(new ThreadStart(() => window.AddFilter(filterType, parameters)));
            }
            else
            {
                Dispatcher.BeginInvoke(new ThreadStart(() => window.UpdateFilter(filterType, inputElement, parameters)));
            }

            this.Close();
        }
예제 #22
0
 public HandHeldPickup(string id,
                       ActorType actorType,
                       StatusType statusType,
                       Transform3D transform,
                       EffectParameters effectParameters,
                       Model model,
                       string name,
                       float interactDistance,
                       Vector3 heldCoords) :
     base(id, actorType, statusType, transform, effectParameters, model,
          name, interactDistance)
 {
     this.heldCoords = heldCoords;
 }
예제 #23
0
        /// <summary>
        /// This method adds the selected filter to the image. This
        /// method is called once the user has set the parameters in
        /// the filter's window and hit Apply. This method takes the
        /// parameters and makes the call to apply the filter to the
        /// image.
        /// </summary>
        public void AddFilter(String filterType, EffectParameters parameters)
        {
            numFilters++;

            Button filter = (Button)this.FindName("Filter" + numFilters);

            filter.Content    = filterType;
            filter.Visibility = Visibility.Visible;

            FilterInfo info = new FilterInfo(filterType, parameters);

            filtersList.Add("Filter" + numFilters, info);

            ApplyFilters(filterType);
        }
예제 #24
0
        public new object Clone()
        {
            PrimitiveObject clone = new PrimitiveObject(ID, ActorType, StatusType, Transform3D.Clone() as Transform3D,
                                                        EffectParameters.Clone() as EffectParameters, vertexData.Clone()
                                                        as IVertexData);

            //if we ever want to clone prims that ALREADY have controllers
            //then we need to add cloning of controllers here
            foreach (Controller controller in this.ControllerList)
            {
                clone.ControllerList.Add(controller.Clone() as Controller);
            }

            return(clone);
        }
예제 #25
0
        public DudeAnimatedPlayerObject(string id, ActorType actorType, Transform3D transform,
                                        EffectParameters effectParameters, Keys[] moveKeys, float radius, float height,
                                        float accelerationRate, float decelerationRate,
                                        float moveSpeed, float rotationSpeed,
                                        float jumpHeight, Vector3 translationOffset,
                                        KeyboardManager keyboardManager)
            : base(id, actorType, transform, effectParameters, moveKeys, radius, height,
                   accelerationRate, decelerationRate, jumpHeight, translationOffset, keyboardManager)
        {
            //add extra constructor parameters like health, inventory etc...
            this.moveSpeed     = moveSpeed;
            this.rotationSpeed = rotationSpeed;

            //register for callback on CDCR
            this.CharacterBody.CollisionSkin.callbackFn += CollisionSkin_callbackFn;
        }
예제 #26
0
 public void SendFFBEffect(Guid effectGuid, EffectParameters effectParams)
 {
     if (this.Connected)
     {
         Effect effect = new Effect(this.joystick, effectGuid, effectParams);
         if (effect == null)
         //{
         //    effect.Start(loopCount, EffectPlayFlags.NoDownload);
         //}
         //else
         {
             // effect not supported
             throw new Exception(string.Format("Force Feedback Effect '{0}' is not supported.", effectGuid));
         }
     }
 }
        public CollidablePlayerObject(string id, ActorType actorType, StatusType statusType, Transform3D transform,
                                      EffectParameters effectParameters, IVertexData vertexData,
                                      ICollisionPrimitive collisionPrimitive, ObjectManager objectManager,
                                      Keys[] moveKeys, float moveSpeed, float rotationSpeed, KeyboardManager keyboardManager, Game game)
            : base(id, actorType, statusType, transform, effectParameters, vertexData, collisionPrimitive, objectManager)
        {
            this.moveKeys      = moveKeys;
            this.moveSpeed     = moveSpeed;
            this.rotationSpeed = 0.1f;

            //for movement
            this.keyboardManager = keyboardManager;
            this.game            = game;

            this.deathCount = 0;
        }
예제 #28
0
        public new object Clone()
        {
            ActivatableTile activatableTile = new ActivatableTile("clone - " + ID, ActorType, StatusType,
                                                                  Transform3D.Clone() as Transform3D,
                                                                  EffectParameters.Clone() as OurEffectParameters, Model, IsBlocking, TileType);

            if (ControllerList != null)
            {
                foreach (IController controller in ControllerList)
                {
                    activatableTile.ControllerList.Add(controller.Clone() as IController);
                }
            }

            return(activatableTile);
        }
예제 #29
0
        /// <summary>
        /// Runs the filter on the image using the specific filter
        /// type's ProcessBlock method.
        /// </summary>
        private void RunFilter(String filter, EffectParameters param, ref FloatToInt[] input, ref FloatToInt[] output, int length)
        {
            switch (filter)
            {
            case "Echo":
                Echo echo = new Echo((EchoParameters)param);
                echo.ProcessBlock(ref input, ref output, input.Length);
                break;

            case "Amplify":
                Amplify amplify = new Amplify((AmplifyParameters)param);
                amplify.ProcessBlock(ref input, ref output, input.Length);
                break;

            case "Bass Boost":
                BassBoost BassBoost = new BassBoost((BassBoostParameters)param);
                BassBoost.ProcessBlock(ref input, ref output, input.Length);
                break;

            case "Phaser":
                Phaser Phaser = new Phaser((PhaserParameters)param);
                Phaser.ProcessBlock(ref input, ref output, input.Length);
                break;

            case "Fade In":
                FadeIn FadeIn = new FadeIn((FadeInParameters)param);
                FadeIn.ProcessBlock(ref input, ref output, input.Length);
                break;

            case "Fade Out":
                FadeOut FadeOut = new FadeOut((FadeOutParameters)param);
                FadeOut.ProcessBlock(ref input, ref output, input.Length);
                break;

            case "Distortion":
                Distortion distortion = new Distortion((DistortionParameters)param);
                distortion.ProcessBlock(ref input, ref output, input.Length);
                break;

            default:
                StatusText.Content = "Invalid filter";
                break;
            }
        }
예제 #30
0
        void IManaSource.PayActivationCost()
        {
            Pay();

            if (_p.AdditionalEffects.Count > 0)
            {
                var effect = new CompoundEffect(
                    _p.AdditionalEffects.Select(factory => factory()).ToArray());

                var effectParameters = new EffectParameters
                {
                    Source = this,
                };

                effect.Initialize(effectParameters, Game);

                Resolve(effect, skipStack: true);
            }
        }
예제 #31
0
        public void Activate(ActivationParameters p)
        {
            _lastActivation.Value = Turn.TurnCount;

              var effects = new List<Effect>();

              for (var i = 0; i < p.Repeat; i++)
              {
            // create effect first, since some cost e.g Sacrifice can
            // put owning card to graveyard which will alter some card
            // properties e.g counters, power, toughness ...
            var effect = CreateEffect();

            var effectParameters = new EffectParameters
            {
              Source = this,
              Targets = p.Targets,
              X = p.X
            };

            effect.Initialize(effectParameters, Game);
            effects.Add(effect);
              }

              Pay(p);

              foreach (var effect in effects)
              {
            if (p.SkipStack)
            {
              Resolve(effect, true);
              continue;
            }

            Publish(new AbilityActivatedEvent(this, p.Targets));

            Resolve(effect, false);
            Publish(new ActivatedAbilityPutOnStackEvent(this, p.Targets));
              }
        }
예제 #32
0
파일: GamePad.cs 프로젝트: henke37/BizHawk
		// Note that this does not appear to work at this time. I probably need to have more infos.
		public void SetVibration(int left, int right)
		{
			int[] temp1, temp2;
			// my first clue that it doesnt work is that LEFT  and RIGHT _ARENT USED_
			// I should just look for C++ examples instead of trying to look for SlimDX examples

			var parameters = new EffectParameters
				{
					Duration = 0x2710,
					Gain = 0x2710,
					SamplePeriod = 0,
					TriggerButton = 0,
					TriggerRepeatInterval = 0x2710,
					Flags = EffectFlags.None
				};
			parameters.GetAxes(out temp1, out temp2);
			parameters.SetAxes(temp1, temp2);
			var effect = new Effect(joystick, EffectGuid.ConstantForce);
			effect.SetParameters(parameters);
			effect.Start(1);
		}
예제 #33
0
        protected virtual void Execute(object triggerMessage)
        {
            if (!IsEnabled)
            return;

              var effectParameters = new EffectParameters
              {
            Source = this,
            TriggerMessage = triggerMessage
              };

              var effect = _p.Effect().Initialize(effectParameters, Game);

              if (_p.TargetSelector.Count > 0)
              {
            Enqueue(new SetTriggeredAbilityTarget(
              OwningCard.Controller,
              p =>
            {
              p.Effect = effect;
              p.TargetSelector = _p.TargetSelector;
              p.MachineRules = _p.Rules;
            }));

            return;
              }
              Resolve(effect);
        }
예제 #34
0
        public void Cast(ActivationParameters p)
        {
            var parameters = new EffectParameters
            {
              Source = this,
              Targets = p.Targets,
              X = p.X
            };

              var effect = _p.Effect().Initialize(parameters, Game);

              if (p.PayCost)
              {
            _p.Cost.Pay(p.Targets, p.X);
              }

              if (p.SkipStack)
              {
            effect.QuickResolve();
            return;
              }

              if (_card.Is().Land)
              {
            _card.Controller.LandsPlayedCount++;

            effect.QuickResolve();
            Publish(new LandPlayedEvent(effect.Source.OwningCard));

            return;
              }

              Publish(new SpellCastEvent(_card, p.Targets));

              Stack.Push(effect);
              Publish(new SpellPutOnStackEvent(_card, p.Targets));
        }
예제 #35
0
        /// <summary>
        /// Creates an FFB effect, stores it at a given slot and starts its playback.
        /// </summary>
        /// <param name="data">
        /// Parameters of the effect to be created.
        /// </param>
        /// <returns>
        /// Returns true if successful, otherwise returns false.
        /// </returns>
        public bool SendFFBEffect(DataClasses.FFBEffectData data)
        {
            //Check if the device is properly initialized
            if (ffbDevice == null)
            {
                MessageBox.Show("Device not initialized.", FFBInspector.Properties.Resources.errCap_devError,
                                MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return false;
            }

            //If there is an effect already stored in this slot, remove it
            StopOneEffect(data.slot);

            int[] axes = new Int32[actuatorsObjectTypes.Count];
            int i = 0;
            foreach (int objt in actuatorsObjectTypes)
            {
                axes[i++] = objt;
            }

            //Set effect direction
            int[] dirs = data.effect.GetDirections();

            //Set the general effect parameters up
            EffectParameters eParams = new EffectParameters();
            eParams.Duration = data.effect.duration;
            eParams.Flags = EffectFlags.Cartesian | EffectFlags.ObjectIds;
            eParams.Gain = data.effect.gain;
            eParams.SetAxes(axes, dirs);
            eParams.StartDelay = data.effect.startDelay;
            eParams.SamplePeriod = 0; //Use the default sample period;
            eParams.TriggerButton = data.effect.trigButton;
            eParams.TriggerRepeatInterval = data.effect.trigRepInterval;

            //Set the type specific effect parameters up
            TypeSpecificParameters typeSpec = null;
            if (data.effect.effectGuid == EffectGuid.ConstantForce)
            {
                DataClasses.ConstantEffectTypeData cfEfd = (DataClasses.ConstantEffectTypeData)data.effect;
                typeSpec = new ConstantForce();
                typeSpec.AsConstantForce().Magnitude = cfEfd.magnitude;
            }
            else if (data.effect.effectGuid == EffectGuid.RampForce)
            {
                DataClasses.RampEffectTypeData rfEfd = (DataClasses.RampEffectTypeData)data.effect;
                typeSpec = new RampForce();
                typeSpec.AsRampForce().Start = rfEfd.start;
                typeSpec.AsRampForce().End = rfEfd.end;
            }
            else if (data.effect.effectGuid == EffectGuid.Sine || data.effect.effectGuid == EffectGuid.Triangle ||
                     data.effect.effectGuid == EffectGuid.Square ||
                     data.effect.effectGuid == EffectGuid.SawtoothUp ||
                     data.effect.effectGuid == EffectGuid.SawtoothDown)
            {
                DataClasses.PeriodicEffectTypeData pfEfd = (DataClasses.PeriodicEffectTypeData)data.effect;
                typeSpec = new PeriodicForce();
                typeSpec.AsPeriodicForce().Magnitude = pfEfd.magnitude;
                typeSpec.AsPeriodicForce().Offset = pfEfd.offset;
                typeSpec.AsPeriodicForce().Period = pfEfd.period;
                typeSpec.AsPeriodicForce().Phase = pfEfd.phase;
            }
            else if (data.effect.effectGuid == EffectGuid.Friction || data.effect.effectGuid == EffectGuid.Inertia ||
                     data.effect.effectGuid == EffectGuid.Damper || data.effect.effectGuid == EffectGuid.Spring)
            {
                DataClasses.ConditionEffectTypeData cdEfd = (DataClasses.ConditionEffectTypeData)data.effect;
                typeSpec = new ConditionSet();
                typeSpec.AsConditionSet().Conditions = new Condition[1];

                typeSpec.AsConditionSet().Conditions[0].DeadBand = cdEfd.deadBand;
                typeSpec.AsConditionSet().Conditions[0].Offset = cdEfd.offset;
                typeSpec.AsConditionSet().Conditions[0].NegativeCoefficient = cdEfd.negCoeff;
                typeSpec.AsConditionSet().Conditions[0].NegativeSaturation = cdEfd.negSat;
                typeSpec.AsConditionSet().Conditions[0].PositiveCoefficient = cdEfd.posCoeff;
                typeSpec.AsConditionSet().Conditions[0].PositiveSaturation = cdEfd.posSat;
            }
            eParams.Parameters = typeSpec;

            //Create an envelope
            if (data.envelope != null)
            {
                Envelope envp = new Envelope();
                envp.AttackLevel = data.envelope.attackLevel;
                envp.AttackTime = data.envelope.attackTime;
                envp.FadeLevel = data.envelope.fadeLevel;
                envp.FadeTime = data.envelope.fadeTime;

                eParams.Envelope = envp;
            }

            //Create an effect and add it to the list
            Effect ef;
            try
            {
                ef = new Effect(ffbDevice, data.effect.effectGuid, eParams);
                ffbEffects[data.slot] = ef;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Cannot create effect.\n" + ex.Message + "\n" + ex.Data,
                                FFBInspector.Properties.Resources.errCap_effError,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }

            return StartFFBEffect(ef);
        }