using UnityEngine;
using System.Collections;
public class Thundering : MonoBehaviour
{
public Transform ground;
float groundWidth, groundlength;
Light thunderLight;
public float maxThunderDur;
float thunderDuration;
public float maxThunderBreakDur;
float thunderBreakDuration;
public float maxThunderRestDur;
float thunderRestDur;
int serialThunderTime;
public int maxSerialThunderTime;
void Awake()
{
thunderLight = GetComponent<Light>();
}
// Use this for initialization
void Start()
{
StartCoroutine(Thunder());
}
IEnumerator Thunder()
{
while (true)
{
serialThunderTime = Random.Range(0, maxSerialThunderTime + 1);
for (int i = 0; i < serialThunderTime; i++)
{
thunderDuration = Random.Range(0, maxThunderDur);
thunderLight.intensity = 8f;
yield return new WaitForSeconds(thunderDuration);
thunderLight.intensity = 2f;
thunderBreakDuration = Random.Range(0, maxThunderBreakDur);
yield return new WaitForSeconds(thunderBreakDuration);
}
thunderRestDur = Random.Range(0, maxThunderRestDur);
yield return new WaitForSeconds(maxThunderRestDur);
}
}
}
下面是参数设置: