DialogueOptionWidget.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Linq;
  3. using Core.Language;
  4. using Excel2Json;
  5. using Fort23.UTool;
  6. using UnityEngine;
  7. using UnityEngine.UI;
  8. namespace Fort23.Mono
  9. {
  10. [UIBinding(prefab = "DialogueOptionWidget")]
  11. public partial class DialogueOptionWidget : UIComponent
  12. {
  13. public AccountFileInfo.EventLinkData eventLinkData;
  14. public EventLinkConfig eventConditionConfig;
  15. private Action<DialogueOptionWidget> callback;
  16. public int type;
  17. private void Init()
  18. {
  19. }
  20. public override void AddEvent()
  21. {
  22. }
  23. public override void DelEvent()
  24. {
  25. }
  26. public override void AddButtonEvent()
  27. {
  28. OptionWidget.onClick.AddListener(() => { callback?.Invoke(this); });
  29. }
  30. public void CustomInit(int selectIndex, AccountFileInfo.EventList CurrentEventList, int id, int mainOpid, Action<DialogueOptionWidget> callback)
  31. {
  32. type = 1;
  33. eventConditionConfig = ConfigComponent.Instance.Get<EventLinkConfig>(id);
  34. eventLinkData = CurrentEventList.eventLinks.FirstOrDefault(l => l.eventLinkId == id);
  35. var mainEventConditionConfig = ConfigComponent.Instance.Get<EventLinkConfig>(mainOpid);
  36. // int index = mainEventConditionConfig.optionPara1.ToList().IndexOf(eventConditionConfig.ID);
  37. Text_desc.text = LanguageManager.Instance.Text(mainEventConditionConfig.optionPara2[selectIndex]);
  38. this.callback = callback;
  39. if (!EventSystemManager.Instance.CeekEventGroupComplete(eventLinkData.eventConditions))
  40. {
  41. transform.Gray();
  42. }
  43. else
  44. {
  45. transform.RecoverColor();
  46. }
  47. LayoutRebuilder.ForceRebuildLayoutImmediate(Text_desc.GetComponent<RectTransform>());
  48. LayoutRebuilder.ForceRebuildLayoutImmediate(transform);
  49. }
  50. public void CustomInit(Action<DialogueOptionWidget> callback)
  51. {
  52. type = 2;
  53. Text_desc.text = "取消事件";
  54. this.callback = callback;
  55. transform.RecoverColor();
  56. LayoutRebuilder.ForceRebuildLayoutImmediate(Text_desc.GetComponent<RectTransform>());
  57. LayoutRebuilder.ForceRebuildLayoutImmediate(transform);
  58. }
  59. }
  60. }