| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537 | 
							- using System.Text;
 
- using Common.Utility.CombatEvent;
 
- using Core.Language;
 
- using Excel2Json;
 
- using Fort23.UTool;
 
- using UnityEngine;
 
- using System;
 
- using System.Collections.Generic;
 
- using System.Linq;
 
- using Fort23.Core;
 
- using GameLogic.Bag;
 
- using GameLogic.Player;
 
- using UnityEngine.UI;
 
- namespace Fort23.Mono
 
- {
 
-     [UIBinding(prefab = "DialoguePanel")]
 
-     public partial class DialoguePanel : UIPanel
 
-     {
 
-         private bool isShowAnima;
 
-         private int[] dialogueMessaga;
 
-         private ShowDialogueEventData.MessageShowType messageShowType;
 
-         private Action<int?> finish;
 
-         private int index;
 
-         private char[] _currShowMessage;
 
-         private float _showTime = 0.03f;
 
-         private float _currShowTime = 0;
 
-         protected StringBuilder _sb = new StringBuilder();
 
-         private int _currShowIndex;
 
-         private bool _isUpdate;
 
-         private bool _isShowNextButton;
 
-         private string[] showIconName;
 
-         private EventLinkConfig eventConditionConfig;
 
-         private bool _skipTyping;
 
-         private bool _isShowingOptions;
 
-         private AccountFileInfo.EventList CurrentEventList;
 
-         private AccountFileInfo.EventLinkData _eventLinkData;
 
-         private int type;
 
-         private Text showText;
 
-         private GameObject shownextIcon;
 
-         private bool isOver;
 
-         public static async CTask OpenDialoguePanel(AccountFileInfo.EventList CurrentEventList, int id, string[] icon,
 
-             ShowDialogueEventData.MessageShowType messageShowType,
 
-             Action<int?> finish, bool isShowAnima)
 
-         {
 
-             DialoguePanel dialoguePanel = await UIManager.Instance.LoadAndOpenPanel<DialoguePanel>(null, UILayer.Top,
 
-                 uiData: new object[] { CurrentEventList, id, icon, messageShowType, finish, isShowAnima });
 
-             // if (isShowAnima)
 
-             // {
 
-             //     dialoguePanel.DialgueType1Anim.Play("DialgueType1open");
 
-             // }
 
-             // else
 
-             // {
 
-             //     dialoguePanel.DialgueType1Anim.Play("DialgueType1idle1");
 
-             // }
 
-             // dialoguePanel.ShowPanel(CurrentEventList, id, icon, messageShowType, finish);
 
-         }
 
-         public static async void OpenDialoguePanel(int[] LanID, string[] icon,
 
-             ShowDialogueEventData.MessageShowType messageShowType,
 
-             Action<int?> finish)
 
-         {
 
-             DialoguePanel dialoguePanel = await UIManager.Instance.LoadAndOpenPanel<DialoguePanel>(null, UILayer.Top);
 
-             dialoguePanel.ShowPanel(LanID, icon, messageShowType, finish);
 
-         }
 
-         public async override CTask Show()
 
-         {
 
-             EventManager.Instance.Dispatch(CustomEventType.DialoguePanelOpen, null);
 
-             base.Show();
 
-             if (isShowAnima)
 
-             {
 
-                 DialgueType1Anim.Play("DialgueType1open");
 
-             }
 
-             else
 
-             {
 
-                 DialgueType1Anim.Play("DialgueType1idle1");
 
-             }
 
-         }
 
-         public async override CTask<bool> AsyncInit(object[] uiData)
 
-         {
 
-             await ShowPanel(uiData[0] as AccountFileInfo.EventList, (int)uiData[1], uiData[2] as string[],
 
-                 (ShowDialogueEventData.MessageShowType)uiData[3], uiData[4] as Action<int?>, (bool)uiData[5]);
 
-             return await base.AsyncInit(uiData);
 
-         }
 
-         private void Init()
 
-         {
 
-             isAddStack = false;
 
-             _skipTyping = false;
 
-             _isShowingOptions = false;
 
-         }
 
-         protected override void AddEvent()
 
-         {
 
-         }
 
-         protected override void DelEvent()
 
-         {
 
-         }
 
-         public override void AddButtonEvent()
 
-         {
 
-             nextButton.onClick.AddListener(NextShow);
 
-             Btn_Cancel.onClick.AddListener(() =>
 
-             {
 
-                 UIManager.Instance.HideUIUIPanel(this);
 
-                 finish?.Invoke(-1);
 
-             });
 
-         }
 
-         private void SkipTyping()
 
-         {
 
-             _skipTyping = true;
 
-             if (_isUpdate)
 
-             {
 
-                 _sb.Clear();
 
-                 _sb.Append(_currShowMessage);
 
-                 showText.text = _sb.ToString();
 
-                 _currShowIndex = _currShowMessage.Length;
 
-                 _isUpdate = false;
 
-                 ShowNextIcon();
 
-                 if (index >= dialogueMessaga.Length)
 
-                 {
 
-                     if (eventConditionConfig.ID != 0 && !_isShowingOptions)
 
-                     {
 
-                         ShowOptions();
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-         private void NextShow()
 
-         {
 
-             if (eventConditionConfig.optionType == 1 && _isShowingOptions)
 
-                 return;
 
-             if (_isUpdate)
 
-             {
 
-                 SkipTyping();
 
-             }
 
-             else
 
-             {
 
-                 StartShowMassge();
 
-             }
 
-         }
 
-         public async CTask ShowPanel(AccountFileInfo.EventList CurrentEventList, int id, string[] icon,
 
-             ShowDialogueEventData.MessageShowType messageShowType,
 
-             Action<int?> finish, bool isShowAnima)
 
-         {
 
-             this.isShowAnima = isShowAnima;
 
-             this.CurrentEventList = CurrentEventList;
 
-             eventConditionConfig = ConfigComponent.Instance.Get<EventLinkConfig>(id);
 
-             _eventLinkData = CurrentEventList.eventLinks.FirstOrDefault(el => el.eventLinkId == id);
 
-             showIconName = icon;
 
-             this.dialogueMessaga = eventConditionConfig.LanID;
 
-             this.messageShowType = messageShowType;
 
-             this.finish = finish;
 
-             index = 0;
 
-             StaticUpdater.Instance.AddRenderUpdateCallBack(Update);
 
-             if (eventConditionConfig.DialogueType == 0 || eventConditionConfig.DialogueType == 1)
 
-             {
 
-                 DialgueType1.gameObject.SetActive(true);
 
-                 DialgueType2.gameObject.SetActive(false);
 
-                 DialgueType3.gameObject.SetActive(false);
 
-                 showText = message;
 
-                 shownextIcon = nextIcon;
 
-             }
 
-             else if (eventConditionConfig.DialogueType == 2)
 
-             {
 
-                 DialgueType1.gameObject.SetActive(false);
 
-                 DialgueType3.gameObject.SetActive(false);
 
-                 DialgueType2.gameObject.SetActive(true);
 
-                 showText = message2;
 
-                 shownextIcon = nextIcon2;
 
-             }
 
-             else if (eventConditionConfig.DialogueType == 3)
 
-             {
 
-                 DialgueType1.gameObject.SetActive(false);
 
-                 DialgueType2.gameObject.SetActive(false);
 
-                 DialgueType3.gameObject.SetActive(true);
 
-                 showText = message3;
 
-                 shownextIcon = nextIcon3;
 
-             }
 
-             if (eventConditionConfig.NPCID == 100)
 
-             {
 
-                 DialgueType1.GetComponent<CustomStateController>().ChangeState(0);
 
-                 Text_Name1.text = PlayerManager.Instance.PlayerName;
 
-                 PLayerNameRoot.SetActive(true);
 
-             }
 
-             else if (eventConditionConfig.NPCID == 0)
 
-             {
 
-                 PLayerNameRoot.SetActive(false);
 
-             }
 
-             else
 
-             {
 
-                 EventNPC eventNpc = ConfigComponent.Instance.Get<EventNPC>(eventConditionConfig.NPCID);
 
-                 if (eventNpc.isNpc)
 
-                 {
 
-                     DialgueType1.GetComponent<CustomStateController>().ChangeState(1);
 
-                     PLayerNameRoot.SetActive(true);
 
-                     Text_Name2.text = LanguageManager.Instance.Text(eventNpc.name);
 
-                 }
 
-                 else
 
-                 {
 
-                     PLayerNameRoot.SetActive(false);
 
-                 }
 
-             }
 
-             StartShowMassge();
 
-         }
 
-         public static string ReverseUsingLoop(string input)
 
-         {
 
-             if (string.IsNullOrEmpty(input))
 
-                 return input;
 
-             StringBuilder sb = new StringBuilder(input.Length);
 
-             for (int i = input.Length - 1; i >= 0; i--)
 
-             {
 
-                 sb.Append(input[i]);
 
-             }
 
-             return sb.ToString();
 
-         }
 
-         public void ShowPanel(int[] LanID, string[] icon,
 
-             ShowDialogueEventData.MessageShowType messageShowType,
 
-             Action<int?> finish)
 
-         {
 
-             showIconName = icon;
 
-             this.dialogueMessaga = LanID;
 
-             this.messageShowType = messageShowType;
 
-             this.finish = finish;
 
-             index = 0;
 
-             StaticUpdater.Instance.AddRenderUpdateCallBack(Update);
 
-             StartShowMassge();
 
-         }
 
-         private async CTask StartShowMassge()
 
-         {
 
-             if (isOver)
 
-                 return;
 
-             CTask cTask = CTask.Create();
 
-             icon.onSpriteAlter = () =>
 
-             {
 
-                 icon.SetNativeSize();
 
-                 icon.gameObject.SetActive(true);
 
-                 cTask.SetResult();
 
-             };
 
-             if (eventConditionConfig.NPCID != 100 && eventConditionConfig.NPCID != 0)
 
-             {
 
-                 icon.gameObject.SetActive(false);
 
-                 EventNPC eventNpc = ConfigComponent.Instance.Get<EventNPC>(eventConditionConfig.NPCID);
 
-                 icon.icon_name = eventNpc.icon;
 
-             }
 
-             else
 
-             {
 
-                 icon.gameObject.SetActive(true);
 
-                 cTask.SetResult();
 
-                 // icon.icon_name = "bg_lh_di1";
 
-             }
 
-             await cTask;
 
-             if (eventConditionConfig.EventID == 10000)
 
-             {
 
-                 Btn_Cancel.gameObject.SetActive(false);
 
-             }
 
-             else
 
-             {
 
-                 Btn_Cancel.gameObject.SetActive(true);
 
-             }
 
-             Btn_Bag.gameObject.SetActive(false);
 
-             if (index >= dialogueMessaga.Length)
 
-             {
 
-                 isOver = true;
 
-                 if (eventConditionConfig.ID != 0 && !_isShowingOptions)
 
-                 {
 
-                     ShowOptions();
 
-                 }
 
-                 // 所有句子显示完成,检查是否有选项
 
-                 if (eventConditionConfig.ID != 0 && eventConditionConfig.optionType == 1 && !_isShowingOptions)
 
-                 {
 
-                     // ShowOptions();
 
-                 }
 
-                 else
 
-                 {
 
-                     if (eventConditionConfig.ID != 0 && _eventLinkData != null &&
 
-                         _eventLinkData.eventConditions.Count > 0)
 
-                     {
 
-                         foreach (var eventConditionData in _eventLinkData.eventConditions)
 
-                         {
 
-                             if (!EventSystemManager.Instance.IsEvenkLinkComplete(eventConditionData))
 
-                             {
 
-                                 TipMessagePanel.OpenTipMessagePanel(EventHelper.GetTaskMessage(eventConditionData));
 
-                                 return;
 
-                             }
 
-                         }
 
-                     }
 
-                     if (eventConditionConfig.optionType == 3)
 
-                     {
 
-                         Btn_Bag.gameObject.SetActive(true);
 
-                         List<ItemInfo> itemInfos = new List<ItemInfo>();
 
-                         for (var i = 0; i < eventConditionConfig.PrizeIDs.Length; i++)
 
-                         {
 
-                             DropConfig dropConfig =
 
-                                 ConfigComponent.Instance.Get<DropConfig>(eventConditionConfig.PrizeIDs[i]);
 
-                             if (dropConfig.dropType == 3)
 
-                             {
 
-                                 ItemInfo itemInfo = new ItemInfo(dropConfig.dropGroupID[0],
 
-                                     eventConditionConfig.PrizeNums[i]);
 
-                                 itemInfos.Add(itemInfo);
 
-                             }
 
-                             else
 
-                             {
 
-                                 List<ItemInfo> items = DropManager.Instance.DropItem(eventConditionConfig.PrizeIDs[i]);
 
-                                 itemInfos.AddRange(items);
 
-                             }
 
-                         }
 
-                         ShowItemMoveToTargetPanel showItemMoveToTargetUiPane =
 
-                             UIManager.Instance.GetComponent<ShowItemMoveToTargetPanel>();
 
-                         Vector3 target = showItemMoveToTargetUiPane.transform.worldToLocalMatrix *
 
-                                          Btn_Bag.transform.position;
 
-                         Vector3 startPos = showItemMoveToTargetUiPane.transform.worldToLocalMatrix *
 
-                                            StartPos.transform.position;
 
-                         int maxCount = 1;
 
-                         foreach (var itemInfo in itemInfos)
 
-                         {
 
-                             int addValue = (int)itemInfo.count.Value / maxCount;
 
-                             int finishVale = (int)itemInfo.count.Value % maxCount;
 
-                             // ItemInfo i = itemInfo;
 
-                             showItemMoveToTargetUiPane.ShowPanel(startPos, target, maxCount, itemInfo.config.icon,
 
-                                 CombatItemShowEventData.ShowType.HeroExp, (imageMove) =>
 
-                                 {
 
-                                     int currAddValue = addValue;
 
-                                     if (imageMove.GroupIndex == maxCount - 1)
 
-                                     {
 
-                                         currAddValue += finishVale;
 
-                                     }
 
-                                 });
 
-                         }
 
-                         await TimerComponent.Instance.WaitAsync(2000);
 
-                     }
 
-                     // 无选项,关闭面板,返回 null
 
-                     UIManager.Instance.HideUIUIPanel(this);
 
-                     finish?.Invoke(null);
 
-                 }
 
-                 return;
 
-             }
 
-             _isShowNextButton = false;
 
-             shownextIcon.SetActive(false);
 
-             string m = LanguageManager.Instance.Text(dialogueMessaga[index], PlayerManager.Instance.PlayerName);
 
-             // if (showIconName != null && index < showIconName.Length)
 
-             // {
 
-             //     icon.icon_name = showIconName[index];
 
-             // }
 
-             index++;
 
-             switch (messageShowType)
 
-             {
 
-                 case ShowDialogueEventData.MessageShowType.Default:
 
-                     showText.text = m;
 
-                     ShowNextIcon();
 
-                     break;
 
-                 case ShowDialogueEventData.MessageShowType.Verbatim:
 
-                     _sb.Clear();
 
-                     _currShowMessage = m.ToCharArray();
 
-                     if (eventConditionConfig.DialogueType == 2 && eventConditionConfig.NPCID == 100 && PlayerManager.Instance.PlayerName != String.Empty)
 
-                     {
 
-                         _sb.Append(PlayerManager.Instance.PlayerName + ":");
 
-                     }
 
-                     _sb.Append(_currShowMessage[0]);
 
-                     showText.text = _sb.ToString();
 
-                     _isUpdate = true;
 
-                     _currShowIndex = 1;
 
-                     _skipTyping = false;
 
-                     break;
 
-             }
 
-             LayoutRebuilder.ForceRebuildLayoutImmediate(Dialgue);
 
-         }
 
-         private async void ShowOptions()
 
-         {
 
-             await MarskPanel.OpenPanel();
 
-             UIManager.Instance.DormancyAllGComponent<DialogueOptionWidget>();
 
-             _isShowingOptions = true;
 
-             if (eventConditionConfig.optionType == 1 && eventConditionConfig.optionPara1 != null)
 
-             {
 
-                 OptionMarsk.SetActive(true);
 
-                 for (var i = 0; i < eventConditionConfig.optionPara1.Length; i++)
 
-                 {
 
-                     int index = eventConditionConfig.optionPara1.Length - 1 - i;
 
-                     DialogueOptionWidget dialogueOptionWidget =
 
-                         await UIManager.Instance.CreateGComponent<DialogueOptionWidget>(null, OptionRoot);
 
-                     dialogueOptionWidget.CustomInit(i, CurrentEventList, eventConditionConfig.optionPara1[i],
 
-                         eventConditionConfig.ID, SelectOption);
 
-                     dialogueOptionWidget.transform.position = OptionPos[index].position;
 
-                     await TimerComponent.Instance.WaitAsync(200);
 
-                 }
 
-                 LayoutRebuilder.ForceRebuildLayoutImmediate(Dialgue);
 
-             }
 
-             await MarskPanel.ClosePanel();
 
-         }
 
-         private async void SelectOption(DialogueOptionWidget obj)
 
-         {
 
-             if (obj.eventLinkData != null &&
 
-                 !EventSystemManager.Instance.IsCeekEventGroupComplete(obj.eventLinkData.eventConditions))
 
-             {
 
-                 bool isOk = await EventTipsPanel.OpenPanel(obj.eventLinkData);
 
-                 if (isOk)
 
-                 {
 
-                     UIManager.Instance.HideUIUIPanel(this);
 
-                     finish?.Invoke(-1);
 
-                 }
 
-                 // TipMessagePanel.OpenTipMessagePanel(EventHelper.GetTaskMessage(selectedOptionID));
 
-                 return;
 
-             }
 
-             OptionMarsk.SetActive(false);
 
-             int selectedOptionID = obj.eventConditionConfig.ID;
 
-             UIManager.Instance.HideUIUIPanel(this);
 
-             finish?.Invoke(selectedOptionID);
 
-         }
 
-         private void ShowNextIcon()
 
-         {
 
-             shownextIcon.SetActive(true);
 
-             _isShowNextButton = true;
 
-         }
 
-         public override void Hide()
 
-         {
 
-             base.Hide();
 
-             StaticUpdater.Instance.RemoveRenderUpdateCallBack(Update);
 
-         }
 
-         public void Update()
 
-         {
 
-             // if (EventSystemManager.Instance.isOpenUi && eventConditionConfig.ID != 0)
 
-             //     return;
 
-             if (!_isUpdate) return;
 
-             if (messageShowType == ShowDialogueEventData.MessageShowType.Verbatim)
 
-             {
 
-                 if (_currShowIndex >= _currShowMessage.Length)
 
-                 {
 
-                     _isUpdate = false;
 
-                     ShowNextIcon();
 
-                     if (index >= dialogueMessaga.Length)
 
-                     {
 
-                         if (eventConditionConfig.ID != 0 && !_isShowingOptions)
 
-                         {
 
-                             ShowOptions();
 
-                         }
 
-                     }
 
-                     return;
 
-                 }
 
-                 _currShowTime += Time.deltaTime;
 
-                 if (_currShowTime > _showTime)
 
-                 {
 
-                     _currShowTime -= _showTime;
 
-                     _sb.Append(_currShowMessage[_currShowIndex]);
 
-                     _currShowIndex++;
 
-                     showText.text = _sb.ToString();
 
-                 }
 
-             }
 
-         }
 
-         public async override CTask Close()
 
-         {
 
-             UIManager.Instance.DormancyAllGComponent<DialogueOptionWidget>();
 
-             _isShowingOptions = false;
 
-             _skipTyping = false;
 
-             index = 0;
 
-             eventConditionConfig = default;
 
-             _eventLinkData = null;
 
-             CurrentEventList = null;
 
-             _currShowMessage = null;
 
-             dialogueMessaga = null;
 
-             // DialgueType1.gameObject.SetActive(false);
 
-             // DialgueType2.gameObject.SetActive(false);
 
-             OptionMarsk.SetActive(false);
 
-             isOver = false;
 
-             await base.Close();
 
-             // DialgueType1Anim.Play("DialgueType1idle");
 
-         }
 
-     }
 
- }
 
 
  |