NetTrainAniCtrl.cs 979 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using GameFramework.Event;
  5. using UnityEngine;
  6. public class NetTrainAniCtrl : MonoBehaviour
  7. {
  8. public GameObject ani_1;
  9. public GameObject ani_2;
  10. void Start()
  11. {
  12. GameMain.Event.Subscribe(Net_TrainAniEvent.EventId,OnGetAniEvent);
  13. }
  14. private void OnDestroy()
  15. {
  16. if (GameMain.Event.Check(Net_TrainAniEvent.EventId, OnGetAniEvent))
  17. {
  18. GameMain.Event.Unsubscribe(Net_TrainAniEvent.EventId,OnGetAniEvent);
  19. }
  20. }
  21. private void OnGetAniEvent(object sender, GameEventArgs e)
  22. {
  23. Net_TrainAniEvent args = (Net_TrainAniEvent)e;
  24. switch (args.type)
  25. {
  26. case 1:
  27. ani_1.SetActive(true);
  28. ani_2.SetActive(false);
  29. break;
  30. case 2:
  31. ani_1.SetActive(false);
  32. ani_2.SetActive(true);
  33. break;
  34. }
  35. }
  36. }