Files
JJBB/Assets/Project/Script/Scene/SceneLogic/SceneEffectLoop.cs

53 lines
1.6 KiB
C#
Raw Normal View History

2024-08-23 15:49:34 +08:00
/********************************************************************************
* SceneEffectLoop.cs
* \Script\Scene\SceneEffectLoop.cs
*
* 2014-10-24
*
*
* Object中
*
*********************************************************************************/
using Games.LogicObj;
using UnityEngine;
using System.Collections;
public class SceneEffectLoop : MonoBehaviour
{
public int m_LoopDeltaTime; //每次循环的间隔时间(秒)
public int m_SoundID = -1; //声音Id
// Use this for initialization
void Start ()
{
StartCoroutine(DoSceneEffectLoop());
}
//时间到了则循环一次
IEnumerator DoSceneEffectLoop()
{
while (true)
{
yield return new WaitForSeconds(m_LoopDeltaTime);
//播放特效
ParticleSystem[] particleSystemArray = gameObject.GetComponentsInChildren<ParticleSystem>();
for(int i=0; i<particleSystemArray.Length; ++i)
{
if (null != particleSystemArray[i])
{
particleSystemArray[i].Play();
}
}
//播放声音
if (m_SoundID >= 0 && null != GameManager.gameManager.SoundManager)
{
GameManager.gameManager.SoundManager.PlaySoundEffectAtPos(m_SoundID, gameObject.transform.localPosition);
}
}
}
}