chenxin
2020-11-25 8681be3c80a3b6837e578290fd2fef5bf6b14a14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using UnityEngine;
 
namespace TowerDefense.UI
{
    /// <summary>
    /// A simple component that plays a given particle system on a given regular interval
    /// </summary>
    public class IntervalParticleSystemPlayer : MonoBehaviour
    {
        public ParticleSystem particleSystemToPlay;
 
        public float interval;
 
        protected DateTime m_NextPlayTime;
    
        void Start ()
        {
            m_NextPlayTime = DateTime.Now.AddSeconds(interval);
        }
 
        void Update()
        {
            if (particleSystemToPlay != null && m_NextPlayTime <= DateTime.Now)
            {
                particleSystemToPlay.Play();
                m_NextPlayTime = DateTime.Now.AddSeconds(interval);
            }
        }
    }
}