WindStreamEffect.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using CIS;
  3. using UnityEngine;
  4. public class WindStreamEffect : MonoBehaviour
  5. {
  6. private void Awake()
  7. {
  8. this.renderner = base.GetComponent<Renderer>();
  9. this.renderner.sortingOrder = this.sortingOrder;
  10. }
  11. private void Start()
  12. {
  13. this.mat = this.renderner.material;
  14. this.mat.SetFloat("_Seed", UnityEngine.Random.Range(0f, 50f));
  15. }
  16. private void Update()
  17. {
  18. if (SingletonMonoBehaviourClass<GameLogicMgr>.instance.IsPause())
  19. {
  20. return;
  21. }
  22. this.time += Time.deltaTime;
  23. this.mat.SetVector("_Speed", new Vector4(this.vel.x, this.vel.y, 0f, 0f));
  24. this.mat.SetFloat("_Strength", this.strength);
  25. this.mat.SetColor("_TintColor", this.tintColor);
  26. this.mat.SetFloat("_Distortion1", this.factor1);
  27. this.mat.SetFloat("_Distortion2", this.factor2);
  28. this.mat.SetFloat("_Gradient", this.gradient);
  29. this.mat.SetFloat("_Extend", this.extend);
  30. this.mat.SetVector("_MyTime", new Vector4(this.time / 20f, this.time, this.time * 2f, this.time * 3f));
  31. this.renderner.sortingOrder = this.sortingOrder;
  32. }
  33. public int sortingOrder;
  34. public Vector2 vel;
  35. public float strength;
  36. public Color tintColor;
  37. public float factor1;
  38. public float factor2;
  39. public float extend;
  40. public float gradient;
  41. private float time;
  42. private Material mat;
  43. private Renderer renderner;
  44. private SpriteRenderer sprite;
  45. }