StoryViewButton.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using TMPro;
  5. using KairoEngine.Core;
  6. using KairoEngine.StorySystem;
  7. namespace KairoEngine.StorySystem.UI
  8. {
  9. public class StoryViewButton : MonoBehaviour
  10. {
  11. public TextMeshProUGUI text;
  12. private string storyName;
  13. private StoryStepData storyStep;
  14. private int value;
  15. private StoryViewUI storyView;
  16. public void Init(string storyName, StoryStepData storyStep, int n, StoryViewUI storyView)
  17. {
  18. this.storyName = storyName;
  19. this.storyStep = storyStep;
  20. this.value = n;
  21. this.storyView = storyView;
  22. text.text = this.storyStep.branches[this.value];
  23. }
  24. public void OnClick()
  25. {
  26. //Debug.Log("Button Clicked");
  27. StoryStepData newStoryStep = new StoryStepData(StoryStepType.Path, storyStep.branches[value], null, null, value);
  28. storyView.ButtonClicked(newStoryStep);
  29. EventManager.broadcast.Trigger(storyName, newStoryStep);
  30. }
  31. }
  32. }