DialogueOptionWidget.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Linq;
  3. using Core.Language;
  4. using Excel2Json;
  5. using Fort23.UTool;
  6. namespace Fort23.Mono
  7. {
  8. [UIBinding(prefab = "DialogueOptionWidget")]
  9. public partial class DialogueOptionWidget : UIComponent
  10. {
  11. public EventConditionConfig eventConditionConfig;
  12. private Action<DialogueOptionWidget> callback;
  13. private void Init()
  14. {
  15. }
  16. public override void AddEvent()
  17. {
  18. }
  19. public override void DelEvent()
  20. {
  21. }
  22. public override void AddButtonEvent()
  23. {
  24. OptionWidget.onClick.AddListener(() => { callback?.Invoke(this); });
  25. }
  26. public void CustomInit(int id, int mainOpid, Action<DialogueOptionWidget> callback)
  27. {
  28. eventConditionConfig = ConfigComponent.Instance.Get<EventConditionConfig>(id);
  29. var mainEventConditionConfig = ConfigComponent.Instance.Get<EventConditionConfig>(mainOpid);
  30. int index = mainEventConditionConfig.optionPara1.ToList().IndexOf(eventConditionConfig.ID);
  31. Text_desc.text = LanguageManager.Instance.Text(mainEventConditionConfig.optionPara2[index]);
  32. this.callback = callback;
  33. }
  34. }
  35. }