DialogueOptionWidget.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 EventLinkConfig eventConditionConfig;
  14. private Action<DialogueOptionWidget> callback;
  15. public int type;
  16. private void Init()
  17. {
  18. }
  19. public override void AddEvent()
  20. {
  21. }
  22. public override void DelEvent()
  23. {
  24. }
  25. public override void AddButtonEvent()
  26. {
  27. OptionWidget.onClick.AddListener(() => { callback?.Invoke(this); });
  28. }
  29. public void CustomInit(int selectIndex, AccountFileInfo.EventList CurrentEventList, int id, int mainOpid, Action<DialogueOptionWidget> callback)
  30. {
  31. type = 1;
  32. eventConditionConfig = ConfigComponent.Instance.Get<EventLinkConfig>(id);
  33. var eventLinkData = CurrentEventList.eventLinks.FirstOrDefault(l => l.eventLinkId == id);
  34. var mainEventConditionConfig = ConfigComponent.Instance.Get<EventLinkConfig>(mainOpid);
  35. // int index = mainEventConditionConfig.optionPara1.ToList().IndexOf(eventConditionConfig.ID);
  36. Text_desc.text = LanguageManager.Instance.Text(mainEventConditionConfig.optionPara2[selectIndex]);
  37. this.callback = callback;
  38. // bool isUlock = true;
  39. // foreach (var eventConditionData in eventLinkData.eventConditions)
  40. // {
  41. // if (!EventSystemManager.Instance.CeekEventGroupComplete(eventLinkData.eventConditions))
  42. // {
  43. // onCancel?.Invoke();
  44. // return;
  45. // }
  46. // if (!EventSystemManager.Instance.IsEvenkLinkComplete(eventConditionData))
  47. // {
  48. // isUlock = false;
  49. // }
  50. // }
  51. if (!EventSystemManager.Instance.CeekEventGroupComplete(eventLinkData.eventConditions))
  52. {
  53. transform.Gray();
  54. }
  55. else
  56. {
  57. transform.RecoverColor();
  58. }
  59. LayoutRebuilder.ForceRebuildLayoutImmediate(Text_desc.GetComponent<RectTransform>());
  60. LayoutRebuilder.ForceRebuildLayoutImmediate(transform);
  61. }
  62. public void CustomInit(Action<DialogueOptionWidget> callback)
  63. {
  64. type = 2;
  65. Text_desc.text = "取消事件";
  66. this.callback = callback;
  67. transform.RecoverColor();
  68. LayoutRebuilder.ForceRebuildLayoutImmediate(Text_desc.GetComponent<RectTransform>());
  69. LayoutRebuilder.ForceRebuildLayoutImmediate(transform);
  70. }
  71. }
  72. }