Esempio n. 1
0
        /// <summary>
        /// adds a new time data.
        /// </summary>
        /// <param name="data">new time data</param>
        public void AddSequence(TimeSequenceData data)
        {
            timeSequenceDataList.Add(data);

            SetOwnerEnable(data, false);

            UpdateDuration();
        }
Esempio n. 2
0
 /// <summary>
 /// enables/disables the scene owner
 /// </summary>
 /// <param name="data">time data</param>
 /// <param name="enable">enable flag</param>
 public static void SetOwnerEnable(TimeSequenceData data, bool enable)
 {
     if (data.Owner != null)
     {
         data.Owner.Enabled = enable;
         data.Owner.Visible = enable;
     }
 }
        /// <summary>
        /// changes the transform matrix of particle.
        /// </summary>
        /// <param name="transform">transform matrix</param>
        public void SetTransform(Matrix transform)
        {
            this.WorldTransform = transform;

            for (int i = 0; i < timeSequence.Count; i++)
            {
                TimeSequenceData sequence = timeSequence.GetSequence(i);

                Particle particle = sequence.Owner as Particle;
                particle.RootAxis       = this.RootAxis;
                particle.WorldTransform = this.WorldTransform;
            }
        }
        /// <summary>
        /// play the particle.
        /// </summary>
        public void Play()
        {
            for (int i = 0; i < timeSequence.Count; i++)
            {
                TimeSequenceData sequence = timeSequence.GetSequence(i);

                Particle particle = sequence.Owner as Particle;
                particle.RootAxis       = RootAxis;
                particle.WorldTransform = WorldTransform;
            }

            Reset();
        }
Esempio n. 5
0
        /// <summary>
        /// updates every time data that has been registered to the list.
        /// Time data whose start time has passed gets enabled.
        /// Time data whose duration time has passed gets disabled.
        /// </summary>
        /// <param name="gameTime"></param>
        protected override void OnUpdate(GameTime gameTime)
        {
            if (!infinite && !active)
            {
                return;
            }

            for (int i = 0; i < timeSequenceDataList.Count; i++)
            {
                TimeSequenceData data = timeSequenceDataList[i];

                if (data.Style == SequenceStyle.Disable)
                {
                    continue;
                }

                if (data.State == SequenceState.Active)
                {
                    //  If activate
                    if (data.SequenceInfo.Duration > 0.0f)
                    {
                        // If the Duration is 0, time is infinite
                        if (localTIme >= (data.SequenceInfo.StartTime +
                                          data.SequenceInfo.Duration))
                        {
                            data.State = SequenceState.None;
                            SetOwnerEnable(data, false);
                        }
                    }
                }
                else
                {
                    //  Starting time..
                    if (localTIme >= data.SequenceInfo.StartTime)
                    {
                        data.State = SequenceState.Active;
                        SetOwnerEnable(data, true);
                    }
                }
            }

            localTIme += (float)gameTime.ElapsedGameTime.TotalSeconds;

            //  Finished
            if (localTIme > duration)
            {
                active = false;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// configures the reference transform matrix.
        /// </summary>
        /// <param name="enabled"></param>
        /// <param name="matrix"></param>
        public void SetRefMatrix(bool enabled, Matrix?matrix)
        {
            for (int i = 0; i < timeSequenceDataList.Count; i++)
            {
                TimeSequenceData data = timeSequenceDataList[i];

                if (data.Owner is Particle)
                {
                    Particle particle = data.Owner as Particle;

                    particle.SetRefMatrixEnable(enabled);
                    particle.SetRefMatrix(matrix);
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// disables the owner.
        /// Stops when the owner is particle.
        /// </summary>
        public void Stop()
        {
            localTIme = 0.0f;
            active    = false;

            for (int i = 0; i < timeSequenceDataList.Count; i++)
            {
                TimeSequenceData data = timeSequenceDataList[i];

                data.State = SequenceState.None;
                SetOwnerEnable(data, false);

                if (data.Owner is Particle)
                {
                    Particle particle = data.Owner as Particle;

                    particle.Stop();
                }
            }
        }
        /// <summary>
        /// Creates using particle information.
        /// </summary>
        /// <param name="info">the particle information</param>
        /// <param name="resourcePath">the particle file</param>
        public void Create(ref ParticleSequenceInfo info, string resourcePath)
        {
            this.sequenceInfo = info;
            this.resourcePath = resourcePath;

            //  Add TimeSequence to child
            timeSequence = new TimeSequence();
            AddChild(timeSequence);

            for (int i = 0; i < info.TimeSequencesInfo.Count; i++)
            {
                TimeSequenceInfo timeSequenceInfo = info.TimeSequencesInfo[i];

                //  Create a TimeSequenceData using TimeSequenceInfo
                TimeSequenceData timeSequenceData =
                    new TimeSequenceData(timeSequenceInfo);

                //  Create a particle using ParticleInfo and TextureSequence
                //  in the TimeSequenceInfo
                Particle particle = new Particle(resourcePath,
                                                 timeSequenceInfo.ParticleInfo,
                                                 timeSequenceInfo.TextureSequence);

                //  Set owner particle to the TimeSequenceData
                timeSequenceData.Owner = particle;

                //  Add the particle to the TimeSequence's child
                timeSequence.AddChild(particle);

                //  Add TimeSequenceData to the TimeSequence
                timeSequence.AddSequence(timeSequenceData);
            }

            Name = info.Name;

            //  Particle off
            Stop();
        }
Esempio n. 9
0
 /// <summary>
 /// removes the time data.
 /// </summary>
 /// <param name="data">the time data</param>
 public void RemoveSequence(TimeSequenceData data)
 {
     timeSequenceDataList.Remove(data);
 }
Esempio n. 10
0
        /// <summary>
        /// adds a new time data.
        /// </summary>
        /// <param name="data">new time data</param>
        public void AddSequence(TimeSequenceData data)
        {
            timeSequenceDataList.Add(data);

            SetOwnerEnable(data, false);

            UpdateDuration();
        }
Esempio n. 11
0
 /// <summary>
 /// enables/disables the scene owner
 /// </summary>
 /// <param name="data">time data</param>
 /// <param name="enable">enable flag</param>
 public static void SetOwnerEnable(TimeSequenceData data, bool enable)
 {
     if (data.Owner != null)
     {
         data.Owner.Enabled = enable;
         data.Owner.Visible = enable;
     }
 }
Esempio n. 12
0
 /// <summary>
 /// removes the time data.
 /// </summary>
 /// <param name="data">the time data</param>
 public void RemoveSequence(TimeSequenceData data)
 {
     timeSequenceDataList.Remove(data);
 }