2025-09-08 14:51:28 +08:00
|
|
|
|
using DG.Tweening;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
using TMPro;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
using ZXKFramework;
|
|
|
|
|
|
using static System.Net.Mime.MediaTypeNames;
|
2025-09-28 15:59:02 +08:00
|
|
|
|
namespace DongWuYiXue.DaoNiaoShu
|
2025-09-08 14:51:28 +08:00
|
|
|
|
{
|
|
|
|
|
|
public class TipPanel : UIBase
|
|
|
|
|
|
{
|
|
|
|
|
|
public override string GroupName => "TipPanel";
|
|
|
|
|
|
public override string Name => "TipPanel";
|
|
|
|
|
|
|
|
|
|
|
|
TextMeshProUGUI tip;
|
|
|
|
|
|
List<string> str = new();
|
|
|
|
|
|
public Transform p1; // <20><>ʼ<EFBFBD><CABC>Transform
|
|
|
|
|
|
public Transform p2; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Transform
|
|
|
|
|
|
public RectTransform container;
|
|
|
|
|
|
Button upBtn;
|
|
|
|
|
|
Button downBtn;
|
|
|
|
|
|
ScrollRect scrollRect;
|
|
|
|
|
|
Coroutine coroutine;
|
2025-09-28 15:59:02 +08:00
|
|
|
|
|
|
|
|
|
|
float hei;
|
2025-09-08 14:51:28 +08:00
|
|
|
|
public override void Init(IUIManager uictrl)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Init(uictrl);
|
|
|
|
|
|
tip = transform.FindFirst<TextMeshProUGUI>("showText");
|
|
|
|
|
|
upBtn = transform.FindFirst<Button>("upBtn");
|
|
|
|
|
|
downBtn = transform.FindFirst<Button>("downBtn");
|
|
|
|
|
|
scrollRect = transform.FindFirst<ScrollRect>("Scroll View");
|
2025-09-28 15:59:02 +08:00
|
|
|
|
|
2025-09-08 14:51:28 +08:00
|
|
|
|
upBtn.onClick.AddListener(MoveUp);
|
|
|
|
|
|
downBtn.onClick.AddListener(MoveDown);
|
|
|
|
|
|
}
|
|
|
|
|
|
public void AddTip(string tips)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetActive(false);
|
|
|
|
|
|
str.Clear();
|
|
|
|
|
|
str = tips.Split('|').ToList();
|
|
|
|
|
|
}
|
|
|
|
|
|
public void ShowTip(int i)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetActive(true);
|
2025-09-28 15:59:02 +08:00
|
|
|
|
|
2025-09-08 14:51:28 +08:00
|
|
|
|
Game.Instance.IEnumeratorManager.Stop(coroutine);
|
|
|
|
|
|
tip.text = str[i].Replace("<br>", "\n");
|
|
|
|
|
|
//Debug.Log(Regex.Replace(Regex.Replace(tip.text, @"<color=[^>]*>", ""), @"</color>", "").Length + "==" + (Regex.Replace(Regex.Replace(tip.text, @"<color=[^>]*>", ""), @"</color>", "").Length + 70 - 1) / 70);
|
|
|
|
|
|
//if (scrollRect.content.rect.height > 57)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// coroutine = Game.Instance.IEnumeratorManager.Run(Scroll((int)(scrollRect.content.rect.height + 56 - 1) / 56));
|
|
|
|
|
|
//}
|
2025-09-28 15:59:02 +08:00
|
|
|
|
scrollRect.normalizedPosition = new Vector2(0, 1);
|
|
|
|
|
|
hei = scrollRect.content.rect.height;
|
2025-09-08 14:51:28 +08:00
|
|
|
|
container.position = p1.position;
|
|
|
|
|
|
coroutine = Game.Instance.IEnumeratorManager.Run(Scroll());
|
|
|
|
|
|
}
|
|
|
|
|
|
public void ShowTip(string str)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetActive(true);
|
|
|
|
|
|
tip.text = str.Replace("<br>", "\n");
|
|
|
|
|
|
}
|
|
|
|
|
|
public override void Hide()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Hide();
|
|
|
|
|
|
Game.Instance.IEnumeratorManager.Stop(coroutine);
|
|
|
|
|
|
Game.Instance.sound.StopBGM();
|
|
|
|
|
|
}
|
|
|
|
|
|
public void MoveDown()
|
|
|
|
|
|
{
|
|
|
|
|
|
container.DOMove(p2.position, 0.5f);
|
|
|
|
|
|
upBtn.gameObject.SetActive(true);
|
|
|
|
|
|
downBtn.gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
public void MoveUp()
|
|
|
|
|
|
{
|
|
|
|
|
|
container.DOMove(p1.position, 0.5f);
|
|
|
|
|
|
upBtn.gameObject.SetActive(false);
|
|
|
|
|
|
downBtn.gameObject.SetActive(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
IEnumerator Scroll()
|
|
|
|
|
|
{
|
2025-09-28 15:59:02 +08:00
|
|
|
|
//scrollRect.normalizedPosition = new Vector2(0, 1);
|
2025-09-08 14:51:28 +08:00
|
|
|
|
yield return new WaitForSeconds(1);
|
2025-09-28 15:59:02 +08:00
|
|
|
|
//Debug.Log(scrollRect.content.rect.height)
|
|
|
|
|
|
//if (scrollRect.content.rect.height > 57)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// int i = (int)(scrollRect.content.rect.height + 56 - 1) / 56;
|
|
|
|
|
|
// for (int j = 0; j < i; j++)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// //Debug.Log((int)scrollRect.normalizedPosition.y);
|
|
|
|
|
|
// if ((int)scrollRect.normalizedPosition.y == 0) yield break;
|
|
|
|
|
|
// yield return new WaitForSeconds(13f);
|
|
|
|
|
|
// scrollRect.normalizedPosition -= new Vector2(0, 1 - (1 / i));
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------<2D>ĺ<DEB8>-----------------------------------------
|
|
|
|
|
|
if (scrollRect.content.rect.height > 80)
|
2025-09-08 14:51:28 +08:00
|
|
|
|
{
|
2025-09-28 15:59:02 +08:00
|
|
|
|
if (scrollRect.normalizedPosition.y > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
yield return new WaitForSeconds(17.0f);
|
|
|
|
|
|
float y = (hei - 80) / scrollRect.content.rect.height;
|
|
|
|
|
|
hei -= 80;
|
|
|
|
|
|
if (hei <= 80 && hei > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
hei = 80;
|
|
|
|
|
|
}
|
|
|
|
|
|
scrollRect.normalizedPosition = new Vector2(0, y);
|
|
|
|
|
|
if (null != coroutine)
|
|
|
|
|
|
{
|
|
|
|
|
|
Game.Instance.IEnumeratorManager.Stop(coroutine);
|
|
|
|
|
|
coroutine = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
coroutine = Game.Instance.IEnumeratorManager.Run(Scroll());
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
2025-09-08 14:51:28 +08:00
|
|
|
|
{
|
2025-09-28 15:59:02 +08:00
|
|
|
|
Game.Instance.IEnumeratorManager.Stop(coroutine);
|
2025-09-08 14:51:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|