NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/UI_LevelSelectController.cs

1300 lines
42 KiB
C#
Raw Normal View History

2024-04-07 16:22:58 +08:00
using System;
2024-01-09 14:00:53 +08:00
using System.Collections.Generic;
2024-01-26 17:14:03 +08:00
using System.Linq;
2023-10-26 20:20:11 +08:00
using System.Threading;
2024-04-12 20:19:13 +08:00
using cfg.FightCfg;
2023-10-26 20:20:11 +08:00
using cfg.LevelCfg;
using Cysharp.Threading.Tasks;
2023-10-30 18:33:18 +08:00
using Framework;
using Gameplay;
2024-04-08 15:09:59 +08:00
using Gameplay.Common;
2023-10-26 20:20:11 +08:00
using Gameplay.Level;
using Gameplay.Net;
2023-10-26 20:20:11 +08:00
using PhxhSDK;
2023-10-24 14:58:21 +08:00
using TMPro;
using UnityEngine;
2024-04-07 16:22:58 +08:00
using UnityEngine.UI;
2023-10-24 14:58:21 +08:00
using Button = UnityEngine.UI.Button;
using Constants = Framework.Constants;
2023-10-24 14:58:21 +08:00
using Image = UnityEngine.UI.Image;
public class UI_LevelSelectController : UIWindow
{
2024-01-18 19:12:39 +08:00
public TMP_Text Text_ChapterName;
public TMP_Text Text_ChapterNum;
public Image Image_ProcessBar;
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 Button Button_Easy;
public Button Button_Hard;
2024-01-19 19:20:05 +08:00
2024-04-07 16:22:58 +08:00
/// <summary>
/// 打开关卡选择界面
/// </summary>
/// <param name="levelInfo">有数据则跳转到对应关卡选项,没有数据则显示默认</param>
2024-04-07 16:22:58 +08:00
/// <returns></returns>
public static async UniTask<UIWindow> Open(LevelInfo levelInfo = null)
{
2024-04-29 15:36:17 +08:00
// 切换场景会有瞬间卡顿先打开UI
2024-05-24 13:32:09 +08:00
UIWindow uiWindow = await UIManager.Instance.CreateAndOpenWindow(UINameConst.UI_LevelSelect, levelInfo);
2024-04-29 15:36:17 +08:00
2024-04-07 16:22:58 +08:00
CommonUtils.ChangeUIScene(Constants.UI_LEVEL_SELECTED_SCENE_PATH); // 切换到关卡选择场景
2024-05-24 14:21:11 +08:00
CameraManager.Instance.SetMainCameraActive(true);
2024-04-29 15:36:17 +08:00
return uiWindow;
}
2024-04-07 16:22:58 +08:00
#region 类
2024-04-02 16:44:23 +08:00
/// <summary>
/// 电池
/// </summary>
private class Batterie : UIGameObjectWrapper
{
/// <summary>
/// 电池电量
/// </summary>
private readonly List<GameObject> listBatteryPower;
public Batterie(GameObject root) : base(root)
{
listBatteryPower = new(GoRoot.transform.childCount);
for (int i = 0; i < GoRoot.transform.childCount; ++i)
{
listBatteryPower.Add(GoRoot.transform.GetChild(i).gameObject);
}
}
/// <summary>
/// 入口
/// </summary>
/// <param name="batteryPower"></param>
public void SetInfo(float batteryPower)
{
int showCount = Mathf.CeilToInt(listBatteryPower.Count * batteryPower);
for (int i = 0; i < listBatteryPower.Count; ++i)
{
2024-04-02 18:48:02 +08:00
listBatteryPower[i].IsScaleShow(i + 1 == showCount);
2024-04-02 16:44:23 +08:00
}
}
}
/// <summary>
/// WIFI
/// </summary>
2024-04-02 18:48:02 +08:00
private class NetSignal : UIGameObjectWrapper
2024-04-02 16:44:23 +08:00
{
2024-07-10 17:36:22 +08:00
int[] SignalThreshold = new int[] { 30, 60, 120, 200, 300 };//网络延迟阶梯值
2024-04-02 16:44:23 +08:00
/// <summary>
/// Wifi信号
/// </summary>
private readonly List<GameObject> listWifi;
2024-04-02 18:48:02 +08:00
public NetSignal(GameObject root) : base(root)
2024-04-02 16:44:23 +08:00
{
listWifi = new(GoRoot.transform.childCount);
for (int i = 0; i < GoRoot.transform.childCount; ++i)
{
listWifi.Add(GoRoot.transform.GetChild(i).gameObject);
}
}
/// <summary>
/// 入口
/// </summary>
/// <param name="networkSignal"></param>
public void SetInfo(float networkSignal)
{
int showCount = Mathf.CeilToInt(listWifi.Count * networkSignal);
for (int i = 0; i < listWifi.Count; ++i)
{
2024-04-02 18:48:02 +08:00
listWifi[i].IsScaleShow(i + 1 == showCount);
2024-04-02 16:44:23 +08:00
}
}
public void SetInfo()
{
var rtt = NetManager.Instance.RTT;//rtt 毫秒
int showCnt = 0;
for (int i = 0; i < SignalThreshold.Length; i++)
{
if (rtt < SignalThreshold[i])
{
showCnt = SignalThreshold.Length - i;
break;
}
}
for (int i = 0; i < listWifi.Count; ++i)
{
listWifi[i].IsScaleShow(showCnt > 0);
--showCnt;
}
IsScaleShow = true;
}
2024-04-02 16:44:23 +08:00
}
2024-04-07 16:22:58 +08:00
/// <summary>
/// 选择面板基类
/// </summary>
private abstract class BaseChoosePanel : UIGameObjectWrapper
2023-10-26 20:20:11 +08:00
{
2024-04-07 16:22:58 +08:00
protected ScrollRect scrollRect;
/// <summary>
/// 章节类型
/// </summary>
private LevelChapterType chapterType;
/// <summary>
/// 章节信息
/// </summary>
private LevelGroupInfo levelGroupInfo;
public LevelChapterType ChapterType
{
get { return chapterType; }
set { chapterType = value; }
}
public LevelGroupInfo ChapterInfo
{
get { return levelGroupInfo; }
set { levelGroupInfo = value; }
}
public new bool IsScaleShow
{
get
{
if (GoRoot.transform.localScale.x == 0f)
return false;
if (GoRoot.transform.localScale.y == 0f)
return false;
return true;
}
set
{
GoRoot.IsScaleShow(value);
if (scrollRect == null)
return;
scrollRect.enabled = value;
}
}
public BaseChoosePanel(GameObject root) : base(root)
{
}
public abstract void SetInfo();
2023-10-26 20:20:11 +08:00
}
2024-04-07 16:22:58 +08:00
/// <summary>
/// 模式选择面板
/// </summary>
private class ModeChoosePanel : BaseChoosePanel
{
/// <summary>
/// 模式选项
/// </summary>
private class ModeItem : UIGameObjectWrapper
{
#region UI
/// <summary>
/// 模式名
/// </summary>
private TMP_Text textModeName;
/// <summary>
/// 当前关卡名
/// </summary>
private TMP_Text textCurLevelName;
/// <summary>
/// 当前关卡编号
/// </summary>
private TMP_Text textCurLevelNum;
/// <summary>
/// 上一次关卡名
/// </summary>
private TMP_Text textLastLevelName;
/// <summary>
/// 上一次关卡编号
/// </summary>
private TMP_Text textLastLevelNum;
/// <summary>
/// 当前关卡
/// </summary>
private GameObject goCurLevel;
/// <summary>
/// 上一次关卡
/// </summary>
private GameObject goLastLevel;
/// <summary>
/// 选择章节按钮
/// </summary>
private Button buttonSelectChapter;
/// <summary>
/// 进入当前关卡按钮
/// </summary>
private Button buttonCurLevel;
/// <summary>
/// 进入上一次关卡按钮
/// </summary>
private Button buttonLastLevel;
#endregion
/// <summary>
/// 关卡章节类型
/// </summary>
private readonly LevelChapterType type;
/// <summary>
/// 点击模式
/// </summary>
private readonly Action<LevelChapterType> mode;
/// <summary>
/// 点击关卡
/// </summary>
private readonly Action<LevelInfo> level;
private LevelInfo curLevelInfo;
private LevelInfo lastLevelInfo;
public ModeItem(GameObject root, LevelChapterType levelChapterType, Action<LevelChapterType> modeAction, Action<LevelInfo> levelAction) : base(root)
{
type = levelChapterType;
mode = modeAction;
level = levelAction;
buttonSelectChapter = GoRoot.GetComponent<Button>();
buttonCurLevel = GetComponent<Button>("Image_TextBG/ButtonCurLevel");
buttonLastLevel = GetComponent<Button>("Image_TextBG/ButtonLastLevel");
textModeName = GetComponent<TMP_Text>("Image_TextBG/Text_MainLevel");
textCurLevelName = GetComponent<TMP_Text>("Image_TextBG/Image_BlackBar/Text_MainLevelName");
textCurLevelNum = GetComponent<TMP_Text>("Image_TextBG/Image_BlackBar/Text_MainLevelNum");
textLastLevelName = GetComponent<TMP_Text>("Image_TextBG/Image_LastRect/Text_MainLevelName");
textLastLevelNum = GetComponent<TMP_Text>("Image_TextBG/Image_LastRect/Text_MainLevelNum");
goCurLevel = FindObj("Image_TextBG/Image_BlackBar");
goLastLevel = FindObj("Image_TextBG/Image_LastRect");
buttonSelectChapter.onClick.AddListener(OnSelectMode);
buttonCurLevel.onClick.AddListener(OnSelectCurLevel);
buttonLastLevel.onClick.AddListener(OnSelectLastLevel);
}
public void SetInfo()
{
textModeName.text = type switch
{
LevelChapterType.Main => CommonUtils.GetLocalizeText("LevelSelect_MainLevel"),
2024-05-06 16:46:00 +08:00
LevelChapterType.Resource => CommonUtils.GetLocalizeText("LevelSelect_ResoureLevel"),
LevelChapterType.Storyline => CommonUtils.GetLocalizeText("LevelSelect_StorylineLevel"),
_ => throw new Exception("未处理类型"),
2024-04-07 16:22:58 +08:00
};
curLevelInfo = LevelManager.Instance.GetLatestLevelInfo(type);
if (curLevelInfo == null)
goCurLevel.IsScaleShow(false);
else
{
2024-05-06 16:46:00 +08:00
textCurLevelNum.text = $"{curLevelInfo.ChapterIndex:00}-{curLevelInfo.LevelIndex:00}";
2024-04-07 16:22:58 +08:00
textCurLevelName.text = curLevelInfo.Name;
goCurLevel.IsScaleShow(true);
}
lastLevelInfo = LevelManager.Instance.GetLastFightLevelInfo(type);
if (lastLevelInfo == null)
goLastLevel.IsScaleShow(false);
else
{
2024-05-06 16:46:00 +08:00
textLastLevelNum.text = $"{lastLevelInfo.ChapterIndex:00}-{lastLevelInfo.LevelIndex:00}";
2024-04-07 16:22:58 +08:00
textLastLevelName.text = lastLevelInfo.Name;
goLastLevel.IsScaleShow(true);
}
IsScaleShow = true;
}
/// <summary>
/// 选择模式
/// </summary>
private void OnSelectMode()
{
mode?.Invoke(type);
}
/// <summary>
/// 选择当前关卡
/// </summary>
private void OnSelectCurLevel()
{
if (curLevelInfo == null)
return;
level?.Invoke(curLevelInfo);
}
/// <summary>
/// 选择上一次关卡
/// </summary>
private void OnSelectLastLevel()
{
if (lastLevelInfo == null)
return;
level?.Invoke(lastLevelInfo);
}
}
/// <summary>
/// 选项列表
/// </summary>
private readonly List<ModeItem> listModeItem = new();
public ModeChoosePanel(GameObject root, Action<LevelChapterType> callbackAction, Action<LevelInfo> levelAction) : base(root)
{
scrollRect = GetComponent<ScrollRect>("Scroll View");
listModeItem.Add(new ModeItem(FindObj("Scroll View/Viewport/Content/Button_MainLevel"), LevelChapterType.Main, callbackAction, levelAction));
2024-05-06 16:46:00 +08:00
listModeItem.Add(new ModeItem(FindObj("Scroll View/Viewport/Content/Button_ResourceLevel"), LevelChapterType.Resource, callbackAction, levelAction));
listModeItem.Add(new ModeItem(FindObj("Scroll View/Viewport/Content/Button_StorylineLevel"), LevelChapterType.Storyline, callbackAction, levelAction));
2024-01-09 16:54:21 +08:00
2024-04-07 16:22:58 +08:00
IsScaleShow = false;
}
public override void SetInfo()
{
foreach (ModeItem modeItem in listModeItem)
{
modeItem.SetInfo();
}
IsScaleShow = true;
}
}
2023-10-26 20:20:11 +08:00
2024-04-02 19:50:36 +08:00
/// <summary>
2024-04-07 16:22:58 +08:00
/// 关卡类型选择面板
2024-04-02 19:50:36 +08:00
/// </summary>
2024-04-07 16:22:58 +08:00
private class ChapterChoosePanel : BaseChoosePanel
{
/// <summary>
/// 章节项
/// </summary>
private class ChapterItem : UIGameObjectWrapper
{
#region UI
/// <summary>
/// 章节编号
/// </summary>
private TMP_Text textChapterNum;
/// <summary>
/// 章节名
/// </summary>
private TMP_Text textChapterName;
/// <summary>
/// 当前简单星星数量
/// </summary>
private TMP_Text textEasyStarNow;
/// <summary>
/// 简单星星最大数量
/// </summary>
private TMP_Text textEasyStarMax;
/// <summary>
/// 当前困难星星数量
/// </summary>
private TMP_Text textHardStarNow;
/// <summary>
/// 困难星星最大数量
/// </summary>
private TMP_Text textHardStarMax;
/// <summary>
/// 简单进度条
/// </summary>
private Image imageProcessBarEasy;
/// <summary>
/// 困难进度条
/// </summary>
private Image imageProcessBarHard;
private RedPointUIController redPointUIController;
private Button button;
2024-06-24 16:41:25 +08:00
private GameObject goHard;
2024-04-07 16:22:58 +08:00
#endregion
private readonly Action<ChapterInfo> callback;
private ChapterInfo info;
public ChapterItem(GameObject root, Action<ChapterInfo> callbackAction) : base(root)
{
callback = callbackAction;
textChapterNum = GetComponent<TMP_Text>("Text_ChapterNum");
textChapterName = GetComponent<TMP_Text>("Text_ChapterName");
textEasyStarNow = GetComponent<TMP_Text>("UI_Easy/Text_EasyStarNow");
textEasyStarMax= GetComponent<TMP_Text>("UI_Easy/Text_EasyStarMax");
textHardStarNow = GetComponent<TMP_Text>("UI_Hard/Text_HardStarNow");
textHardStarMax = GetComponent<TMP_Text>("UI_Hard/Text_HardStarMax");
imageProcessBarEasy = GetComponent<Image>("UI_Easy/Image_ProcessBarEasy");
imageProcessBarHard = GetComponent<Image>("UI_Hard/Image_ProcessBarHard");
redPointUIController = GetComponent<RedPointUIController>("UI_RedPoint");
2024-06-24 16:41:25 +08:00
goHard = FindObj("UI_Hard");
2024-04-07 16:22:58 +08:00
button = GoRoot.GetComponent<Button>();
button.onClick.AddListener(OnClick);
}
public void SetInfo(int index, ChapterInfo chapterInfo)
{
info = chapterInfo;
2024-05-31 17:19:28 +08:00
textChapterNum.text = $"{index:D2}";
textChapterName.text = info.Name;
2024-04-07 16:22:58 +08:00
int starCountEasy = info.EasyLevelGroup?.StarCount ?? 0;
2024-05-06 16:46:00 +08:00
int starMaxEasy = info.EasyLevelGroup?.StarMax ?? 1;
2024-04-07 16:22:58 +08:00
imageProcessBarEasy.fillAmount = (float)starCountEasy / starMaxEasy;
textEasyStarNow.text = starCountEasy.ToString();
textEasyStarMax.text = starMaxEasy.ToString();
2024-06-24 16:41:25 +08:00
if (null == info.HardLevelGroup)
goHard.IsScaleShow(false);
else
{
int starCountHard = info.HardLevelGroup.StarCount;
int starMaxHard = info.HardLevelGroup.StarMax;
imageProcessBarHard.fillAmount = (float)starCountHard / starMaxHard;
textHardStarNow.text = starCountHard.ToString();
textHardStarMax.text = starMaxHard.ToString();
goHard.IsScaleShow(true);
}
2024-04-07 16:22:58 +08:00
if (redPointUIController != null)
redPointUIController.NodeID = info.RedPointNode.ID;
IsScaleShow = true;
}
private void OnClick()
{
callback?.Invoke(info);
}
}
/// <summary>
/// 列表箭头
/// </summary>
private GameObject goArrow;
/// <summary>
/// 循环列表
/// </summary>
private RecycleView recycleView;
/// <summary>
/// 章节字典
/// </summary>
private readonly Dictionary<int, ChapterItem> dicChapterItem = new();
private readonly Action<ChapterInfo> callback;
/// <summary>
/// 章节信息
/// </summary>
private List<ChapterInfo> listShowChapterInfo;
public ChapterChoosePanel(GameObject root, Action<ChapterInfo> callbackAction) : base(root)
{
callback = callbackAction;
goArrow = FindObj("Image_ChapterBG/Triangle");
recycleView = GetComponent<RecycleView>("Image_ChapterBG/RecyScrollView");
scrollRect = recycleView.ScrollRect;
recycleView.Init(OnRefreshItem);
recycleView.ScrollRect.onValueChanged.AddListener(OnRefreshArrow);
IsScaleShow = false;
}
public override void SetInfo()
{
LevelManager.Instance.GetChapterInfosByType(ChapterType, ref listShowChapterInfo);
listShowChapterInfo.Sort((a, b) => { return a.ID.CompareTo(b.ID); });
recycleView.ShowList(listShowChapterInfo.Count);
OnRefreshArrow(Vector2.one);
IsScaleShow = true;
}
/// <summary>
/// 刷新列表项
/// </summary>
/// <param name="cell"></param>
/// <param name="index"></param>
private void OnRefreshItem(GameObject cell, int index)
{
if (!dicChapterItem.TryGetValue(cell.GetInstanceID(), out ChapterItem item))
{
item = new ChapterItem(cell, callback);
dicChapterItem.Add(cell.GetInstanceID(), item);
}
if (index < 0 || index >= listShowChapterInfo.Count)
{
DebugUtil.LogError("索引错误");
return;
}
item.SetInfo(index, listShowChapterInfo[index]);
}
/// <summary>
/// 刷新列表箭头
/// </summary>
/// <param name="vector2"></param>
private void OnRefreshArrow(Vector2 vector2)
{
if (recycleView.IsShowOnePage)
goArrow.IsScaleShow(false);
else
goArrow.IsScaleShow(vector2.y > 0f);
}
}
2024-04-02 19:50:36 +08:00
/// <summary>
2024-04-07 16:22:58 +08:00
/// 关卡选择面板
2024-04-02 19:50:36 +08:00
/// </summary>
2024-04-07 16:22:58 +08:00
private class LevelChoosePanel : BaseChoosePanel
{
private class LevelItem : UIGameObjectWrapper
{
#region UI
/// <summary>
/// 关卡编号
/// </summary>
private TMP_Text textLevelNum;
/// <summary>
/// 关卡名
/// </summary>
private TMP_Text Text_LevelName;
2024-04-12 20:19:13 +08:00
private TMP_Text textDayOrNight;
private TMP_Text textWeatherAndLand01;
private TMP_Text textweatherAndLand02;
2024-04-07 16:22:58 +08:00
private GameObject goStar1;
private GameObject goStar2;
private GameObject goStar3;
private GameObject goMapDetail;
private GameObject goTarget;
private Image imageEnvironment;
private Image imageWeather;
private Image imageDaynight;
private RedPointUIController redPointUIController;
private Button button;
#endregion
private readonly Action<LevelInfo> callback;
private LevelInfo info;
public LevelItem(GameObject root, Action<LevelInfo> callbackAction) : base(root)
{
callback = callbackAction;
textLevelNum = GetComponent<TMP_Text>("Text_LevelNum");
Text_LevelName = GetComponent<TMP_Text>("Text_LevelName");
2024-04-12 20:19:13 +08:00
textDayOrNight = GetComponent<TMP_Text>("MapDetail/Image_DayOrNight/Text_DayOrNight");
textWeatherAndLand01 = GetComponent<TMP_Text>("MapDetail/Image_weather/Text_WeatherAndLand01");
textweatherAndLand02 = GetComponent<TMP_Text>("MapDetail/Image_environment/Text_WeatherAndLand02");
2024-04-07 16:22:58 +08:00
goStar1 = FindObj("Target/Text_01/Image_Yellow");
goStar2 = FindObj("Target/Text_02/Image_Yellow");
goStar3 = FindObj("Target/Text_03/Image_Yellow");
goMapDetail = FindObj("MapDetail");
goTarget = FindObj("Target");
imageEnvironment = GetComponent<Image>("MapDetail/Image_environment");
imageWeather = GetComponent<Image>("MapDetail/Image_weather");
imageDaynight = GetComponent<Image>("MapDetail/Image_DayOrNight");
redPointUIController = GetComponent<RedPointUIController>("UI_RedPoint");
button = GoRoot.GetComponent<Button>();
button.onClick.AddListener(OnClick);
}
2024-05-24 14:21:11 +08:00
public async void SetInfo(LevelInfo levelInfo)
2024-04-07 16:22:58 +08:00
{
info = levelInfo;
2024-05-06 16:46:00 +08:00
textLevelNum.text = $"{info.ChapterIndex:00}-{info.LevelIndex:00}";
2024-04-07 16:22:58 +08:00
Text_LevelName.text = info.Name;
if (info.IsStory)
{
goMapDetail.IsScaleShow(false);
goTarget.IsScaleShow(false);
}
else
{
bool[] StarResult = info.StarResult;
goStar1.IsScaleShow(StarResult[0]);
goStar2.IsScaleShow(StarResult[1]);
goStar3.IsScaleShow(StarResult[2]);
2024-04-12 20:19:13 +08:00
2024-05-24 14:21:11 +08:00
await AssetManager.Instance.WaitAllPreloads();
2024-04-12 20:19:13 +08:00
DataEnviorment environmentConfig = CommonUtils.GetEnvironmentConfig(levelInfo.EnvironmentType);
imageEnvironment.sprite = AssetManager.Instance.GetPreLoadResult<Sprite>(environmentConfig.Icon);
textweatherAndLand02.text = CommonUtils.GetLocalizeText(environmentConfig.NameLocal);
DataEnWeather weatherConfig = CommonUtils.GetWeatherConfig(levelInfo.WeatherType);
imageWeather.sprite = AssetManager.Instance.GetPreLoadResult<Sprite>(weatherConfig.Icon);
textWeatherAndLand01.text = CommonUtils.GetLocalizeText(weatherConfig.NameLocal);
DataDayNightProp dayNightConfig = CommonUtils.GetDayNightConfig(levelInfo.DayNightType);
imageDaynight.sprite = AssetManager.Instance.GetPreLoadResult<Sprite>(dayNightConfig.Icon);
textDayOrNight.text = CommonUtils.GetLocalizeText(dayNightConfig.NameLocal);
2024-04-07 16:22:58 +08:00
goMapDetail.IsScaleShow(true);
goTarget.IsScaleShow(true);
}
if (redPointUIController != null)
redPointUIController.NodeID = info.RedPointNode.ID;
IsScaleShow = true;
}
private void OnClick()
{
callback?.Invoke(info);
}
}
/// <summary>
/// 列表箭头
/// </summary>
private GameObject goArrow;
/// <summary>
/// 循环列表
/// </summary>
private RecycleView recycleView;
2024-05-06 16:46:00 +08:00
/// <summary>
/// 关卡进度
/// </summary>
private GameObject goProcess;
/// <summary>
/// 关卡模式
/// </summary>
private GameObject goMode;
2024-04-07 16:22:58 +08:00
/// <summary>
/// 关卡信息列表
/// </summary>
private readonly List<LevelInfo> listLevelInfo = new();
/// <summary>
/// 关卡字典
/// </summary>
private readonly Dictionary<int, LevelItem> dicLevelItem = new();
private readonly Action<LevelInfo> callback;
2024-05-06 16:46:00 +08:00
public bool IsShowMode
{
set
{
goProcess.IsScaleShow(value);
goMode.IsScaleShow(value);
}
}
2024-04-07 16:22:58 +08:00
public LevelChoosePanel(GameObject root, Action<LevelInfo> callbackAction) : base(root)
{
callback = callbackAction;
goArrow = FindObj("Triangle");
2024-05-06 16:46:00 +08:00
goProcess = FindObj("Image_ProcessBG");
goMode = FindObj("Image_ModeBG");
2024-04-07 16:22:58 +08:00
recycleView = GetComponent<RecycleView>("Image_LevelBG/Scroll View");
scrollRect = recycleView.ScrollRect;
recycleView.Init(OnRefreshItem);
recycleView.ScrollRect.onValueChanged.AddListener(OnRefreshArrow);
IsScaleShow = false;
}
public override void SetInfo()
{
listLevelInfo.Clear();
foreach (LevelInfo levelInfo in ChapterInfo)
{
if (!levelInfo.IsLock)
listLevelInfo.Add(levelInfo);
}
listLevelInfo.Sort((a, b) => a.ID.CompareTo(b.ID));
recycleView.ShowList(listLevelInfo.Count);
OnRefreshArrow(Vector2.one);
2024-05-06 16:46:00 +08:00
IsShowMode = ChapterType != LevelChapterType.Storyline;
2024-04-07 16:22:58 +08:00
IsScaleShow = true;
}
private void OnRefreshItem(GameObject cell, int index)
{
if (!dicLevelItem.TryGetValue(cell.GetInstanceID(), out LevelItem levelItem))
{
levelItem = new LevelItem(cell, callback);
dicLevelItem.Add(cell.GetInstanceID(), levelItem);
}
if (index < 0 || index >= listLevelInfo.Count)
{
DebugUtil.LogError($"索引错误 {index}");
return;
}
levelItem.SetInfo(listLevelInfo[index]);
}
/// <summary>
/// 刷新列表箭头
/// </summary>
/// <param name="vector2"></param>
private void OnRefreshArrow(Vector2 vector2)
{
if (recycleView.IsShowOnePage)
goArrow.IsScaleShow(false);
else
goArrow.IsScaleShow(vector2.y > 0f);
}
}
#endregion
/// <summary>
/// 页签类型
/// </summary>
private enum E_PageType
{
/// <summary>
/// 无效
/// </summary>
None = 0,
/// <summary>
/// 模式
/// </summary>
Mode = 1,
/// <summary>
/// 章节
/// </summary>
Chapter = 2,
/// <summary>
/// 关卡
/// </summary>
Level = 3,
}
2023-10-26 20:20:11 +08:00
2024-05-06 16:46:00 +08:00
#region UI
/// <summary>
/// 返回按钮
/// </summary>
private Button buttonBack;
/// <summary>
/// 主页按钮
/// </summary>
private Button buttonHome;
#endregion
2024-04-07 16:22:58 +08:00
private Animation animation;
private RectTransform _starRewardsParent;
private RedPointUIController easyLevelGroupRedPointUI;
private RedPointUIController hardLevelGroupRedPointUI;
2023-10-26 20:20:11 +08:00
/// <summary>
/// 进入动画名
/// </summary>
private const string IN_ANIMATION_NAME = "LS_MoveIn";
/// <summary>
/// 退出动画名
/// </summary>
private const string OUT_ANIMATION_NAME = "LS_MoveOut";
#region 私有变量
2024-04-07 16:22:58 +08:00
/// <summary>
/// 当前章节信息
/// </summary>
private ChapterInfo curChapterInfo;
/// <summary>
/// 当前简单关卡组信息
/// </summary>
private LevelGroupInfo curEasyLevelGroupInfo;
/// <summary>
/// 当前困难关卡组信息
/// </summary>
private LevelGroupInfo curHardLevelGroupInfo;
/// <summary>
/// 当前剧情关卡组信息
/// </summary>
private LevelGroupInfo curPlotLevelGroupInfo;
/// <summary>
/// 当前关卡组信息
/// </summary>
private LevelGroupInfo curLevelGroupInfo;
2024-01-18 17:16:20 +08:00
private float _progressmoveSpeed = 1f;
2023-10-27 12:07:33 +08:00
private CancellationTokenSource _cts;
2024-04-02 18:48:02 +08:00
/// <summary>
/// 电量
/// </summary>
private Batterie batterie;
/// <summary>
/// 网络信号
/// </summary>
private NetSignal netSignal;
/// <summary>
/// 刷新计时
/// </summary>
private float timer;
2024-04-07 16:22:58 +08:00
/// <summary>
2024-05-06 16:46:00 +08:00
/// 面板字典
2024-04-07 16:22:58 +08:00
/// </summary>
private readonly Dictionary<E_PageType, BaseChoosePanel> dicPanel = new();
/// <summary>
/// 当前页签
/// </summary>
private E_PageType curPage = E_PageType.None;
/// <summary>
/// 章节类型
/// </summary>
private LevelChapterType curChapterType;
2024-04-08 15:09:59 +08:00
/// <summary>
/// 货币栏
/// </summary>
2024-04-22 15:29:20 +08:00
private UI_CurrencyList currencyList;
#endregion
2024-05-24 14:21:11 +08:00
public override async void PreLoad(object data = null)
2024-02-22 19:47:38 +08:00
{
2024-05-24 14:21:11 +08:00
await CommonUtils.PreLoadOrUnloadEnvironmentWeatherDayNightIcon(true);
2024-02-22 19:47:38 +08:00
}
2024-01-23 12:25:47 +08:00
public override void OnInit()
2023-10-26 20:20:11 +08:00
{
UI_LevelSelectBinder.GetComponents(this);
2024-05-06 16:46:00 +08:00
buttonBack = GetComponent<Button>("Button_Back/Button_back");
buttonHome = GetComponent<Button>("Button_Back/Button_Home");
2024-04-02 18:48:02 +08:00
2024-04-07 16:22:58 +08:00
animation = GetComponent<Animation>();
2024-04-22 15:29:20 +08:00
currencyList = GetComponent<UI_CurrencyList>("UI_CurrencyList");
2024-04-07 16:22:58 +08:00
easyLevelGroupRedPointUI = Button_Easy.transform.Find("UI_RedPoint").GetComponent<RedPointUIController>();
hardLevelGroupRedPointUI = Button_Hard.transform.Find("UI_RedPoint").GetComponent<RedPointUIController>();
2024-04-02 19:50:36 +08:00
2024-04-02 18:48:02 +08:00
batterie = new Batterie(FindObj("UI_BattertSignal/BatteryRoot"));
netSignal = new NetSignal(FindObj("UI_BattertSignal/SignalRoot"));
2024-04-07 16:22:58 +08:00
dicPanel.Add(E_PageType.Mode, new ModeChoosePanel(FindObj("UI_ModeChoose"), OnMode, OnLevel));
dicPanel.Add(E_PageType.Chapter, new ChapterChoosePanel(FindObj("UI_LevelGroupChoose"), OnChapter));
dicPanel.Add(E_PageType.Level, new LevelChoosePanel(FindObj("UI_LevelChoose"), OnLevel));
2024-04-12 14:12:35 +08:00
//_currencyList = GetComponent<UI_CurrencyList>("UI_Topbtn/UI_CurrencyList");
2024-04-08 15:09:59 +08:00
2024-04-07 16:22:58 +08:00
_starRewardsParent = Image_ProcessBar.transform as RectTransform;
2024-05-06 16:46:00 +08:00
currencyList.SetData(GLConfig.Inst.data.GoldItemId, GLConfig.Inst.data.DiamondItemId, GLConfig.Inst.data.EnergyPointID);
2024-04-22 15:29:20 +08:00
2024-05-06 16:46:00 +08:00
BindButton(buttonBack, OnBack);
BindButton(buttonHome, OnHome);
BindButton(Button_Easy, OnEasy);
BindButton(Button_Hard, OnHard);
BindButton(Button_GetAll, OnStarReward);
2024-04-02 18:48:02 +08:00
2024-04-07 16:22:58 +08:00
EventManager.Instance.Register(EventManager.EventName.ChapterInfoChange, OnRefresh);
EventManager.Instance.Register(EventManager.EventName.LevelUnlock, OnRefresh);
EventManager.Instance.Register(EventManager.EventName.LevelInfoChanged, OnRefresh);
2023-10-26 20:20:11 +08:00
}
2024-04-02 18:48:02 +08:00
protected override void OnShowWindow(object data = null)
{
2024-05-31 16:51:38 +08:00
base.OnShowWindow(data);
2024-04-07 16:22:58 +08:00
SelectPage(E_PageType.Mode);
2024-04-22 15:29:20 +08:00
if (data is LevelInfo levelInfo)
2024-05-24 14:21:11 +08:00
{
OnMode(levelInfo.ChapterInfo.ChapterType);
OnChapter(levelInfo.ChapterInfo);
2024-05-24 14:21:11 +08:00
}
2024-04-22 15:29:20 +08:00
currencyList.Refresh();
2024-04-02 18:48:02 +08:00
}
protected override void OnReloadWindow(object data = null)
{
2024-04-07 16:22:58 +08:00
OnRefresh();
2024-04-02 18:48:02 +08:00
}
protected override void OnUpdate()
{
timer += Time.deltaTime;
2024-05-06 16:46:00 +08:00
if (timer >= 1f) // 每秒刷新电量和信号
2024-04-02 18:48:02 +08:00
{
batterie.SetInfo(DeviceHelper.GetBatteryLevel());
netSignal.SetInfo();//DeviceHelper.GetNetworkSignal()
2024-04-02 18:48:02 +08:00
timer -= 1f;
}
}
2024-05-06 16:46:00 +08:00
public override async UniTask<bool> OnBack(object data = null)
{
OnBack();
2024-06-03 19:52:28 +08:00
await UniTask.Yield();
2024-05-06 16:46:00 +08:00
return true;
}
2024-06-03 19:52:28 +08:00
public override async void OnRelease()
2024-04-02 18:48:02 +08:00
{
2024-04-07 16:22:58 +08:00
EventManager.Instance.Unregister(EventManager.EventName.ChapterInfoChange, OnRefresh);
EventManager.Instance.Unregister(EventManager.EventName.LevelUnlock, OnRefresh);
EventManager.Instance.Unregister(EventManager.EventName.LevelInfoChanged, OnRefresh);
2024-06-03 19:52:28 +08:00
await CommonUtils.PreLoadOrUnloadEnvironmentWeatherDayNightIcon(false);
2024-05-06 16:46:00 +08:00
2024-04-07 16:22:58 +08:00
curPage = E_PageType.Mode;
2024-04-02 18:48:02 +08:00
_cts?.Cancel();
_cts?.Dispose();
2023-10-26 20:20:11 +08:00
2024-04-07 16:22:58 +08:00
base.OnRelease();
2023-10-26 20:20:11 +08:00
}
2024-04-07 16:22:58 +08:00
/// <summary>
/// 选择页签
/// </summary>
private void SelectPage(E_PageType pageType)
2023-10-26 20:20:11 +08:00
{
2024-04-07 16:22:58 +08:00
if (curPage == pageType)
return;
2024-04-02 19:50:36 +08:00
2024-04-07 16:22:58 +08:00
if (dicPanel.TryGetValue(curPage, out BaseChoosePanel baseChoosePanel))
baseChoosePanel.IsScaleShow = false;
2023-10-26 20:20:11 +08:00
2024-04-07 16:22:58 +08:00
curPage = pageType;
2023-10-26 20:20:11 +08:00
2024-04-07 16:22:58 +08:00
OnRefresh();
2023-10-26 20:20:11 +08:00
2024-04-07 16:22:58 +08:00
switch (curPage)
2023-10-26 20:20:11 +08:00
{
2024-04-07 16:22:58 +08:00
case E_PageType.Mode:
2024-04-02 18:48:02 +08:00
{
batterie.IsScaleShow = true;
netSignal.IsScaleShow = true;
}
2023-10-26 20:20:11 +08:00
break;
2024-04-07 16:22:58 +08:00
case E_PageType.Chapter:
2024-04-02 18:48:02 +08:00
{
batterie.IsScaleShow = true;
netSignal.IsScaleShow = true;
}
2023-10-26 20:20:11 +08:00
break;
2024-04-07 16:22:58 +08:00
case E_PageType.Level:
2024-04-02 18:48:02 +08:00
{
batterie.IsScaleShow = false;
netSignal.IsScaleShow = false;
}
2023-10-26 20:20:11 +08:00
break;
}
}
2024-04-07 16:22:58 +08:00
/// <summary>
2024-05-06 16:46:00 +08:00
/// 刷新面板
2024-04-07 16:22:58 +08:00
/// </summary>
private void OnRefresh()
2023-10-26 20:20:11 +08:00
{
2024-04-07 16:22:58 +08:00
if (dicPanel.TryGetValue(curPage, out BaseChoosePanel baseChoosePanel))
2023-10-26 20:20:11 +08:00
{
2024-04-07 16:22:58 +08:00
baseChoosePanel.ChapterType = curChapterType;
baseChoosePanel.ChapterInfo = curLevelGroupInfo;
baseChoosePanel.SetInfo();
2023-10-26 20:20:11 +08:00
}
}
2024-04-07 16:22:58 +08:00
/// <summary>
/// 初始化章节信息
/// </summary>
/// <returns></returns>
private LevelGroupInfo InitChapter()
2023-10-26 20:20:11 +08:00
{
2024-04-07 16:22:58 +08:00
curEasyLevelGroupInfo = curChapterInfo.EasyLevelGroup;
curHardLevelGroupInfo = curChapterInfo.HardLevelGroup;
curPlotLevelGroupInfo = curChapterInfo.PlotLevelGroup;
2023-10-26 20:20:11 +08:00
2024-04-07 16:22:58 +08:00
Button_Easy.interactable = IsChapterValid(curEasyLevelGroupInfo);
Button_Hard.interactable = IsChapterValid(curHardLevelGroupInfo);
2023-10-26 20:20:11 +08:00
2024-04-07 16:22:58 +08:00
easyLevelGroupRedPointUI.ResetToDefault();
hardLevelGroupRedPointUI.ResetToDefault();
2023-10-26 20:20:11 +08:00
2024-04-07 16:22:58 +08:00
if (curEasyLevelGroupInfo != null)
easyLevelGroupRedPointUI.NodeID = curEasyLevelGroupInfo.RedPointNode.ID;
2023-10-26 20:20:11 +08:00
2024-04-07 16:22:58 +08:00
if (curHardLevelGroupInfo != null)
hardLevelGroupRedPointUI.NodeID = curHardLevelGroupInfo.RedPointNode.ID;
2023-10-26 20:20:11 +08:00
2024-04-07 16:22:58 +08:00
LevelGroupInfo result = IsChapterValid(curEasyLevelGroupInfo) ? curEasyLevelGroupInfo :
IsChapterValid(curHardLevelGroupInfo) ? curHardLevelGroupInfo : curPlotLevelGroupInfo;
2023-10-26 20:20:11 +08:00
return result;
}
2024-04-07 16:22:58 +08:00
/// <summary>
2024-05-06 16:46:00 +08:00
/// 判断章节是否有效
2024-04-07 16:22:58 +08:00
/// </summary>
/// <param name="chapter"></param>
/// <returns></returns>
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-04-07 16:22:58 +08:00
private void ChangeLevelGroup(LevelGroupInfo levelGroupInfo)
2023-10-26 20:20:11 +08:00
{
2024-05-30 12:50:56 +08:00
/*if (curLevelGroupInfo == levelGroupInfo)
return;*/
2024-04-07 16:22:58 +08:00
LevelGroupInfo oldLevelGroupInfo = curLevelGroupInfo;
curLevelGroupInfo = levelGroupInfo;
SetLevelGroupButtonSelected(Button_Easy, levelGroupInfo == curEasyLevelGroupInfo);
SetLevelGroupButtonSelected(Button_Hard, levelGroupInfo == curHardLevelGroupInfo);
if (levelGroupInfo.LevelType != LevelType.Plot &&
(levelGroupInfo.StarList == null || levelGroupInfo.StarList.Length == 0))
2024-01-08 19:39:41 +08:00
{
2024-04-07 16:22:58 +08:00
DebugUtil.LogError($"levelGroup的星级奖励列表未配置!levelGroup ID:{levelGroupInfo.ID}");
2024-01-08 19:39:41 +08:00
return;
}
2024-01-09 14:00:53 +08:00
2024-04-07 16:22:58 +08:00
// 播放切换levelGroup动画
2024-01-19 14:40:40 +08:00
if (oldLevelGroupInfo != null)
2024-01-09 16:54:21 +08:00
{
2024-04-07 16:22:58 +08:00
if (oldLevelGroupInfo.LevelType == LevelType.Plot && levelGroupInfo.LevelType != LevelType.Plot)
animation.Play(IN_ANIMATION_NAME);
if (oldLevelGroupInfo.LevelType != LevelType.Plot && levelGroupInfo.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-04-07 16:22:58 +08:00
if (levelGroupInfo.LevelType != LevelType.Plot)
2024-01-19 14:40:40 +08:00
{
2024-04-07 16:22:58 +08:00
animation.Play(IN_ANIMATION_NAME);
var clip = animation[IN_ANIMATION_NAME];
clip.speed = 0f;
2024-01-19 14:40:40 +08:00
clip.time = clip.length;
2024-04-07 16:22:58 +08:00
animation.Sample();
animation.Stop(IN_ANIMATION_NAME);
clip.speed = 1f;
2024-01-19 14:40:40 +08:00
}
2024-01-09 14:00:53 +08:00
}
2024-01-18 19:12:39 +08:00
2024-04-07 16:22:58 +08:00
if (levelGroupInfo.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-04-07 16:22:58 +08:00
int maxTarget = levelGroupInfo.StarList[^1];
float progressLength = _starRewardsParent.rect.width;
var currStarCount = levelGroupInfo.StarCount;
var currRewardIndexMax = levelGroupInfo.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
2024-04-07 16:22:58 +08:00
float 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
}
2024-04-12 18:00:31 +08:00
OnRefresh();
2023-10-26 20:20:11 +08:00
}
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 async void PlayProgressAnimation(float ratio, float progressLength, CancellationToken token)
{
2024-01-18 17:16:20 +08:00
Image_ProcessBar.fillAmount = 0;
2024-05-30 12:50:56 +08:00
int maxStarCount = curLevelGroupInfo.StarList[^1];
float targetFillAmount = (float)curLevelGroupInfo.StarCount / maxStarCount;
2024-01-18 19:12:39 +08:00
2024-01-18 17:16:20 +08:00
while (Image_ProcessBar.fillAmount < targetFillAmount)
2023-10-26 20:20:11 +08:00
{
2024-05-30 12:50:56 +08:00
float 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;
2023-10-26 20:20:11 +08:00
2024-05-30 12:50:56 +08:00
bool isCanceled = await UniTask.DelayFrame(1, PlayerLoopTiming.Update, token).SuppressCancellationThrow();
2023-10-26 20:20:11 +08:00
if (isCanceled)
return;
}
}
2024-04-07 16:22:58 +08:00
#region 回调方法
/// <summary>
/// 点击模式
/// </summary>
/// <param name="levelChapterType"></param>
private void OnMode(LevelChapterType levelChapterType)
2023-10-26 20:20:11 +08:00
{
2024-04-07 16:22:58 +08:00
curChapterType = levelChapterType;
2024-07-05 23:14:53 +08:00
#region TODO 临时处理
if (LevelChapterType.Storyline == levelChapterType)
{
List<ChapterInfo> chapterInfos = new();
LevelManager.Instance.GetChapterInfosByType(levelChapterType, ref chapterInfos);
if (chapterInfos.Count > 0)
{
curChapterInfo = chapterInfos[0];
InitChapter();
OnPlot();
}
}
#endregion
2024-04-07 16:22:58 +08:00
SelectPage(E_PageType.Chapter);
2023-10-26 20:20:11 +08:00
}
2024-04-07 16:22:58 +08:00
/// <summary>
/// 点击章节
/// </summary>
private void OnChapter(ChapterInfo chapterInfo)
2023-10-26 20:20:11 +08:00
{
2024-06-13 15:05:32 +08:00
if (chapterInfo.IsLock)
return;
2024-04-07 16:22:58 +08:00
curChapterInfo = chapterInfo;
Text_ChapterName.text = curChapterInfo.Name;
Text_ChapterNum.text = $"{curChapterInfo.Index:00}";
LevelGroupInfo defaultLevelGroup = InitChapter();
if (defaultLevelGroup != null)
ChangeLevelGroup(defaultLevelGroup);
2023-10-26 20:20:11 +08:00
2024-04-07 16:22:58 +08:00
SelectPage(E_PageType.Level);
}
2023-10-26 20:20:11 +08:00
2024-04-07 16:22:58 +08:00
/// <summary>
/// 点击关卡
/// </summary>
private async void OnLevel(LevelInfo levelInfo)
{
if (levelInfo == null)
2023-10-26 20:20:11 +08:00
return;
2024-04-07 16:22:58 +08:00
if (levelInfo.IsStory)
LevelManager.Instance.TryEnterLevel(levelInfo.ID);
else
await UI_LevelDetailController.Open(levelInfo);
}
2023-10-26 20:20:11 +08:00
2024-05-06 16:46:00 +08:00
/// <summary>
/// 返回
/// </summary>
private void OnBack()
2023-10-26 20:20:11 +08:00
{
2024-04-07 16:22:58 +08:00
switch (curPage)
2023-10-26 20:20:11 +08:00
{
2024-04-07 16:22:58 +08:00
case E_PageType.Mode:
{
2024-05-06 16:46:00 +08:00
OnHome();
}
2023-10-27 12:07:33 +08:00
break;
2024-04-07 16:22:58 +08:00
case E_PageType.Chapter:
{
SelectPage(E_PageType.Mode);
}
2023-10-27 12:07:33 +08:00
break;
2024-04-07 16:22:58 +08:00
case E_PageType.Level:
{
SelectPage(E_PageType.Chapter);
}
2023-10-27 12:07:33 +08:00
break;
2023-10-26 20:20:11 +08:00
}
}
2024-05-06 16:46:00 +08:00
/// <summary>
/// 主页
/// </summary>
private void OnHome()
2024-01-03 17:25:13 +08:00
{
2024-04-03 14:46:57 +08:00
CommonUtils.ChangeUIScene(Constants.MAIN_SCENE_PATH);
CloseWindow();
UIManager.Instance.ShowAllUI();
2023-10-26 20:20:11 +08:00
}
2024-04-07 16:22:58 +08:00
/// <summary>
/// 点击简单
/// </summary>
2024-05-06 16:46:00 +08:00
private void OnEasy()
2023-10-26 20:20:11 +08:00
{
2024-04-07 16:22:58 +08:00
if (curEasyLevelGroupInfo != null)
ChangeLevelGroup(curEasyLevelGroupInfo);
2023-10-26 20:20:11 +08:00
}
2024-04-07 16:22:58 +08:00
/// <summary>
/// 点击困难
/// </summary>
2024-05-06 16:46:00 +08:00
private void OnHard()
2023-10-26 20:20:11 +08:00
{
2024-06-13 15:05:32 +08:00
if (null == curHardLevelGroupInfo)
return;
ChangeLevelGroup(curHardLevelGroupInfo);
2023-10-26 20:20:11 +08:00
}
2024-04-07 16:22:58 +08:00
/// <summary>
/// 点击剧情
/// </summary>
2024-05-06 16:46:00 +08:00
private void OnPlot()
2023-10-26 20:20:11 +08:00
{
2024-04-07 16:22:58 +08:00
if (curPlotLevelGroupInfo != null)
ChangeLevelGroup(curPlotLevelGroupInfo);
2023-10-26 20:20:11 +08:00
}
2024-05-06 16:46:00 +08:00
private void OnStarReward()
2023-10-27 18:23:18 +08:00
{
2024-05-06 16:46:00 +08:00
int index = curLevelGroupInfo.OwnRewardMaxIndex + 1;
2024-04-07 16:22:58 +08:00
if (curLevelGroupInfo.CanGetReward(index))
LevelManager.Instance.GetStarReward(curLevelGroupInfo.ID, index);
2023-10-30 18:33:18 +08:00
}
2024-04-22 15:29:20 +08:00
#endregion
2024-01-18 19:12:39 +08:00
}