123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- using System;
- using Core.Language;
- using Excel2Json;
- using Fort23.Core;
- using Fort23.UTool;
- using Mono.Utility;
- using UnityEngine;
- using UnityEngine.UI;
- namespace Fort23.Mono
- {
- public class DialogBox
- {
- /// <summary>
- /// 对话内容.
- /// </summary>
- public Text Content;
- public Text Text_Dialogue01;
- public Text Text_Dialogue02;
- public Text Text_Dialogue03;
- // public BoxCollider boxCol;
- public Transform MessageBG;
- public Transform di;
- public MyImage NpcIcon;
- public MyImage HeroIcon;
- private BetterList<string> dialogTextList;
- private int curIdx;
- public Action onAction;
- public UISpiritLoader UISpiritLoader;
- public Text NpcNameText;
- public void Init()
- {
- GuidePanel guidePanel = UIManager.Instance.GetComponent<GuidePanel>();
- // guidePanel.DialogBoxState.gameObject.SetActive(true);
- NpcIcon = guidePanel.Image_Npc;
- HeroIcon = guidePanel.HeroIcon;
- MessageBG = guidePanel.MessageBG;
- UISpiritLoader = NpcIcon.transform.parent.GetComponent<UISpiritLoader>();
- NpcNameText = guidePanel.Text_NpcName;
- Text_Dialogue01 = guidePanel.Text_Dialogue01;
- Text_Dialogue02 = guidePanel.Text_Dialogue02;
- Text_Dialogue03 = guidePanel.Text_Dialogue03;
- }
- public void Open(BetterList<string> list, Action action)
- {
- GuidePanel guidePanel = UIManager.Instance.GetComponent<GuidePanel>();
- guidePanel.DialogBoxState.gameObject.SetActive(true);
- if (list == null || list.size <= 0)
- {
- Close();
- return;
- }
- if (action == null) Debug.Log("action == null");
- onAction = action;
- curIdx = 0;
- dialogTextList = list;
- OnClickScreen();
- }
- // private AssetHandle assetHandle;
- /// <summary>
- ///
- /// </summary>
- /// <param name="playerGuideConfig"></param>
- /// <param name="id">1:默认 2:剧情1 3:boss</param>
- public async CTask SetDiTex(PlayerGuideConfig playerGuideConfig, int id)
- {
- HeroModelConfig heroModelConfig = ConfigComponent.Instance.Get<HeroModelConfig>(id);
- NpcIcon.gameObject.SetActive(false);
- CTask cTask = CTask.Create();
- NpcIcon.onSpriteAlter = () =>
- {
- NpcIcon.SetNativeSize();
- NpcIcon.gameObject.SetActive(true);
- cTask.SetResult();
- };
- // NpcIcon.icon_name = heroModelConfig.LiHuiName;
- // HeroIcon.icon_name = heroModelConfig.HeroUIIconName;
- if (playerGuideConfig.reversalBox == 1)
- {
- NpcIcon.transform.rotation = Quaternion.Euler(0, 180, 0);
- }
- else
- {
- NpcIcon.transform.rotation = Quaternion.Euler(0, 0, 0);
- }
- // NpcNameText.text = LanguageManager.Instance.Text(heroModelConfig.HeroNameID);
- NpcIcon.enabled = true;
- await cTask;
- }
- public void OnClickScreen()
- {
- // for (int i = 0; i < 100; i++)
- // {
- //
- // }
- if (dialogTextList == null)
- {
- return;
- }
- if (dialogTextList.size > curIdx)
- {
- Content.text = dialogTextList[curIdx++];
- //最后一条
- if (dialogTextList.size == curIdx)
- {
- if (PlayerGuideManager.Instance.guideConfig.forceText == 0)
- {
- // PlayerGuideManager.Instance.SetFingerVisiable(true);
- PlayerGuideManager.Instance.CanDoNextCTask = CTask.Create();
- onAction?.Invoke();
- onAction = null;
- PlayerGuideManager.Instance.CanDoNextCTask.SetResult();
- }
- }
- }
- else
- {
- PlayerGuideManager.Instance.CanDoNextCTask = CTask.Create();
- onAction?.Invoke();
- onAction = null;
- PlayerGuideManager.Instance.CanDoNextCTask.SetResult();
- }
- }
- public void Close()
- {
- PlayerGuideManager.Instance.CanDoNextCTask = CTask.Create();
- onAction?.Invoke();
- onAction = null;
- PlayerGuideManager.Instance.CanDoNextCTask.SetResult();
- }
- public void ChangeState(int guideConfigSpeakerStyle)
- {
- switch (guideConfigSpeakerStyle)
- {
- case 1:
- Content = Text_Dialogue01;
- break;
- case 2:
- Content = Text_Dialogue02;
- break;
- case 3:
- Content = Text_Dialogue03;
- break;
- }
- }
- }
- }
|