DialogueOptionWidget.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. // bool isUlock = true;
  40. // foreach (var eventConditionData in eventLinkData.eventConditions)
  41. // {
  42. // if (!EventSystemManager.Instance.CeekEventGroupComplete(eventLinkData.eventConditions))
  43. // {
  44. // onCancel?.Invoke();
  45. // return;
  46. // }
  47. // if (!EventSystemManager.Instance.IsEvenkLinkComplete(eventConditionData))
  48. // {
  49. // isUlock = false;
  50. // }
  51. // }
  52. if (!EventSystemManager.Instance.CeekEventGroupComplete(eventLinkData.eventConditions))
  53. {
  54. transform.Gray();
  55. }
  56. else
  57. {
  58. transform.RecoverColor();
  59. }
  60. LayoutRebuilder.ForceRebuildLayoutImmediate(Text_desc.GetComponent<RectTransform>());
  61. LayoutRebuilder.ForceRebuildLayoutImmediate(transform);
  62. }
  63. public void CustomInit(Action<DialogueOptionWidget> callback)
  64. {
  65. type = 2;
  66. Text_desc.text = "取消事件";
  67. this.callback = callback;
  68. transform.RecoverColor();
  69. LayoutRebuilder.ForceRebuildLayoutImmediate(Text_desc.GetComponent<RectTransform>());
  70. LayoutRebuilder.ForceRebuildLayoutImmediate(transform);
  71. }
  72. }
  73. }