Scene_Anime_SingleUnit.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using CrossgateToolkit;
  5. using UnityEngine;
  6. using UnityEngine.UI;
  7. public class Scene_Anime_SingleUnit : MonoBehaviour
  8. {
  9. public AnimePlayer animePlayer;
  10. public Anime.DirectionType DirectionType;
  11. public Anime.ActionType ActionType;
  12. public uint Serial;
  13. public Text[] Texts;
  14. // Start is called before the first frame update
  15. private void Awake()
  16. {
  17. Util.Init();
  18. Serial = Util.GetRandomSerial();
  19. DirectionType = Anime.DirectionType.SouthWest;
  20. ActionType = Anime.ActionType.Idle;
  21. }
  22. void Start()
  23. {
  24. animePlayer.play(Serial,DirectionType,ActionType,Anime.PlayType.Loop);
  25. UpdateText();
  26. }
  27. // Update is called once per frame
  28. void Update()
  29. {
  30. }
  31. public void ChangeUint()
  32. {
  33. Serial = Util.GetRandomSerial();
  34. animePlayer.Serial = Serial;
  35. UpdateText();
  36. }
  37. public void ChangeDirection()
  38. {
  39. DirectionType = Util.GetNextDirection(DirectionType);
  40. animePlayer.DirectionType = DirectionType;
  41. UpdateText();
  42. }
  43. public void ChangeAction()
  44. {
  45. // 注意不是所有角色都有 BeforeRun/AfterRun 或其他动作
  46. ActionType = Util.GetNextAction(ActionType);
  47. animePlayer.ActionType = ActionType;
  48. UpdateText();
  49. }
  50. public void UpdateText()
  51. {
  52. Texts[0].text = Serial.ToString();
  53. Texts[1].text = DirectionType.ToString();
  54. Texts[2].text = ActionType.ToString();
  55. }
  56. }