12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- using Excel2Json;
- using Unity.VisualScripting;
- using UnityEngine;
- using UnityEngine.UI;
- namespace Mono
- {
- [UIBinding(prefab = "ChatPanel")]
- public class ChatPanel : UIPanel
- {
- public Button Btn_OnClick;
- public Typewriter Text_Dialogue;
- public int MaxIndex;
- public Transform Text_YK;
- public Transform Image_NPC;
- public override void GetUIData()
- {
- Btn_OnClick = UIData.Get<Button>("Btn_OnClick");
- Text_Dialogue = UIData.Get<Typewriter>("Text_Dialogue");
- Text_Dialogue.IsOver = true;
- MaxIndex = ConfigComponent.Instance.GetAll<DialogueConfig>().Length;
- Text_YK = UIData.Get<RectTransform>("Text_YK");
- Image_NPC = UIData.Get<RectTransform>("Image_NPC");
- }
- public override void AddButtonEvent()
- {
- Btn_OnClick.onClick.AddListener(() => { Dialogue(); });
- }
- public int CurIndex;
- public bool IsOver;
-
-
-
- public override void Show()
- {
- base.Show();
- Image_NPC.gameObject.SetActive(true);
- Text_YK.gameObject.SetActive(false);
- UIManager.Instance.PlayBGM("scene02");
- CurIndex = 0;
- Text_Dialogue.Showtext.text = "";
-
-
- }
- public void Dialogue()
- {
- if (CurIndex >= MaxIndex)
- {
- IsOver = true;
- UIManager.Instance.HideUIPanel<ChatPanel>();
- UIManager.Instance.LoadAndOpenPanel<InputPanel>(UIManager.UILayer.Middle);
- return;
- }
- if (Text_Dialogue.IsOver)
- {
- UIManager.Instance.PlayAudioClip("UI_Bubble");
- CurIndex++;
- DialogueConfig dialogueConfig = ConfigComponent.Instance.Get<DialogueConfig>(CurIndex);
- Text_Dialogue.StringContent = dialogueConfig.name;
- Text_Dialogue.SetContent();
- if (CurIndex % 2 == 0)
- {
- Image_NPC.gameObject.SetActive(false);
- Text_YK.gameObject.SetActive(true);
- }
- else
- {
- Image_NPC.gameObject.SetActive(true);
- Text_YK.gameObject.SetActive(false);
- }
- }
- }
- }
- }
|