wangguan
2020-11-11 6b213bdbe7dec2304b256ddfacaa76d817cc47ee
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);
            }
        }
    }
}