2024-01-09 14:00:53 +08:00
|
|
|
|
using System.Collections.Generic;
|
2023-10-26 20:20:11 +08:00
|
|
|
|
using System.Threading;
|
|
|
|
|
|
using cfg.LevelCfg;
|
|
|
|
|
|
using Cysharp.Threading.Tasks;
|
2023-10-30 18:33:18 +08:00
|
|
|
|
using Framework;
|
2023-12-05 12:49:29 +08:00
|
|
|
|
using Gameplay;
|
2023-10-26 20:20:11 +08:00
|
|
|
|
using Gameplay.Level;
|
|
|
|
|
|
using PhxhSDK;
|
2023-10-24 14:58:21 +08:00
|
|
|
|
using TMPro;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using Button = UnityEngine.UI.Button;
|
|
|
|
|
|
using Image = UnityEngine.UI.Image;
|
|
|
|
|
|
|
|
|
|
|
|
public class UI_LevelSelectController : UIWindow
|
|
|
|
|
|
{
|
2023-10-26 20:20:11 +08:00
|
|
|
|
//UI GameObj
|
|
|
|
|
|
///Auto Gen Start///
|
2024-01-18 19:12:39 +08:00
|
|
|
|
public Button Button_Back;
|
|
|
|
|
|
|
|
|
|
|
|
public TMP_Text Text_Back;
|
|
|
|
|
|
public Button Button_Home;
|
|
|
|
|
|
public Button Button_MainLevel;
|
|
|
|
|
|
public Image Image_MainlevelLogo;
|
2024-01-09 14:00:53 +08:00
|
|
|
|
public Button Button_DungeonlEVEL;
|
2024-01-18 19:12:39 +08:00
|
|
|
|
public Image Image_TextBG;
|
|
|
|
|
|
public TMP_Text Text_MainLevel;
|
|
|
|
|
|
public TMP_Text Text_Campaignnode;
|
|
|
|
|
|
public Image Image_BlackBar;
|
|
|
|
|
|
public TMP_Text Text_MainLevelProcess;
|
|
|
|
|
|
public TMP_Text Text_MainLevelNum;
|
|
|
|
|
|
public TMP_Text Text_MainLevelName;
|
|
|
|
|
|
public Image Image_Seperate;
|
|
|
|
|
|
public Image Image_LastRect;
|
|
|
|
|
|
public TMP_Text Text_LastLevel;
|
|
|
|
|
|
public TMP_Text Text_LastLevelNum;
|
|
|
|
|
|
public TMP_Text Text_LastLevelName;
|
|
|
|
|
|
public Button Button_BranchLevel;
|
|
|
|
|
|
public Image Image_ChapterBG;
|
|
|
|
|
|
public TMP_Text Text_Title;
|
|
|
|
|
|
public Image Image_FractionlLogo;
|
|
|
|
|
|
public Image Image_LevelBG;
|
|
|
|
|
|
public TMP_Text Text_ChapterName;
|
|
|
|
|
|
public TMP_Text Text_ChapterNum;
|
|
|
|
|
|
public Image Image_ProcessBG;
|
|
|
|
|
|
public Image Image_ProcessBar;
|
|
|
|
|
|
public Image Image_Reward01;
|
|
|
|
|
|
public Image Image_Reward02;
|
|
|
|
|
|
public Image Image_Reward03;
|
|
|
|
|
|
public Button Button_GetAll;
|
2024-01-18 17:16:20 +08:00
|
|
|
|
public TMP_Text Text_StarNum;
|
2024-01-18 19:12:39 +08:00
|
|
|
|
public Image Image_Start;
|
|
|
|
|
|
public Image Image_ModeBG;
|
|
|
|
|
|
public Image Image_SelectBG;
|
|
|
|
|
|
public Button Button_Plot;
|
|
|
|
|
|
public TMP_Text Text_Read;
|
|
|
|
|
|
public Image Image_Pot;
|
|
|
|
|
|
public Button Button_Easy;
|
|
|
|
|
|
public TMP_Text Text_Simple;
|
|
|
|
|
|
public Button Button_Hard;
|
|
|
|
|
|
public TMP_Text Text_Hard;
|
|
|
|
|
|
public Image Image_pot;
|
|
|
|
|
|
public TMP_Text Text_Mode;
|
|
|
|
|
|
|
2023-10-26 20:20:11 +08:00
|
|
|
|
///Auto Gen End///
|
2024-01-19 14:40:40 +08:00
|
|
|
|
private const string IN_ANIMATION_NAME = "LS_MoveIn";
|
2024-01-19 19:20:05 +08:00
|
|
|
|
|
2024-01-19 14:40:40 +08:00
|
|
|
|
private const string OUT_ANIMATION_NAME = "LS_MoveOut";
|
2024-01-19 19:20:05 +08:00
|
|
|
|
|
2023-10-26 20:20:11 +08:00
|
|
|
|
private enum PageType
|
|
|
|
|
|
{
|
|
|
|
|
|
Mode = 1,
|
2024-01-05 19:35:51 +08:00
|
|
|
|
Chapter = 2,
|
2023-10-26 20:20:11 +08:00
|
|
|
|
Level = 3,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-09 16:54:21 +08:00
|
|
|
|
private Animation _animation;
|
|
|
|
|
|
|
2023-10-26 20:20:11 +08:00
|
|
|
|
private PageType _currPage = PageType.Mode;
|
2024-01-05 19:15:21 +08:00
|
|
|
|
private LevelChapterType _currChapterType;
|
|
|
|
|
|
private ChapterInfo _currChapterInfo;
|
|
|
|
|
|
private LevelGroupInfo _currEasyLevelGroupInfo;
|
|
|
|
|
|
private LevelGroupInfo _currHardLevelGroupInfo;
|
|
|
|
|
|
private LevelGroupInfo _currPlotLevelGroupInfo;
|
|
|
|
|
|
private LevelGroupInfo _currLevelGroupInfo;
|
2023-10-26 20:20:11 +08:00
|
|
|
|
private LevelInfo _currSelectLevelInfo;
|
2024-01-05 19:35:51 +08:00
|
|
|
|
private List<ChapterInfo> _showChapterInfoList = new();
|
2023-10-26 20:20:11 +08:00
|
|
|
|
private List<LevelInfo> _showLevelInfoList = new();
|
|
|
|
|
|
|
|
|
|
|
|
private RectTransform UI_ModeChoose;
|
|
|
|
|
|
private RectTransform UI_LevelGroupChoose;
|
|
|
|
|
|
private RectTransform UI_LevelChoose;
|
|
|
|
|
|
private RectTransform _modeParent;
|
2023-12-05 12:49:29 +08:00
|
|
|
|
private PhxhScrollView _levelGroupScrollView;
|
|
|
|
|
|
private PhxhScrollView _levelScrollView;
|
2023-10-26 20:20:11 +08:00
|
|
|
|
private RectTransform _starRewardsParent;
|
2024-01-05 19:35:51 +08:00
|
|
|
|
private RedPointUIController _easyLevelGroupRedPointUI;
|
|
|
|
|
|
private RedPointUIController _hardLevelGroupRedPointUI;
|
|
|
|
|
|
private RedPointUIController _plotLevelGroupRedPointUI;
|
2023-10-26 20:20:11 +08:00
|
|
|
|
|
2024-01-18 17:16:20 +08:00
|
|
|
|
//private const string STAR_REWARD_PREFAB_PATH = "Assets/Art/UI/Prefab/LevelSelect/Button_StarReward.prefab";
|
2024-01-19 14:00:42 +08:00
|
|
|
|
// private List<GameObject> _starRewardPool = new();
|
|
|
|
|
|
// private List<GameObject> _showStarReward = new();
|
2023-10-26 20:20:11 +08:00
|
|
|
|
|
2024-01-18 17:16:20 +08:00
|
|
|
|
private float _progressmoveSpeed = 1f;
|
2023-10-27 12:07:33 +08:00
|
|
|
|
private CancellationTokenSource _cts;
|
2023-10-26 20:20:11 +08:00
|
|
|
|
|
2024-01-19 14:00:42 +08:00
|
|
|
|
private List<Button> _modeButtons = new();
|
|
|
|
|
|
|
2024-01-23 12:25:47 +08:00
|
|
|
|
public override void OnInit()
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
|
|
|
|
|
//bind UI GameObj
|
|
|
|
|
|
UI_LevelSelectBinder.GetComponents(this);
|
|
|
|
|
|
BindProperty();
|
|
|
|
|
|
BindEvent();
|
|
|
|
|
|
RegisterSignal();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void BindProperty()
|
|
|
|
|
|
{
|
|
|
|
|
|
UI_ModeChoose = transform.Find("UI_ModeChoose") as RectTransform;
|
|
|
|
|
|
UI_LevelGroupChoose = transform.Find("UI_LevelGroupChoose") as RectTransform;
|
|
|
|
|
|
UI_LevelChoose = transform.Find("UI_LevelChoose") as RectTransform;
|
|
|
|
|
|
_modeParent = UI_ModeChoose.Find("Scroll View/Viewport/Content") as RectTransform;
|
2023-11-02 20:02:10 +08:00
|
|
|
|
_levelGroupScrollView = UI_LevelGroupChoose.Find("Image_ChapterBG/Scroll View")
|
2023-12-05 12:49:29 +08:00
|
|
|
|
.GetComponent<PhxhScrollView>();
|
|
|
|
|
|
_levelScrollView = UI_LevelChoose.Find("Image_LevelBG/Scroll View").GetComponent<PhxhScrollView>();
|
2024-01-18 16:02:45 +08:00
|
|
|
|
_starRewardsParent = Image_ProcessBar.transform as RectTransform;
|
2023-10-26 20:20:11 +08:00
|
|
|
|
|
2024-01-18 17:16:20 +08:00
|
|
|
|
_levelGroupScrollView.SetUpdateFunc(OnRenderChapter);
|
2023-10-26 20:20:11 +08:00
|
|
|
|
_levelGroupScrollView.SetItemCountFunc(GetLevelGroupCount);
|
2024-01-04 13:51:08 +08:00
|
|
|
|
//_levelGroupScrollView.SetButton(SetOnLevelGroupClick);
|
2023-10-26 20:20:11 +08:00
|
|
|
|
|
|
|
|
|
|
_levelScrollView.SetUpdateFunc(OnRenderLevelInfo);
|
|
|
|
|
|
_levelScrollView.SetItemCountFunc(GetLevelCount);
|
2024-01-04 13:51:08 +08:00
|
|
|
|
//_levelScrollView.SetButton(SetOnLevelClick);
|
2023-11-02 20:02:10 +08:00
|
|
|
|
|
2024-01-05 19:35:51 +08:00
|
|
|
|
_easyLevelGroupRedPointUI = Button_Easy.transform.Find("UI_RedPoint").GetComponent<RedPointUIController>();
|
|
|
|
|
|
_hardLevelGroupRedPointUI = Button_Hard.transform.Find("UI_RedPoint").GetComponent<RedPointUIController>();
|
|
|
|
|
|
_plotLevelGroupRedPointUI = Button_Plot.transform.Find("UI_RedPoint").GetComponent<RedPointUIController>();
|
2024-01-09 16:54:21 +08:00
|
|
|
|
|
|
|
|
|
|
_animation = GetComponent<Animation>();
|
2024-01-19 14:00:42 +08:00
|
|
|
|
|
|
|
|
|
|
_modeButtons.Clear();
|
|
|
|
|
|
var modeButtonParent = "UI_ModeChoose/Scroll View/Viewport/Content";
|
|
|
|
|
|
var modeContent = transform.Find(modeButtonParent);
|
|
|
|
|
|
if (modeContent != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (Transform child in modeContent)
|
|
|
|
|
|
{
|
|
|
|
|
|
var button = child.GetComponent<Button>();
|
|
|
|
|
|
if (button != null)
|
|
|
|
|
|
_modeButtons.Add(button);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-10-26 20:20:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void BindEvent()
|
|
|
|
|
|
{
|
2024-01-09 14:00:53 +08:00
|
|
|
|
BindButton(Button_Back, OnClickBack);
|
|
|
|
|
|
BindButton(Button_Home, OnClickHome);
|
|
|
|
|
|
BindButton(Button_Easy, OnClickEasy);
|
|
|
|
|
|
BindButton(Button_Hard, OnClickHard);
|
|
|
|
|
|
BindButton(Button_Plot, OnClickPlot);
|
2024-01-18 17:16:20 +08:00
|
|
|
|
BindButton(Button_GetAll, OnClickStarReward);
|
2023-10-26 20:20:11 +08:00
|
|
|
|
var modeButtonCount = _modeParent.childCount;
|
|
|
|
|
|
for (int i = 0; i < modeButtonCount; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var modeButton = _modeParent.GetChild(i).GetComponent<Button>();
|
|
|
|
|
|
modeButton.onClick.RemoveAllListeners();
|
|
|
|
|
|
var index = i;
|
|
|
|
|
|
modeButton.onClick.AddListener(() =>
|
|
|
|
|
|
{
|
2024-01-05 19:15:21 +08:00
|
|
|
|
var levelChapterType = (LevelChapterType)index;
|
|
|
|
|
|
EnterSelectLevelGroup(levelChapterType);
|
2023-10-26 20:20:11 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void RegisterSignal()
|
|
|
|
|
|
{
|
2023-11-03 12:39:51 +08:00
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.ChapterInfoChange, Refresh);
|
|
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.LevelUnlock, Refresh);
|
|
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.LevelInfoChanged, Refresh);
|
2023-10-26 20:20:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void UnRegisterSignal()
|
|
|
|
|
|
{
|
2023-11-03 12:39:51 +08:00
|
|
|
|
EventManager.Instance.Unregister(EventManager.EventName.ChapterInfoChange, Refresh);
|
|
|
|
|
|
EventManager.Instance.Unregister(EventManager.EventName.LevelUnlock, Refresh);
|
|
|
|
|
|
EventManager.Instance.Unregister(EventManager.EventName.LevelInfoChanged, Refresh);
|
2023-10-26 20:20:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Refresh()
|
|
|
|
|
|
{
|
|
|
|
|
|
RefreshPage();
|
|
|
|
|
|
switch (_currPage)
|
|
|
|
|
|
{
|
|
|
|
|
|
case PageType.Mode:
|
|
|
|
|
|
RefreshMode();
|
|
|
|
|
|
break;
|
2024-01-05 19:35:51 +08:00
|
|
|
|
case PageType.Chapter:
|
|
|
|
|
|
RefreshChapter();
|
2023-10-26 20:20:11 +08:00
|
|
|
|
break;
|
|
|
|
|
|
case PageType.Level:
|
|
|
|
|
|
RefreshLevel();
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//将当前UI看成是三个页面,选模式,选关卡组,选关
|
|
|
|
|
|
private void RefreshPage()
|
|
|
|
|
|
{
|
|
|
|
|
|
UI_ModeChoose.gameObject.SetActive(_currPage == PageType.Mode);
|
2024-01-05 19:35:51 +08:00
|
|
|
|
UI_LevelGroupChoose.gameObject.SetActive(_currPage == PageType.Chapter);
|
2023-10-26 20:20:11 +08:00
|
|
|
|
UI_LevelChoose.gameObject.SetActive(_currPage == PageType.Level);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void RefreshMode()
|
|
|
|
|
|
{
|
2024-01-19 14:00:42 +08:00
|
|
|
|
for (int i = 0; i < (int)LevelChapterType.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (i >= _modeButtons.Count)
|
|
|
|
|
|
return;
|
|
|
|
|
|
OnRenderModeButton(_modeButtons[i], (LevelChapterType)i);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnRenderModeButton(Button btn, LevelChapterType type)
|
|
|
|
|
|
{
|
2024-01-19 19:20:05 +08:00
|
|
|
|
var Image_BlackBar = btn.transform.Find("Image_TextBG/Image_BlackBar").gameObject;
|
|
|
|
|
|
var Image_LastRect = btn.transform.Find("Image_TextBG/Image_LastRect").gameObject;
|
|
|
|
|
|
|
2024-01-19 14:00:42 +08:00
|
|
|
|
var latestLevelInfo = LevelManager.Instance.GetLatestLevelInfo(type);
|
2024-01-19 19:20:05 +08:00
|
|
|
|
Image_BlackBar.SetActive(latestLevelInfo != null);
|
2024-01-19 14:00:42 +08:00
|
|
|
|
if (latestLevelInfo != null)
|
|
|
|
|
|
{
|
2024-01-19 19:20:05 +08:00
|
|
|
|
var Text_MainLevelNum = btn.transform.Find("Image_TextBG/Image_BlackBar/Text_MainLevelNum").GetComponent<TMP_Text>();
|
|
|
|
|
|
var Text_MainLevelName = btn.transform.Find("Image_TextBG/Image_BlackBar/Text_MainLevelName").GetComponent<TMP_Text>();
|
2024-01-19 14:00:42 +08:00
|
|
|
|
Text_MainLevelNum.text = GetLevelLabel(latestLevelInfo);
|
|
|
|
|
|
Text_MainLevelName.text = latestLevelInfo.Name;
|
|
|
|
|
|
}
|
2024-01-19 19:20:05 +08:00
|
|
|
|
|
|
|
|
|
|
var lastFightLevel = LevelManager.Instance.GetLastFightLevelInfo(type);
|
|
|
|
|
|
Image_LastRect.SetActive(lastFightLevel != null);
|
|
|
|
|
|
if (lastFightLevel != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var Text_MainLevelNum = btn.transform.Find("Image_TextBG/Image_LastRect/Text_MainLevelNum").GetComponent<TMP_Text>();
|
|
|
|
|
|
var Text_MainLevelName = btn.transform.Find("Image_TextBG/Image_LastRect/Text_MainLevelName").GetComponent<TMP_Text>();
|
|
|
|
|
|
Text_MainLevelNum.text = GetLevelLabel(lastFightLevel);
|
|
|
|
|
|
Text_MainLevelName.text = lastFightLevel.Name;
|
|
|
|
|
|
}
|
2023-10-26 20:20:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-05 19:35:51 +08:00
|
|
|
|
private void RefreshChapter()
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
2024-01-05 19:35:51 +08:00
|
|
|
|
RefreshChapterToShow();
|
2023-10-26 20:20:11 +08:00
|
|
|
|
_levelGroupScrollView.UpdateData(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-05 19:35:51 +08:00
|
|
|
|
private void RefreshChapterToShow()
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
2024-01-05 19:35:51 +08:00
|
|
|
|
_showChapterInfoList.Clear();
|
|
|
|
|
|
var allChapter = LevelManager.Instance.GetAllChapterInfo();
|
|
|
|
|
|
foreach (var chapterInfo in allChapter)
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
2024-01-18 16:02:45 +08:00
|
|
|
|
if (chapterInfo.ChapterType == _currChapterType && !chapterInfo.IsLock)
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
2024-01-05 19:35:51 +08:00
|
|
|
|
_showChapterInfoList.Add(chapterInfo);
|
2023-10-26 20:20:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-05 20:03:45 +08:00
|
|
|
|
_showChapterInfoList.Sort((a, b) => { return a.ID.CompareTo(b.ID); });
|
2023-10-26 20:20:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void RefreshLevel()
|
|
|
|
|
|
{
|
|
|
|
|
|
RefreshLevelToShow();
|
|
|
|
|
|
_levelScrollView.UpdateData(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void RefreshLevelToShow()
|
|
|
|
|
|
{
|
|
|
|
|
|
_showLevelInfoList.Clear();
|
2024-01-05 19:15:21 +08:00
|
|
|
|
foreach (LevelInfo levelInfo in _currLevelGroupInfo)
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
2023-11-01 13:33:20 +08:00
|
|
|
|
if (!levelInfo.IsLock)
|
2023-10-26 20:20:11 +08:00
|
|
|
|
_showLevelInfoList.Add(levelInfo);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-05 20:03:45 +08:00
|
|
|
|
_showLevelInfoList.Sort((a, b) => a.ID.CompareTo(b.ID));
|
2023-10-26 20:20:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-05 19:15:21 +08:00
|
|
|
|
private void EnterSelectLevelGroup(LevelChapterType type)
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
2024-01-05 19:15:21 +08:00
|
|
|
|
_currChapterType = type;
|
2024-01-05 19:35:51 +08:00
|
|
|
|
_currPage = PageType.Chapter;
|
2023-10-26 20:20:11 +08:00
|
|
|
|
Refresh();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ExitSelectLevelGroup()
|
|
|
|
|
|
{
|
|
|
|
|
|
_currPage = PageType.Mode;
|
|
|
|
|
|
Refresh();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-05 19:15:21 +08:00
|
|
|
|
private void EnterSelectLevel(ChapterInfo chapterInfo)
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
2024-01-05 19:15:21 +08:00
|
|
|
|
_currChapterInfo = chapterInfo;
|
2023-10-26 20:20:11 +08:00
|
|
|
|
_currPage = PageType.Level;
|
2024-01-18 17:16:20 +08:00
|
|
|
|
Text_ChapterName.text = _currChapterInfo.Name;
|
2024-01-18 19:12:39 +08:00
|
|
|
|
Text_ChapterNum.text = string.Format("{0:00}", _currChapterInfo.SortIndex + 1);
|
2024-01-08 19:52:51 +08:00
|
|
|
|
var defaultLevelGroup = InitChapter();
|
|
|
|
|
|
if (defaultLevelGroup != null)
|
|
|
|
|
|
ChangeLevelGroup(defaultLevelGroup);
|
2024-01-18 16:02:45 +08:00
|
|
|
|
Refresh();
|
2023-10-26 20:20:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ExitSelectLevel()
|
|
|
|
|
|
{
|
2024-01-05 19:15:21 +08:00
|
|
|
|
_currChapterInfo = null;
|
|
|
|
|
|
_currEasyLevelGroupInfo = null;
|
|
|
|
|
|
_currHardLevelGroupInfo = null;
|
|
|
|
|
|
_currPlotLevelGroupInfo = null;
|
|
|
|
|
|
_currLevelGroupInfo = null;
|
2023-10-26 20:20:11 +08:00
|
|
|
|
_currSelectLevelInfo = null;
|
2024-01-05 19:35:51 +08:00
|
|
|
|
_currPage = PageType.Chapter;
|
2023-10-26 20:20:11 +08:00
|
|
|
|
Refresh();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-05 19:15:21 +08:00
|
|
|
|
private LevelGroupInfo InitChapter()
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
2024-01-05 19:35:51 +08:00
|
|
|
|
_currEasyLevelGroupInfo = _currChapterInfo.EasyLevelGroup;
|
|
|
|
|
|
_currHardLevelGroupInfo = _currChapterInfo.HardLevelGroup;
|
|
|
|
|
|
_currPlotLevelGroupInfo = _currChapterInfo.PlotLevelGroup;
|
2023-10-26 20:20:11 +08:00
|
|
|
|
|
2024-01-05 19:15:21 +08:00
|
|
|
|
Button_Easy.interactable = IsChapterValid(_currEasyLevelGroupInfo);
|
|
|
|
|
|
Button_Hard.interactable = IsChapterValid(_currHardLevelGroupInfo);
|
|
|
|
|
|
Button_Plot.interactable = IsChapterValid(_currPlotLevelGroupInfo);
|
2023-10-26 20:20:11 +08:00
|
|
|
|
|
2024-01-05 19:35:51 +08:00
|
|
|
|
_easyLevelGroupRedPointUI.ResetToDefault();
|
|
|
|
|
|
_hardLevelGroupRedPointUI.ResetToDefault();
|
|
|
|
|
|
_plotLevelGroupRedPointUI.ResetToDefault();
|
2023-11-02 20:02:10 +08:00
|
|
|
|
|
2024-01-05 19:15:21 +08:00
|
|
|
|
if (_currEasyLevelGroupInfo != null)
|
2024-01-05 19:35:51 +08:00
|
|
|
|
_easyLevelGroupRedPointUI.NodeID = _currEasyLevelGroupInfo.RedPointNode.ID;
|
2024-01-05 19:15:21 +08:00
|
|
|
|
if (_currHardLevelGroupInfo != null)
|
2024-01-05 19:35:51 +08:00
|
|
|
|
_hardLevelGroupRedPointUI.NodeID = _currHardLevelGroupInfo.RedPointNode.ID;
|
2024-01-05 19:15:21 +08:00
|
|
|
|
if (_currPlotLevelGroupInfo != null)
|
2024-01-05 19:35:51 +08:00
|
|
|
|
_plotLevelGroupRedPointUI.NodeID = _currPlotLevelGroupInfo.RedPointNode.ID;
|
2023-11-02 20:02:10 +08:00
|
|
|
|
|
2023-10-26 20:20:11 +08:00
|
|
|
|
var result =
|
2024-01-05 19:15:21 +08:00
|
|
|
|
IsChapterValid(_currEasyLevelGroupInfo) ? _currEasyLevelGroupInfo :
|
|
|
|
|
|
IsChapterValid(_currHardLevelGroupInfo) ? _currHardLevelGroupInfo : _currPlotLevelGroupInfo;
|
2023-10-26 20:20:11 +08:00
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-05 19:15:21 +08:00
|
|
|
|
private bool IsChapterValid(LevelGroupInfo chapter)
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
|
|
|
|
|
return chapter != null && !chapter.IsLock;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-08 19:52:51 +08:00
|
|
|
|
private async void ChangeLevelGroup(LevelGroupInfo currLevelGroupInfo)
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
2024-01-09 16:54:21 +08:00
|
|
|
|
var oldLevelGroupInfo = _currLevelGroupInfo;
|
2024-01-05 19:15:21 +08:00
|
|
|
|
if (_currLevelGroupInfo == currLevelGroupInfo)
|
2023-10-26 20:20:11 +08:00
|
|
|
|
return;
|
2024-01-05 19:15:21 +08:00
|
|
|
|
_currLevelGroupInfo = currLevelGroupInfo;
|
2024-01-18 19:12:39 +08:00
|
|
|
|
SetLevelGroupButtonSelected(Button_Plot, currLevelGroupInfo == _currPlotLevelGroupInfo);
|
|
|
|
|
|
SetLevelGroupButtonSelected(Button_Easy, currLevelGroupInfo == _currEasyLevelGroupInfo);
|
|
|
|
|
|
SetLevelGroupButtonSelected(Button_Hard, currLevelGroupInfo == _currHardLevelGroupInfo);
|
2024-01-18 16:02:45 +08:00
|
|
|
|
// Image_Plot.gameObject.SetActive(currLevelGroupInfo == _currPlotLevelGroupInfo);
|
|
|
|
|
|
// Image_Easy.gameObject.SetActive(currLevelGroupInfo == _currEasyLevelGroupInfo);
|
|
|
|
|
|
// Image_Hard.gameObject.SetActive(currLevelGroupInfo == _currHardLevelGroupInfo);
|
2024-01-18 18:59:33 +08:00
|
|
|
|
//ReturnAllStarReward();
|
2024-01-09 14:00:53 +08:00
|
|
|
|
if (currLevelGroupInfo.LevelType != LevelType.Plot &&
|
|
|
|
|
|
(currLevelGroupInfo.StarList == null || currLevelGroupInfo.StarList.Length == 0))
|
2024-01-08 19:39:41 +08:00
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"levelGroup的星级奖励列表未配置!levelGroup ID:{currLevelGroupInfo.ID}");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-01-09 14:00:53 +08:00
|
|
|
|
|
2024-01-09 16:54:21 +08:00
|
|
|
|
//播放切换levelGroup动画
|
2024-01-19 14:40:40 +08:00
|
|
|
|
if (oldLevelGroupInfo != null)
|
2024-01-09 16:54:21 +08:00
|
|
|
|
{
|
2024-01-19 14:40:40 +08:00
|
|
|
|
if (oldLevelGroupInfo.LevelType == LevelType.Plot && currLevelGroupInfo.LevelType != LevelType.Plot)
|
|
|
|
|
|
_animation.Play(IN_ANIMATION_NAME);
|
|
|
|
|
|
if (oldLevelGroupInfo.LevelType != LevelType.Plot && currLevelGroupInfo.LevelType == LevelType.Plot)
|
|
|
|
|
|
_animation.Play(OUT_ANIMATION_NAME);
|
2024-01-09 16:54:21 +08:00
|
|
|
|
}
|
2024-01-19 14:40:40 +08:00
|
|
|
|
else
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
2024-01-19 14:40:40 +08:00
|
|
|
|
if (currLevelGroupInfo.LevelType != LevelType.Plot)
|
|
|
|
|
|
{
|
|
|
|
|
|
_animation.Play(IN_ANIMATION_NAME);
|
|
|
|
|
|
var clip = _animation[IN_ANIMATION_NAME];
|
|
|
|
|
|
clip.speed = 0;
|
|
|
|
|
|
clip.time = clip.length;
|
|
|
|
|
|
_animation.Sample();
|
|
|
|
|
|
_animation.Stop(IN_ANIMATION_NAME);
|
|
|
|
|
|
clip.speed = 1;
|
|
|
|
|
|
}
|
2024-01-09 14:00:53 +08:00
|
|
|
|
}
|
2024-01-18 19:12:39 +08:00
|
|
|
|
|
2024-01-19 14:40:40 +08:00
|
|
|
|
|
2024-01-18 18:59:33 +08:00
|
|
|
|
if (currLevelGroupInfo.LevelType != LevelType.Plot)
|
2024-01-09 14:00:53 +08:00
|
|
|
|
{
|
2024-01-18 19:12:39 +08:00
|
|
|
|
//Image_ProcessBG.gameObject.SetActive(true);
|
2024-01-09 14:00:53 +08:00
|
|
|
|
int maxTarget = currLevelGroupInfo.StarList[^1];
|
|
|
|
|
|
var progressLength = _starRewardsParent.rect.width;
|
|
|
|
|
|
var currStarCount = currLevelGroupInfo.StarCount;
|
|
|
|
|
|
var currRewardIndexMax = currLevelGroupInfo.OwnRewardMaxIndex;
|
2024-01-18 17:16:20 +08:00
|
|
|
|
// for (int i = 0; i < currLevelGroupInfo.StarList.Length; i++)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// var target = currLevelGroupInfo.StarList[i];
|
2024-01-18 19:12:39 +08:00
|
|
|
|
//var starReward = await GetAStarReward();
|
|
|
|
|
|
//var button = starReward.GetComponent<Button>();
|
|
|
|
|
|
//button.onClick.RemoveAllListeners();
|
|
|
|
|
|
// var index = i + 1;
|
|
|
|
|
|
// if (_currLevelGroupInfo.CanGetReward(index))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// button.enabled = true;
|
|
|
|
|
|
// button.onClick.AddListener(() => { OnClickStarReward(index); });
|
|
|
|
|
|
// }
|
|
|
|
|
|
// else
|
|
|
|
|
|
// button.enabled = false;
|
|
|
|
|
|
//
|
|
|
|
|
|
// _showStarReward.Add(starReward);
|
|
|
|
|
|
// var targetText = starReward.transform.Find("target_green").GetComponent<TMP_Text>();
|
|
|
|
|
|
// var targetWhiteText = starReward.transform.Find("target_white").GetComponent<TMP_Text>();
|
|
|
|
|
|
// targetText.text = target.ToString();
|
|
|
|
|
|
// targetWhiteText.text = target.ToString();
|
2024-01-18 17:16:20 +08:00
|
|
|
|
// var x = ((float)target / maxTarget) * progressLength;
|
|
|
|
|
|
// var rectTrans = starReward.transform as RectTransform;
|
|
|
|
|
|
// rectTrans.anchoredPosition = new Vector2(x, rectTrans.anchoredPosition.y);
|
|
|
|
|
|
// SetStarRewardEnable(starReward, false);
|
|
|
|
|
|
// }
|
2024-01-09 14:00:53 +08:00
|
|
|
|
|
|
|
|
|
|
var ratio = (float)currStarCount / maxTarget;
|
2024-01-18 17:16:20 +08:00
|
|
|
|
Text_StarNum.text = $"{currStarCount}/{maxTarget}";
|
2024-01-09 14:00:53 +08:00
|
|
|
|
_cts?.Cancel();
|
|
|
|
|
|
_cts?.Dispose();
|
|
|
|
|
|
_cts = new CancellationTokenSource();
|
|
|
|
|
|
PlayProgressAnimation(ratio, progressLength, _cts.Token);
|
2023-10-26 20:20:11 +08:00
|
|
|
|
}
|
2023-10-30 18:33:18 +08:00
|
|
|
|
|
2023-10-26 20:20:11 +08:00
|
|
|
|
Refresh();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-18 19:12:39 +08:00
|
|
|
|
private void SetLevelGroupButtonSelected(Button button, bool isSelected)
|
2024-01-18 18:59:33 +08:00
|
|
|
|
{
|
|
|
|
|
|
var selectedImage = button.transform.Find("selectedImage");
|
|
|
|
|
|
selectedImage.gameObject.SetActive(isSelected);
|
2024-01-18 19:12:39 +08:00
|
|
|
|
|
2024-01-18 18:59:33 +08:00
|
|
|
|
var selectedImage_1 = button.transform.Find("selectedImage_1");
|
|
|
|
|
|
selectedImage_1.gameObject.SetActive(isSelected);
|
2024-01-19 19:20:05 +08:00
|
|
|
|
|
2024-01-19 14:40:40 +08:00
|
|
|
|
var Image_pot = button.transform.Find("Image_pot");
|
|
|
|
|
|
Image_pot.gameObject.SetActive(!isSelected);
|
2024-01-18 18:59:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-10-26 20:20:11 +08:00
|
|
|
|
private void SetStarRewardEnable(GameObject starReward, bool isEnable)
|
|
|
|
|
|
{
|
|
|
|
|
|
var starRewardGreen = starReward.transform.Find("starReward_green").gameObject;
|
|
|
|
|
|
var starReward_white = starReward.transform.Find("starReward_white").gameObject;
|
|
|
|
|
|
var star_green = starReward.transform.Find("star_green").gameObject;
|
|
|
|
|
|
var star_white = starReward.transform.Find("star_white").gameObject;
|
|
|
|
|
|
var target_green = starReward.transform.Find("target_green").gameObject;
|
|
|
|
|
|
var target_white = starReward.transform.Find("target_white").gameObject;
|
|
|
|
|
|
|
|
|
|
|
|
starRewardGreen.SetActive(isEnable);
|
|
|
|
|
|
starReward_white.SetActive(!isEnable);
|
|
|
|
|
|
star_green.SetActive(isEnable);
|
|
|
|
|
|
star_white.SetActive(!isEnable);
|
|
|
|
|
|
target_green.SetActive(isEnable);
|
|
|
|
|
|
target_white.SetActive(!isEnable);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private async void PlayProgressAnimation(float ratio, float progressLength, CancellationToken token)
|
|
|
|
|
|
{
|
2024-01-18 17:16:20 +08:00
|
|
|
|
Image_ProcessBar.fillAmount = 0;
|
|
|
|
|
|
//var currMoveTime = 0f;
|
|
|
|
|
|
//var rewardTList = new List<float>();
|
2024-01-05 19:15:21 +08:00
|
|
|
|
var maxStarCount = _currLevelGroupInfo.StarList[^1];
|
2024-01-18 17:16:20 +08:00
|
|
|
|
// foreach (var starCount in _currLevelGroupInfo.StarList)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// var t = (float)starCount / maxStarCount;
|
|
|
|
|
|
// rewardTList.Add(t);
|
|
|
|
|
|
// }
|
|
|
|
|
|
var targetFillAmount = _currLevelGroupInfo.StarCount / maxStarCount;
|
2024-01-18 19:12:39 +08:00
|
|
|
|
|
2023-10-26 20:20:11 +08:00
|
|
|
|
var currStarIndex = 0;
|
2024-01-18 17:16:20 +08:00
|
|
|
|
while (Image_ProcessBar.fillAmount < targetFillAmount)
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
2024-01-18 17:16:20 +08:00
|
|
|
|
var fillAmount = Image_ProcessBar.fillAmount + Time.deltaTime * _progressmoveSpeed;
|
2024-01-18 19:12:39 +08:00
|
|
|
|
fillAmount = Mathf.Min(fillAmount, targetFillAmount);
|
2024-01-18 17:16:20 +08:00
|
|
|
|
Image_ProcessBar.fillAmount = fillAmount;
|
|
|
|
|
|
// currMoveTime += Time.deltaTime;
|
|
|
|
|
|
// var t = currMoveTime / _progressmoveSpeed;
|
|
|
|
|
|
// var x = Mathf.Min(progressLength * ratio, progressLength * t);
|
|
|
|
|
|
// Image_ProcessBar.rectTransform.anchoredPosition =
|
|
|
|
|
|
// new Vector2(x, Image_ProcessBar.rectTransform.anchoredPosition.y);
|
|
|
|
|
|
// if (t >= rewardTList[0])
|
|
|
|
|
|
// {
|
|
|
|
|
|
// rewardTList.RemoveAt(0);
|
|
|
|
|
|
// SetStarRewardEnable(_showStarReward[currStarIndex], true);
|
|
|
|
|
|
// currStarIndex++;
|
|
|
|
|
|
// }
|
2023-10-26 20:20:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var isCanceled = await UniTask.DelayFrame(1, PlayerLoopTiming.Update, token).SuppressCancellationThrow();
|
|
|
|
|
|
if (isCanceled)
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-18 17:16:20 +08:00
|
|
|
|
// private async UniTask<GameObject> GetAStarReward()
|
|
|
|
|
|
// {
|
|
|
|
|
|
// GameObject result = null;
|
|
|
|
|
|
// if (_starRewardPool.Count > 0)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// result = _starRewardPool[^1];
|
|
|
|
|
|
// _starRewardPool.RemoveAt(_starRewardPool.Count - 1);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// else
|
|
|
|
|
|
// {
|
|
|
|
|
|
// var prefab = await AssetManager.Instance.LoadAssetAsync<GameObject>(STAR_REWARD_PREFAB_PATH);
|
|
|
|
|
|
// if (prefab == null)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// return null;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// GameObject go = Instantiate(prefab, _starRewardsParent.transform);
|
|
|
|
|
|
// result = go;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// result.SetActive(true);
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
// }
|
2023-10-26 20:20:11 +08:00
|
|
|
|
|
2024-01-19 14:00:42 +08:00
|
|
|
|
// private void ReturnAllStarReward()
|
|
|
|
|
|
// {
|
|
|
|
|
|
// foreach (var go in _showStarReward)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// go.SetActive(false);
|
|
|
|
|
|
// _starRewardPool.Add(go);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// _showStarReward.Clear();
|
|
|
|
|
|
// }
|
2023-10-26 20:20:11 +08:00
|
|
|
|
|
|
|
|
|
|
private void ShowLevelDetail()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_currSelectLevelInfo == null)
|
|
|
|
|
|
return;
|
2023-11-22 15:05:43 +08:00
|
|
|
|
if (_currSelectLevelInfo.IsStory)
|
|
|
|
|
|
LevelManager.Instance.TryEnterLevel(_currSelectLevelInfo.ID);
|
|
|
|
|
|
else
|
|
|
|
|
|
UIManager.Instance.OpenWindow(UINameConst.UI_BeforeFight, _currSelectLevelInfo.ID);
|
2023-10-27 16:47:42 +08:00
|
|
|
|
//LevelManager.Instance.TryEnterLevel(_currSelectLevelInfo.ID, CloseSelf);
|
2023-10-26 20:20:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private int GetLevelGroupCount()
|
|
|
|
|
|
{
|
2024-01-05 19:35:51 +08:00
|
|
|
|
return _showChapterInfoList.Count;
|
2023-10-26 20:20:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-18 17:16:20 +08:00
|
|
|
|
private void OnRenderChapter(int index, RectTransform item)
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
2024-01-05 19:35:51 +08:00
|
|
|
|
if (index >= _showChapterInfoList.Count || index < 0)
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"index out of range,index:{index}");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-05 19:35:51 +08:00
|
|
|
|
var levelGroupInfo = _showChapterInfoList[index];
|
2023-10-26 20:20:11 +08:00
|
|
|
|
var Text_ChapterNum = item.Find("Text_ChapterNum").GetComponent<TMP_Text>();
|
|
|
|
|
|
var Text_ChapterName = item.Find("Text_ChapterName").GetComponent<TMP_Text>();
|
|
|
|
|
|
var Image_ProcessBarEasy = item.Find("UI_Easy/Image_ProcessBarEasy").GetComponent<Image>();
|
|
|
|
|
|
var Text_EasyStarNow = item.Find("UI_Easy/Text_EasyStarNow").GetComponent<TMP_Text>();
|
|
|
|
|
|
var Text_EasyStarMax = item.Find("UI_Easy/Text_EasyStarMax").GetComponent<TMP_Text>();
|
|
|
|
|
|
var Image_ProcessBarHard = item.Find("UI_Hard/Image_ProcessBarHard").GetComponent<Image>();
|
|
|
|
|
|
var Text_HardStarNow = item.Find("UI_Hard/Text_HardStarNow").GetComponent<TMP_Text>();
|
|
|
|
|
|
var Text_HardStarMax = item.Find("UI_Hard/Text_HardStarMax").GetComponent<TMP_Text>();
|
|
|
|
|
|
|
2024-01-09 14:00:53 +08:00
|
|
|
|
Text_ChapterNum.text = string.Format("{0:D2}", index + 1);
|
2023-10-26 20:20:11 +08:00
|
|
|
|
Text_ChapterName.text = levelGroupInfo.Name;
|
|
|
|
|
|
|
2024-01-05 19:35:51 +08:00
|
|
|
|
var starCountEasy = levelGroupInfo.EasyLevelGroup?.StarCount ?? 0;
|
|
|
|
|
|
var starMaxEasy = levelGroupInfo.EasyLevelGroup?.StarMax ?? 0;
|
2023-10-26 20:20:11 +08:00
|
|
|
|
Image_ProcessBarEasy.fillAmount = (float)starCountEasy / starMaxEasy;
|
|
|
|
|
|
Text_EasyStarNow.text = starCountEasy.ToString();
|
|
|
|
|
|
Text_EasyStarMax.text = starMaxEasy.ToString();
|
|
|
|
|
|
|
2024-01-05 19:35:51 +08:00
|
|
|
|
var starCountHard = levelGroupInfo.HardLevelGroup?.StarCount ?? 0;
|
|
|
|
|
|
var starMaxHard = levelGroupInfo.HardLevelGroup?.StarMax ?? 0;
|
2023-10-26 20:20:11 +08:00
|
|
|
|
Image_ProcessBarHard.fillAmount = (float)starCountHard / starMaxHard;
|
|
|
|
|
|
Text_HardStarNow.text = starCountHard.ToString();
|
|
|
|
|
|
Text_HardStarMax.text = starMaxHard.ToString();
|
2023-11-02 20:02:10 +08:00
|
|
|
|
|
|
|
|
|
|
var UI_RedPoint = item.Find("UI_RedPoint").GetComponent<RedPointUIController>();
|
|
|
|
|
|
if (UI_RedPoint != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UI_RedPoint.NodeID = levelGroupInfo.RedPointNode.ID;
|
|
|
|
|
|
}
|
2023-10-26 20:20:11 +08:00
|
|
|
|
|
2024-01-04 13:51:08 +08:00
|
|
|
|
var btn = item.GetComponent<Button>();
|
|
|
|
|
|
btn.onClick.RemoveAllListeners();
|
2024-01-18 19:12:39 +08:00
|
|
|
|
btn.onClick.AddListener(() => { EnterSelectLevel(levelGroupInfo); });
|
2024-01-04 13:51:08 +08:00
|
|
|
|
//BindButton(item.gameObject,)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// private void SetOnLevelGroupClick(GameObject obj)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// BindButton(obj, () =>
|
|
|
|
|
|
// {
|
|
|
|
|
|
// var index = CommonUtils.GetTransformIndex(obj.transform);
|
|
|
|
|
|
// if (index >= _showLevelGroupInfoList.Count || index < 0)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// DebugUtil.LogError($"index out of range,index:{index}");
|
|
|
|
|
|
// return;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// var selectedLevelGroup = _showLevelGroupInfoList[index];
|
|
|
|
|
|
// EnterSelectLevel(selectedLevelGroup);
|
|
|
|
|
|
// Refresh();
|
|
|
|
|
|
// });
|
|
|
|
|
|
// }
|
2023-10-26 20:20:11 +08:00
|
|
|
|
|
|
|
|
|
|
private int GetLevelCount()
|
|
|
|
|
|
{
|
|
|
|
|
|
return _showLevelInfoList.Count;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private async void OnRenderLevelInfo(int index, RectTransform item)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (index < 0 || index >= _showLevelInfoList.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("index out of range,index:{0}", index);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var levelInfo = _showLevelInfoList[index];
|
|
|
|
|
|
var Text_LevelNum = item.Find("Text_LevelNum").GetComponent<TMP_Text>();
|
|
|
|
|
|
var Text_LevelName = item.Find("Text_LevelName").GetComponent<TMP_Text>();
|
2024-01-18 16:02:45 +08:00
|
|
|
|
var Image_Star01 = item.Find("Target/Text_01/Image_Yellow").gameObject;
|
|
|
|
|
|
var Image_Star02 = item.Find("Target/Text_02/Image_Yellow").gameObject;
|
|
|
|
|
|
var Image_Star03 = item.Find("Target/Text_03/Image_Yellow").gameObject;
|
|
|
|
|
|
var Image_environment = item.Find("MapDetail/Image_environment").GetComponent<Image>();
|
|
|
|
|
|
var Image_weather = item.Find("MapDetail/Image_weather").GetComponent<Image>();
|
|
|
|
|
|
var Image_daynight = item.Find("MapDetail/Image_DayOrNight").GetComponent<Image>();
|
|
|
|
|
|
|
2024-01-19 14:00:42 +08:00
|
|
|
|
Text_LevelNum.text = GetLevelLabel(levelInfo);
|
2023-10-26 20:20:11 +08:00
|
|
|
|
Text_LevelName.text = levelInfo.Name;
|
|
|
|
|
|
var starCount = levelInfo.StarCount;
|
|
|
|
|
|
Image_Star01.SetActive(starCount >= 1);
|
|
|
|
|
|
Image_Star02.SetActive(starCount >= 2);
|
|
|
|
|
|
Image_Star03.SetActive(starCount >= 3);
|
|
|
|
|
|
Image_environment.sprite = await CommonUtils.GetEnvironmentIcon(levelInfo.EnvironmentType);
|
|
|
|
|
|
Image_weather.sprite = await CommonUtils.GetWeatherIcon(levelInfo.WeatherType);
|
|
|
|
|
|
Image_daynight.sprite = await CommonUtils.GetDayNightIcon(levelInfo.DayNightType);
|
2023-11-02 20:02:10 +08:00
|
|
|
|
|
|
|
|
|
|
var UI_RedPoint = item.Find("UI_RedPoint").GetComponent<RedPointUIController>();
|
|
|
|
|
|
if (UI_RedPoint != null)
|
|
|
|
|
|
UI_RedPoint.NodeID = levelInfo.RedPointNode.ID;
|
2023-10-26 20:20:11 +08:00
|
|
|
|
|
2024-01-04 13:51:08 +08:00
|
|
|
|
var btn = item.GetComponent<Button>();
|
|
|
|
|
|
btn.onClick.RemoveAllListeners();
|
|
|
|
|
|
btn.onClick.AddListener(() =>
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
2024-01-04 13:51:08 +08:00
|
|
|
|
_currSelectLevelInfo = levelInfo;
|
|
|
|
|
|
ShowLevelDetail();
|
2023-10-26 20:20:11 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-19 14:40:40 +08:00
|
|
|
|
private string GetLevelLabel(LevelInfo levelInfo) =>
|
|
|
|
|
|
$"{levelInfo.ChapterInfo.SortIndex + 1:00}-{levelInfo.SortIndex + 1:00}";
|
|
|
|
|
|
|
2024-01-04 13:51:08 +08:00
|
|
|
|
// private void SetOnLevelClick(GameObject go)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// BindButton(go, () =>
|
|
|
|
|
|
// {
|
|
|
|
|
|
// var index = CommonUtils.GetTransformIndex(go.transform);
|
|
|
|
|
|
// if (index >= _showLevelInfoList.Count || index < 0)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// DebugUtil.LogError("index out of range!,{0}", index);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// var levelInfo = _showLevelInfoList[index];
|
|
|
|
|
|
// if (levelInfo != null)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// _currSelectLevelInfo = levelInfo;
|
|
|
|
|
|
// ShowLevelDetail();
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
2023-10-26 20:20:11 +08:00
|
|
|
|
#region Event
|
|
|
|
|
|
|
|
|
|
|
|
private void OnClickBack()
|
|
|
|
|
|
{
|
2023-10-27 12:07:33 +08:00
|
|
|
|
switch (_currPage)
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
2023-10-27 12:07:33 +08:00
|
|
|
|
case PageType.Mode:
|
2024-01-17 16:49:32 +08:00
|
|
|
|
CloseWindow();
|
2023-10-27 12:07:33 +08:00
|
|
|
|
break;
|
2024-01-05 19:35:51 +08:00
|
|
|
|
case PageType.Chapter:
|
2023-10-27 12:07:33 +08:00
|
|
|
|
ExitSelectLevelGroup();
|
|
|
|
|
|
break;
|
|
|
|
|
|
case PageType.Level:
|
|
|
|
|
|
ExitSelectLevel();
|
|
|
|
|
|
break;
|
2023-10-26 20:20:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnClickHome()
|
2024-01-03 17:25:13 +08:00
|
|
|
|
{
|
2023-11-24 19:23:15 +08:00
|
|
|
|
CloseWindow(UIWindowCloseType.HideAndDestroy);
|
|
|
|
|
|
//UIManager.Instance.CloseAllNormalExcept(UINameConst.UI_MainPanel);
|
2023-10-26 20:20:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnClickEasy()
|
|
|
|
|
|
{
|
2024-01-05 19:15:21 +08:00
|
|
|
|
if (_currEasyLevelGroupInfo != null)
|
2024-01-08 19:52:51 +08:00
|
|
|
|
ChangeLevelGroup(_currEasyLevelGroupInfo);
|
2023-10-26 20:20:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnClickHard()
|
|
|
|
|
|
{
|
2024-01-05 19:15:21 +08:00
|
|
|
|
if (_currHardLevelGroupInfo != null)
|
2024-01-08 19:52:51 +08:00
|
|
|
|
ChangeLevelGroup(_currHardLevelGroupInfo);
|
2023-10-26 20:20:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnClickPlot()
|
|
|
|
|
|
{
|
2024-01-05 19:15:21 +08:00
|
|
|
|
if (_currPlotLevelGroupInfo != null)
|
2024-01-08 19:52:51 +08:00
|
|
|
|
ChangeLevelGroup(_currPlotLevelGroupInfo);
|
2023-10-26 20:20:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-18 17:16:20 +08:00
|
|
|
|
private void OnClickStarReward()
|
2023-10-27 18:23:18 +08:00
|
|
|
|
{
|
2024-01-18 17:16:20 +08:00
|
|
|
|
var index = _currLevelGroupInfo.OwnRewardMaxIndex + 1;
|
2024-01-18 19:12:39 +08:00
|
|
|
|
if (_currLevelGroupInfo.CanGetReward(index))
|
2024-01-18 17:16:20 +08:00
|
|
|
|
LevelManager.Instance.GetStarReward(_currLevelGroupInfo.ID, index);
|
2023-10-30 18:33:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-10-26 20:20:11 +08:00
|
|
|
|
#endregion Event
|
|
|
|
|
|
|
|
|
|
|
|
#region override method
|
|
|
|
|
|
|
2024-01-24 16:32:38 +08:00
|
|
|
|
protected override void OnShowWindow(object data = null)
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
|
|
|
|
|
Refresh();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//invoke when open window
|
2024-01-23 12:25:47 +08:00
|
|
|
|
// protected override void OnOpenWindow(object data = null)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// Refresh();
|
|
|
|
|
|
// }
|
2023-10-26 20:20:11 +08:00
|
|
|
|
|
|
|
|
|
|
//invoke when reload window
|
|
|
|
|
|
protected override void OnReloadWindow(object data = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Refresh();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//invoke when close window
|
2024-01-24 16:32:38 +08:00
|
|
|
|
protected override void OnHideWindow()
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
2024-01-25 17:52:04 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnRelease()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnRelease();
|
2024-01-17 16:49:32 +08:00
|
|
|
|
CommonUtils.CloseUIWithScene(WindowName);
|
2023-10-26 20:20:11 +08:00
|
|
|
|
UnRegisterSignal();
|
|
|
|
|
|
_currPage = PageType.Mode;
|
2023-10-27 12:36:01 +08:00
|
|
|
|
_cts?.Cancel();
|
|
|
|
|
|
_cts?.Dispose();
|
2023-10-26 20:20:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
2024-01-18 19:12:39 +08:00
|
|
|
|
}
|