DianFuTiCtrl.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using Sirenix.OdinInspector;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityCommon;
  5. using UnityEngine;
  6. namespace DTYJ
  7. {
  8. public class DianFuTiCtrl : SerializedMonoBehaviour
  9. {
  10. public static DianFuTiCtrl Instance;
  11. private void Awake()
  12. {
  13. Instance = this;
  14. }
  15. public Dictionary<string, Animation> dic;
  16. public void SetState(string id, int state)
  17. {
  18. if (dic.ContainsKey(id))
  19. {
  20. var anim = dic[id];//.GetComponent<Animation>();
  21. var animationName = anim.clip.name;
  22. //anim[animationName].time = state == 1 ? 0 : anim[animationName].length;
  23. switch (state)
  24. {
  25. case 0:
  26. anim[animationName].speed = 1;
  27. break;
  28. case 1:
  29. anim[animationName].speed = -1;
  30. break;
  31. case 2:
  32. case 3:
  33. anim[animationName].speed = 0;
  34. break;
  35. }
  36. anim[animationName].wrapMode = WrapMode.Loop;
  37. anim.CrossFade(animationName);
  38. }
  39. }
  40. [ContextMenu("´¦Àí")]
  41. public void HandleTemp()
  42. {
  43. Dictionary<string, Animation> dicNew = new Dictionary<string, Animation>();
  44. foreach (var kvp in dic)
  45. {
  46. var animPath = Utility.GetPathInHierichy(kvp.Value.transform, null);
  47. dicNew["1_" + kvp.Key] = GameObject.Find("StationOthers/1/" + animPath).GetComponent<Animation>();
  48. dicNew["2_" + kvp.Key] = GameObject.Find("StationOthers/2/" + animPath).GetComponent<Animation>();
  49. }
  50. foreach (var kvp in dicNew)
  51. {
  52. dic[kvp.Key] = kvp.Value;
  53. }
  54. }
  55. }
  56. }