48 lines
1.0 KiB
C#
48 lines
1.0 KiB
C#
using UnityEngine;
|
|
|
|
public class smoky_explosion : MonoBehaviour
|
|
{
|
|
private float t1;
|
|
|
|
private float t;
|
|
|
|
public float delay;
|
|
|
|
private bool expl;
|
|
|
|
public float force_k = 1f;
|
|
|
|
private void explo()
|
|
{
|
|
expl = true;
|
|
GetComponent<Rigidbody>().AddRelativeForce(Vector3.forward * 200f * force_k * Random.Range(0.9f, 1.1f));
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
t1 += Time.deltaTime;
|
|
if (t1 >= delay)
|
|
{
|
|
t += Time.deltaTime;
|
|
if (t > 0.2f)
|
|
{
|
|
MonoBehaviour.print(GetComponent<ParticleSystem>().startSize);
|
|
GetComponent<ParticleSystem>().startSize += (0f - GetComponent<ParticleSystem>().startSize) / 30f;
|
|
GetComponent<ParticleSystem>().startColor += (new Color(GetComponent<ParticleSystem>().startColor.r, GetComponent<ParticleSystem>().startColor.g, GetComponent<ParticleSystem>().startColor.b, 0f) - GetComponent<ParticleSystem>().startColor) / 10f;
|
|
}
|
|
if (t > 7f)
|
|
{
|
|
Object.Destroy(base.gameObject);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void FixedUpdate()
|
|
{
|
|
if (t1 >= delay && !expl)
|
|
{
|
|
explo();
|
|
}
|
|
}
|
|
}
|