ScriptPlayableAssetStoryDialogue.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Playables;
  5. using UnityEngine.UI;
  6. public enum StoryLocation
  7. {
  8. Left,
  9. Right,
  10. }
  11. [System.Serializable]
  12. public class ScriptPlayableAssetStoryDialogue : PlayableAsset, IPlayableAssetDeal
  13. {
  14. public int dlgId;
  15. public int startTime;
  16. public int endTime;
  17. public Text talkText;
  18. public Toggle toggleBtn;
  19. public StoryMgr mgr;
  20. bool isPlayed = false;
  21. bool isEnd = false;
  22. // Factory method that generates a playable based on this asset
  23. public override Playable CreatePlayable(PlayableGraph graph, GameObject go)
  24. {
  25. ScriptPlayableTrackStoryDialogue talkPlayable = new ScriptPlayableTrackStoryDialogue();
  26. talkPlayable.Init(talkText, toggleBtn, dlgId, mgr);
  27. return ScriptPlayable<ScriptPlayableTrackStoryDialogue>.Create(graph, talkPlayable);
  28. }
  29. public void DealWithSimpleMode(int time)
  30. {
  31. if (dlgId == 0)
  32. return;
  33. if (time >= startTime && time < endTime)
  34. {
  35. if (!isPlayed)
  36. {
  37. StoryMgr.Instance.PlayDialogueText(dlgId);
  38. isPlayed = true;
  39. }
  40. }
  41. else if (time >= endTime)
  42. {
  43. if (!isEnd)
  44. {
  45. isEnd = true;
  46. StoryMgr.Instance.DialogueEndPauseStatus();
  47. }
  48. }
  49. }
  50. }