DialogueOptionWidget.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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(AccountFileInfo.EventLinkData eventLinkData, int id, int mainOpid, Action<DialogueOptionWidget> callback)
  30. {
  31. type = 1;
  32. eventConditionConfig = ConfigComponent.Instance.Get<EventLinkConfig>(id);
  33. var mainEventConditionConfig = ConfigComponent.Instance.Get<EventLinkConfig>(mainOpid);
  34. int index = mainEventConditionConfig.optionPara1.ToList().IndexOf(eventConditionConfig.ID);
  35. Text_desc.text = LanguageManager.Instance.Text(mainEventConditionConfig.optionPara2[index]);
  36. this.callback = callback;
  37. // bool isUlock = true;
  38. // foreach (var eventConditionData in eventLinkData.eventConditions)
  39. // {
  40. // if (!EventSystemManager.Instance.CeekEventGroupComplete(eventLinkData.eventConditions))
  41. // {
  42. // onCancel?.Invoke();
  43. // return;
  44. // }
  45. // if (!EventSystemManager.Instance.IsEvenkLinkComplete(eventConditionData))
  46. // {
  47. // isUlock = false;
  48. // }
  49. // }
  50. if (!EventSystemManager.Instance.CeekEventGroupComplete(eventLinkData.eventConditions))
  51. {
  52. transform.Gray();
  53. }
  54. else
  55. {
  56. transform.RecoverColor();
  57. }
  58. LayoutRebuilder.ForceRebuildLayoutImmediate(Text_desc.GetComponent<RectTransform>());
  59. LayoutRebuilder.ForceRebuildLayoutImmediate(transform);
  60. }
  61. public void CustomInit(Action<DialogueOptionWidget> callback)
  62. {
  63. type = 2;
  64. Text_desc.text = "取消事件";
  65. this.callback = callback;
  66. transform.RecoverColor();
  67. LayoutRebuilder.ForceRebuildLayoutImmediate(Text_desc.GetComponent<RectTransform>());
  68. LayoutRebuilder.ForceRebuildLayoutImmediate(transform);
  69. }
  70. }
  71. }