DetonatorSprayHelper.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using UnityEngine;
  3. public class DetonatorSprayHelper : MonoBehaviour
  4. {
  5. private void Start()
  6. {
  7. this.isReallyOn = base.GetComponent<ParticleEmitter>().emit;
  8. base.GetComponent<ParticleEmitter>().emit = false;
  9. this.startTime = UnityEngine.Random.value * (this.startTimeMax - this.startTimeMin) + this.startTimeMin + Time.time;
  10. this.stopTime = UnityEngine.Random.value * (this.stopTimeMax - this.stopTimeMin) + this.stopTimeMin + Time.time;
  11. base.GetComponent<Renderer>().material = ((UnityEngine.Random.value <= 0.5f) ? this.secondMaterial : this.firstMaterial);
  12. }
  13. private void FixedUpdate()
  14. {
  15. if (Time.time > this.startTime)
  16. {
  17. base.GetComponent<ParticleEmitter>().emit = this.isReallyOn;
  18. }
  19. if (Time.time > this.stopTime)
  20. {
  21. base.GetComponent<ParticleEmitter>().emit = false;
  22. }
  23. }
  24. public float startTimeMin;
  25. public float startTimeMax;
  26. public float stopTimeMin = 10f;
  27. public float stopTimeMax = 10f;
  28. public Material firstMaterial;
  29. public Material secondMaterial;
  30. private float startTime;
  31. private float stopTime;
  32. private bool isReallyOn;
  33. }