Example #1
0
        /// <summary>
        /// Run once per frame in order to manage the actor
        /// </summary>
        protected virtual void Update()
        {
            // Process each of the reactors effects
            for (int i = 0; i < _Reactors.Count; i++)
            {
                ReactorAction lReactor = _Reactors[i];
                if (lReactor._IsEnabled && lReactor._IsActive)
                {
                    lReactor.Update();
                }
            }

            // Process each of the active effects
            for (int i = 0; i < _Effects.Count; i++)
            {
                ActorCoreEffect lEffect   = _Effects[i];
                bool            lIsActive = lEffect.Update();

                // If the effect is no longer active, remove it
                if (!lIsActive)
                {
                    _Effects.RemoveAt(i);
                    i--;

                    lEffect.Release();
                }
            }
        }
Example #2
0
        /// <summary>
        /// Processes the effect definitions and updates the effects to match the definitions.
        /// </summary>
        public void InstantiateEffects()
        {
            int lDefCount = _EffectDefinitions.Count;

            // First, remove any extra motors that may exist
            for (int i = ActiveEffects.Count - 1; i >= lDefCount; i--)
            {
                ActiveEffects.RemoveAt(i);
            }

            // We need to match the motor definitions to the motors
            for (int i = 0; i < lDefCount; i++)
            {
                string lDefinition = _EffectDefinitions[i];

                Type lType = JSONSerializer.GetType(lDefinition);
                if (lType == null)
                {
                    continue;
                }

                ActorCoreEffect lEffect = null;

                // If don't have a motor matching the type, we need to create one
                if (ActiveEffects.Count <= i || !lType.Equals(ActiveEffects[i].GetType()))
                {
                    lEffect           = Activator.CreateInstance(lType) as ActorCoreEffect;
                    lEffect.ActorCore = this;

                    if (ActiveEffects.Count <= i)
                    {
                        ActiveEffects.Add(lEffect);
                    }
                    else
                    {
                        ActiveEffects[i] = lEffect;
                    }
                }
                // Grab the matching motor
                else
                {
                    lEffect = ActiveEffects[i];
                }

                // Fill the motor with data from the definition
                if (lEffect != null)
                {
                    lEffect.Deserialize(lDefinition);
                }
            }

            // Allow each motion to initialize now that his has been deserialized
            for (int i = 0; i < ActiveEffects.Count; i++)
            {
                ActiveEffects[i].Awake();
            }
        }
Example #3
0
        /// <summary>
        /// Run once per frame in order to manage the actor
        /// </summary>
        protected virtual void Update()
        {
            // Process each of the active effects
            for (int i = 0; i < _ActiveEffects.Count; i++)
            {
                ActorCoreEffect lEffect   = _ActiveEffects[i];
                bool            lIsActive = lEffect.Update();

                // If the effect is no longer active, remove it
                if (!lIsActive)
                {
                    _ActiveEffects.RemoveAt(i);
                    i--;

                    lEffect.Release();
                }
            }
        }