WindWavable.cs 719 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using CIS;
  3. using UnityEngine;
  4. public class WindWavable : MonoBehaviour
  5. {
  6. private void Awake()
  7. {
  8. this.animator = base.GetComponent<Animator>();
  9. }
  10. private void Start()
  11. {
  12. this.wind = SingletonMonoBehaviourClass<GlobalWindGenerator>.instance;
  13. if (this.random)
  14. {
  15. this.randomFactor = UnityEngine.Random.Range(-1f, 0f);
  16. }
  17. else
  18. {
  19. this.randomFactor = 0f;
  20. }
  21. }
  22. private void Update()
  23. {
  24. this.animator.speed = this.wind.power / this.wind.maxPower;
  25. this.animator.SetFloat("windPower", this.wind.power + this.randomFactor);
  26. }
  27. public bool random;
  28. private Animator animator;
  29. private GlobalWindGenerator wind;
  30. private float randomFactor;
  31. }