2024-04-07 16:22:58 +08:00
|
|
|
|
using System;
|
2024-01-09 14:00:53 +08:00
|
|
|
|
using System.Collections.Generic;
|
2024-09-03 19:22:47 +08:00
|
|
|
|
using System.Data;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Net.Sockets;
|
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;
|
2023-12-05 12:49:29 +08:00
|
|
|
|
using Gameplay;
|
2024-04-08 15:09:59 +08:00
|
|
|
|
using Gameplay.Common;
|
2023-10-26 20:20:11 +08:00
|
|
|
|
using Gameplay.Level;
|
2024-07-10 16:56:38 +08:00
|
|
|
|
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;
|
2024-04-03 14:23:41 +08:00
|
|
|
|
using Constants = Framework.Constants;
|
2023-10-24 14:58:21 +08:00
|
|
|
|
|
|
|
|
|
|
public class UI_LevelSelectController : UIWindow
|
|
|
|
|
|
{
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 打开关卡选择界面
|
|
|
|
|
|
/// </summary>
|
2024-05-24 13:28:03 +08:00
|
|
|
|
/// <param name="levelInfo">有数据则跳转到对应关卡选项,没有数据则显示默认</param>
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <returns></returns>
|
2024-05-24 13:28:03 +08:00
|
|
|
|
public static async UniTask<UIWindow> Open(LevelInfo levelInfo = null)
|
2024-04-03 14:23:41 +08:00
|
|
|
|
{
|
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-03 14:23:41 +08:00
|
|
|
|
|
2024-04-29 15:36:17 +08:00
|
|
|
|
return uiWindow;
|
2024-04-03 14:23:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
#region 结构
|
2024-04-02 16:44:23 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 页签模式
|
2024-04-02 16:44:23 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private enum E_PageModeType
|
2024-04-02 16:44:23 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
None,
|
2024-04-02 16:44:23 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 章节
|
2024-04-02 16:44:23 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
Chapter,
|
2024-04-02 16:44:23 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 关卡
|
2024-04-02 16:44:23 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
Level,
|
2024-04-02 16:44:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 模式按钮
|
2024-04-02 16:44:23 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private class ModeButton : UIGameObjectWrapper
|
2024-04-02 16:44:23 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
#region UI
|
2024-04-02 16:44:23 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 章节按钮
|
2024-04-02 16:44:23 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private Button button;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 选中状态
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private GameObject goSelect;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 未选中状态
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private GameObject goUnSelect;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 选中箭头
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private GameObject goTriangle;
|
|
|
|
|
|
#endregion
|
2024-04-02 16:44:23 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 选择模式
|
2024-04-02 16:44:23 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private readonly Action<E_ChapterType> selectModeAction;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 章节类型
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private readonly E_ChapterType chapterType;
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsSelect
|
2024-04-02 16:44:23 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
set
|
2024-04-02 16:44:23 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
goSelect.IsScaleShow(value);
|
|
|
|
|
|
goTriangle.IsScaleShow(value);
|
|
|
|
|
|
goUnSelect.IsScaleShow(!value);
|
2024-04-02 16:44:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-07-10 16:56:38 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
public ModeButton(GameObject root, E_ChapterType type, Action<E_ChapterType> selectMode) : base(root, true)
|
2024-07-10 16:56:38 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
chapterType = type;
|
|
|
|
|
|
selectModeAction = selectMode;
|
2024-07-10 16:56:38 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
button = GoRoot.GetComponent<Button>();
|
|
|
|
|
|
goSelect = FindObj("Image_Selected");
|
|
|
|
|
|
goUnSelect = FindObj("Image_Unselect");
|
|
|
|
|
|
goTriangle = FindObj("Image_Triangle");
|
|
|
|
|
|
|
|
|
|
|
|
IsSelect = false;
|
|
|
|
|
|
|
|
|
|
|
|
BindButton(button, OnClick);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnClick()
|
|
|
|
|
|
{
|
|
|
|
|
|
selectModeAction?.Invoke(chapterType);
|
2024-07-10 16:56:38 +08:00
|
|
|
|
}
|
2024-04-02 16:44:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
#region 章节
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 章节基类
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private abstract class ChapterBase : UIGameObjectWrapper
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 动态列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
protected RecycleView recycleView;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 电池
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private readonly Batterie batterie;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// wifi
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private readonly NetSignal netSignal;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 章节信息
|
|
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
protected readonly E_ChapterType chapterType;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 章节信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
protected List<ChapterInfo> listChapterInfo;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 选择章节回调
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private readonly Action<ChapterInfo> selectChapterAction;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
|
|
|
|
|
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);
|
2024-09-03 19:22:47 +08:00
|
|
|
|
recycleView.ScrollRect.enabled = value;
|
|
|
|
|
|
if (value)
|
|
|
|
|
|
recycleView.ScrollRect.verticalNormalizedPosition = 1f;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ChapterBase(GameObject root, E_ChapterType chapter, Action<ChapterInfo> selectChapter) : base(root)
|
|
|
|
|
|
{
|
|
|
|
|
|
chapterType = chapter;
|
|
|
|
|
|
selectChapterAction = selectChapter;
|
|
|
|
|
|
|
|
|
|
|
|
recycleView = GetComponent<RecycleView>("RecycleView");
|
|
|
|
|
|
|
|
|
|
|
|
batterie = new Batterie(FindObj("Image_BottomBar/BatteryRoot"));
|
|
|
|
|
|
netSignal = new NetSignal(FindObj("Image_BottomBar/SignalRoot"));
|
|
|
|
|
|
|
|
|
|
|
|
recycleView.Init(RefreshCell);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void SetInfo()
|
|
|
|
|
|
{
|
|
|
|
|
|
RefreshBatterie();
|
|
|
|
|
|
RefreshNetSignal();
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
if (!LevelManager.Instance.TryGetChapterInfosByType(chapterType, out listChapterInfo))
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"没有获取到{chapterType}类型的章节信息");
|
|
|
|
|
|
return;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 刷新电量
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="batteryPower"></param>
|
|
|
|
|
|
public void RefreshBatterie()
|
|
|
|
|
|
{
|
|
|
|
|
|
batterie.SetInfo();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 刷新信号
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="networkSignal"></param>
|
|
|
|
|
|
public void RefreshNetSignal()
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
netSignal.SetInfo();
|
2024-04-07 16:22:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
protected abstract void RefreshCell(GameObject cell, int index);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 点击章节
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="chapterInfo"></param>
|
|
|
|
|
|
protected void OnChapter(ChapterInfo chapterInfo)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectChapterAction?.Invoke(chapterInfo);
|
|
|
|
|
|
}
|
2023-10-26 20:20:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 主线章节
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private class MainChapter : ChapterBase
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 列表章节选项
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private class ChapterItem : UIGameObjectWrapper
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
|
|
|
|
|
#region UI
|
|
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 选中章节
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private Button button;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 章节名
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private TMP_Text textChapterName;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 章节索引
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private TMP_Text textChapterIndex;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 简单星星数量
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private TMP_Text textEasyStarCount;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 困难星星数量
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private TMP_Text textDifficultStarCount;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 上次泊车标志
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private GameObject goLast;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 简单星星未激活状态
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private GameObject goEasyStar;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 简单星星激活状态
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private GameObject goEasyStarEnable;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 困难星星未激活状态
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private GameObject goDifficultStar;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 困难星星激活状态
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private GameObject goDifficultStarEnable;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 章节信息
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private ChapterInfo chapterInfo;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 选中章节
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private readonly Action<ChapterInfo> selectChapterAction;
|
|
|
|
|
|
|
|
|
|
|
|
#region 属性
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 是否显示简单星星
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
public bool IsShowEasyStar
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
set
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
goEasyStarEnable.IsScaleShow(value);
|
|
|
|
|
|
goEasyStar.IsScaleShow(!value);
|
2024-04-07 16:22:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 是否显示困难星星
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
public bool IsShowDiffcultStar
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
goDifficultStarEnable.IsScaleShow(value);
|
|
|
|
|
|
goDifficultStar.IsScaleShow(!value);
|
|
|
|
|
|
}
|
2024-04-07 16:22:58 +08:00
|
|
|
|
}
|
2024-09-03 19:22:47 +08:00
|
|
|
|
#endregion
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
public ChapterItem(GameObject root, Action<ChapterInfo> selectChapter) : base(root)
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
selectChapterAction = selectChapter;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
button = GoRoot.GetComponent<Button>();
|
|
|
|
|
|
textChapterName = GetComponent<TMP_Text>("Text_LevelName");
|
|
|
|
|
|
textChapterIndex = GetComponent<TMP_Text>("Text_Episode");
|
|
|
|
|
|
textEasyStarCount = GetComponent<TMP_Text>("UI_Easy/Text_Progress");
|
|
|
|
|
|
textDifficultStarCount = GetComponent<TMP_Text>("UI_Difficult/Text_Progress");
|
|
|
|
|
|
goLast = FindObj("Image_Last");
|
|
|
|
|
|
goEasyStar = FindObj("UI_Easy/Image_StarOff");
|
|
|
|
|
|
goEasyStarEnable = FindObj("UI_Easy/Image_StarOn");
|
|
|
|
|
|
goDifficultStar = FindObj("UI_Difficult/Image_StarOff");
|
|
|
|
|
|
goDifficultStarEnable = FindObj("UI_Difficult/Image_StarOn");
|
|
|
|
|
|
|
|
|
|
|
|
BindButton(button, OnClick);
|
2024-04-07 16:22:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 入口
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// <param name="chapterInfo"></param>
|
|
|
|
|
|
/// <param name="isLastFight">是否上次战斗的关卡</param>
|
|
|
|
|
|
public void SetInfo(ChapterInfo info, bool isLastFight)
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
chapterInfo = info;
|
|
|
|
|
|
|
|
|
|
|
|
textChapterName.text = chapterInfo.Name;
|
|
|
|
|
|
textChapterIndex.text = $"EPISODE {chapterInfo.Cfg.Index:00}";
|
|
|
|
|
|
|
|
|
|
|
|
if (chapterInfo.TryGetGroupInfo(E_LevelDifficulty.Easy, out LevelGroupInfo easyGroupInfo))
|
|
|
|
|
|
{
|
|
|
|
|
|
textEasyStarCount.text = $"{easyGroupInfo.StarCount}/{easyGroupInfo.StarMax}";
|
|
|
|
|
|
IsShowEasyStar = easyGroupInfo.StarCount >= easyGroupInfo.StarMax;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
textEasyStarCount.text = "0/0";
|
|
|
|
|
|
IsShowEasyStar = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (chapterInfo.TryGetGroupInfo(E_LevelDifficulty.Hard, out LevelGroupInfo diffcultGroupInfo))
|
|
|
|
|
|
{
|
|
|
|
|
|
textDifficultStarCount.text = $"{diffcultGroupInfo.StarCount}/{diffcultGroupInfo.StarMax}";
|
|
|
|
|
|
IsShowDiffcultStar = diffcultGroupInfo.StarCount >= diffcultGroupInfo.StarMax;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
textDifficultStarCount.text = "0/0";
|
|
|
|
|
|
IsShowDiffcultStar = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
goLast.IsScaleShow(isLastFight);
|
|
|
|
|
|
|
|
|
|
|
|
IsScaleShow = true;
|
|
|
|
|
|
}
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private void OnClick()
|
|
|
|
|
|
{
|
|
|
|
|
|
selectChapterAction?.Invoke(chapterInfo);
|
2024-04-07 16:22:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 选项字典
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private readonly Dictionary<int, ChapterItem> dicChapterItem = new();
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 上次战斗的章节id
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private int lastFightChapterId;
|
|
|
|
|
|
|
|
|
|
|
|
public MainChapter(GameObject root, Action<ChapterInfo> selectChapter) : base(root, E_ChapterType.Main, selectChapter)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
public override void SetInfo()
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
base.SetInfo();
|
|
|
|
|
|
|
|
|
|
|
|
LevelInfo levelInfo = LevelManager.Instance.GetLastFightLevelInfo(chapterType);
|
|
|
|
|
|
if (null == levelInfo)
|
|
|
|
|
|
lastFightChapterId = -1;
|
|
|
|
|
|
else
|
|
|
|
|
|
lastFightChapterId = levelInfo.ChapterInfo.Cfg.Id;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
recycleView.ShowList(listChapterInfo.Count);
|
2024-01-09 16:54:21 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
IsScaleShow = true;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
protected override void RefreshCell(GameObject cell, int index)
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
if (!dicChapterItem.TryGetValue(cell.GetInstanceID(), out ChapterItem chapterItem))
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
chapterItem = new(cell, OnChapter);
|
|
|
|
|
|
dicChapterItem.Add(cell.GetInstanceID(), chapterItem);
|
2024-04-07 16:22:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
if (null == listChapterInfo)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("章节列表无效");
|
|
|
|
|
|
chapterItem.IsScaleShow = false;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (index < 0 || index >= listChapterInfo.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("越界");
|
|
|
|
|
|
chapterItem.IsScaleShow = false;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ChapterInfo chapterInfo = listChapterInfo[index];
|
|
|
|
|
|
chapterItem.SetInfo(chapterInfo, chapterInfo.Cfg.Id == lastFightChapterId);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 资源章节
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private class ResourceChapter : ChapterBase
|
|
|
|
|
|
{
|
|
|
|
|
|
public ResourceChapter(GameObject root, Action<ChapterInfo> selectChapter) : base(root, E_ChapterType.Resource, selectChapter)
|
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
protected override void RefreshCell(GameObject cell, int index)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
2024-04-07 16:22:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-10-26 20:20:11 +08:00
|
|
|
|
|
2024-04-02 19:50:36 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 剧情章节
|
2024-04-02 19:50:36 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private class StoryChapter : ChapterBase
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 列表章节选项
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
private class ChapterItem : UIGameObjectWrapper
|
|
|
|
|
|
{
|
|
|
|
|
|
#region UI
|
|
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 选中章节
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private Button button;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 章节名
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private TMP_Text textChapterName;
|
|
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 章节描述
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private TMP_Text textChapterDesc;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 上次泊车标志
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private GameObject goLast;
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 章节信息
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private ChapterInfo chapterInfo;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 选中章节
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private readonly Action<ChapterInfo> selectChapterAction;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
public ChapterItem(GameObject root, Action<ChapterInfo> selectChapter) : base(root)
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
selectChapterAction = selectChapter;
|
|
|
|
|
|
|
2024-04-07 16:22:58 +08:00
|
|
|
|
button = GoRoot.GetComponent<Button>();
|
2024-09-03 19:22:47 +08:00
|
|
|
|
textChapterName = GetComponent<TMP_Text>("Text_LevelName");
|
|
|
|
|
|
textChapterDesc = GetComponent<TMP_Text>("Text_Episode");
|
|
|
|
|
|
goLast = FindObj("Image_Last");
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
BindButton(button, OnClick);
|
2024-04-07 16:22:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 入口
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="chapterInfo"></param>
|
|
|
|
|
|
/// <param name="isLastFight">是否上次战斗的关卡</param>
|
|
|
|
|
|
public void SetInfo(ChapterInfo info, bool isLastFight)
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
chapterInfo = info;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
textChapterName.text = chapterInfo.Name;
|
|
|
|
|
|
textChapterDesc.text = chapterInfo.Desc;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
goLast.IsScaleShow(isLastFight);
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
|
|
|
|
|
IsScaleShow = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnClick()
|
|
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
selectChapterAction?.Invoke(chapterInfo);
|
2024-04-07 16:22:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 选项字典
|
|
|
|
|
|
/// </summary>
|
2024-04-07 16:22:58 +08:00
|
|
|
|
private readonly Dictionary<int, ChapterItem> dicChapterItem = new();
|
|
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 上次战斗的章节id
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private int lastFightChapterId;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
public StoryChapter(GameObject root, Action<ChapterInfo> selectChapter) : base(root, E_ChapterType.Storyline, selectChapter)
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void SetInfo()
|
|
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
base.SetInfo();
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
LevelInfo levelInfo = LevelManager.Instance.GetLastFightLevelInfo(chapterType);
|
|
|
|
|
|
if (null == levelInfo)
|
|
|
|
|
|
lastFightChapterId = -1;
|
|
|
|
|
|
else
|
|
|
|
|
|
lastFightChapterId = levelInfo.ChapterInfo.Cfg.Id;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
recycleView.ShowList(listChapterInfo.Count);
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
|
|
|
|
|
IsScaleShow = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
protected override void RefreshCell(GameObject cell, int index)
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
if (!dicChapterItem.TryGetValue(cell.GetInstanceID(), out ChapterItem chapterItem))
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
chapterItem = new(cell, OnChapter);
|
|
|
|
|
|
dicChapterItem.Add(cell.GetInstanceID(), chapterItem);
|
2024-04-07 16:22:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
if (null == listChapterInfo)
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
DebugUtil.LogError("章节列表无效");
|
|
|
|
|
|
chapterItem.IsScaleShow = false;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
if (index < 0 || index >= listChapterInfo.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("越界");
|
|
|
|
|
|
chapterItem.IsScaleShow = false;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
ChapterInfo chapterInfo = listChapterInfo[index];
|
|
|
|
|
|
chapterItem.SetInfo(chapterInfo, chapterInfo.Cfg.Id == lastFightChapterId);
|
2024-04-07 16:22:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-02 19:50:36 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 战役章节
|
2024-04-02 19:50:36 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private class WarChapter : ChapterBase
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
public WarChapter(GameObject root, Action<ChapterInfo> selectChapter) : base(root, E_ChapterType.War, selectChapter)
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
}
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
protected override void RefreshCell(GameObject cell, int index)
|
|
|
|
|
|
{
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
#region 关卡
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 选关基类
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private abstract class SelectLevelBase : UIGameObjectWrapper
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 关卡难度
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
protected E_LevelDifficulty levelDifficulty;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 章节信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
protected readonly E_ChapterType chapterType;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 关卡列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
protected readonly LevelList levelList;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 章节信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
protected ChapterInfo chapterInfo;
|
|
|
|
|
|
|
|
|
|
|
|
public SelectLevelBase(GameObject root, E_ChapterType chapter, LevelList list) : base(root)
|
|
|
|
|
|
{
|
|
|
|
|
|
chapterType = chapter;
|
|
|
|
|
|
levelList = list;
|
|
|
|
|
|
levelDifficulty = chapterType switch
|
|
|
|
|
|
{
|
|
|
|
|
|
E_ChapterType.Main => E_LevelDifficulty.Easy,
|
|
|
|
|
|
E_ChapterType.Resource or
|
|
|
|
|
|
E_ChapterType.Storyline or
|
|
|
|
|
|
E_ChapterType.War or
|
|
|
|
|
|
_ => E_LevelDifficulty.None,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void SetInfo(ChapterInfo info)
|
|
|
|
|
|
{
|
|
|
|
|
|
chapterInfo = info;
|
|
|
|
|
|
|
|
|
|
|
|
RefreshLevelList();
|
|
|
|
|
|
|
|
|
|
|
|
IsScaleShow = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 刷新关卡列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
protected void RefreshLevelList()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (null == chapterInfo)
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
levelList.SetInfo(null);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!chapterInfo.TryGetGroupInfo(levelDifficulty, out LevelGroupInfo levelGroupInfo))
|
|
|
|
|
|
{
|
|
|
|
|
|
levelList.SetInfo(null);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
levelList.SetInfo(levelGroupInfo.ListLevelInfo);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 主线选关基类
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private class MainSelectLevel : SelectLevelBase
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 简单
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private Button buttonEasy;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 困难
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private Button buttonDifficult;
|
|
|
|
|
|
|
|
|
|
|
|
public MainSelectLevel(GameObject root, LevelList levelList) : base(root, E_ChapterType.Main, levelList)
|
|
|
|
|
|
{
|
|
|
|
|
|
buttonEasy = GetComponent<Button>("Image_MainMission/UI_Easy");
|
|
|
|
|
|
buttonDifficult = GetComponent<Button>("Image_MainMission/UI_Difficult");
|
|
|
|
|
|
|
|
|
|
|
|
BindButton(buttonEasy, () => { OnDifficult(E_LevelDifficulty.Easy); });
|
|
|
|
|
|
BindButton(buttonDifficult, () => { OnDifficult(E_LevelDifficulty.Hard); });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 点击关卡难度
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="levelDifficulty"></param>
|
|
|
|
|
|
private void OnDifficult(E_LevelDifficulty difficulty)
|
|
|
|
|
|
{
|
|
|
|
|
|
levelDifficulty = difficulty;
|
|
|
|
|
|
|
|
|
|
|
|
RefreshLevelList();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 资源选关基类
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private class ResourceSelectLevel : SelectLevelBase
|
|
|
|
|
|
{
|
|
|
|
|
|
public ResourceSelectLevel(GameObject root, LevelList levelList) : base(root, E_ChapterType.Resource, levelList)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 剧情选关基类
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private class StorySelectLevel : SelectLevelBase
|
|
|
|
|
|
{
|
|
|
|
|
|
public StorySelectLevel(GameObject root, LevelList levelList) : base(root, E_ChapterType.Storyline, levelList)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 战役选关基类
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private class WarSelectLevel : SelectLevelBase
|
|
|
|
|
|
{
|
|
|
|
|
|
public WarSelectLevel(GameObject root, LevelList levelList) : base(root, E_ChapterType.War, levelList)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 关卡列表类
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private class LevelList : UIGameObjectWrapper
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 关卡选项
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private class LevelItem : UIGameObjectWrapper
|
|
|
|
|
|
{
|
|
|
|
|
|
#region UI
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 按钮
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private Button button;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 昼夜
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private Image imageTime;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 天气
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private Image imageWeather;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 环境
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private Image imageEnviroment;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 昼夜文本
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private TMP_Text textTime;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 天气文本
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private TMP_Text textWeather;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 环境文本
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private TMP_Text textEnviroment;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 关卡名
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private TMP_Text textLevelName;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 节点位置
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private RectTransform rtsRoot;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 向上的线
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private GameObject goUp;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 直线
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private GameObject goStraight;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 向下的线
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private GameObject goDown;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 主线关卡信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private GameObject goMainInfo;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 战役关卡信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private GameObject goWarInfo;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 星级列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private GameObject[] goStars;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 星级根节点
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private GameObject goStarRoot;
|
|
|
|
|
|
#endregion
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 关卡信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private LevelInfo levelInfo;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 关卡点击回调
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private readonly Action<LevelInfo> levelAction;
|
|
|
|
|
|
|
|
|
|
|
|
public LevelItem(GameObject root, Action<LevelInfo> level) : base(root)
|
|
|
|
|
|
{
|
|
|
|
|
|
levelAction = level;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
button = GoRoot.GetComponent<Button>();
|
|
|
|
|
|
imageTime = GetComponent<Image>("Root/Image_LevelInfo/Image_Time");
|
|
|
|
|
|
imageWeather = GetComponent<Image>("Root/Image_LevelInfo/Image_Weather");
|
|
|
|
|
|
imageEnviroment = GetComponent<Image>("Root/Image_LevelInfo/Image_Enviroment");
|
|
|
|
|
|
textTime = GetComponent<TMP_Text>("Root/Image_LevelInfo/Image_Time/Text");
|
|
|
|
|
|
textWeather = GetComponent<TMP_Text>("Root/Image_LevelInfo/Image_Weather/Text");
|
|
|
|
|
|
textEnviroment = GetComponent<TMP_Text>("Root/Image_LevelInfo/Image_Enviroment/Text");
|
|
|
|
|
|
textLevelName = GetComponent<TMP_Text>("Root/ImageChoose/Text_Level");
|
|
|
|
|
|
rtsRoot = FindObj("Root").GetComponent<RectTransform>();
|
|
|
|
|
|
goUp = FindObj("Root/ImageUp");
|
|
|
|
|
|
goStraight = FindObj("Root/ImageStraight");
|
|
|
|
|
|
goDown = FindObj("Root/ImageDown");
|
|
|
|
|
|
goMainInfo = FindObj("Root/Image_LevelInfo");
|
|
|
|
|
|
goWarInfo = FindObj("Root/Image_LevelInfoWar");
|
|
|
|
|
|
goStarRoot = FindObj("Root/UI_Stars");
|
|
|
|
|
|
Transform tsStarRoot = goStarRoot.transform;
|
|
|
|
|
|
goStars = new GameObject[tsStarRoot.childCount];
|
|
|
|
|
|
for (int i = 0; i < tsStarRoot.childCount; ++i)
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
goStars[i] = tsStarRoot.GetChild(i).gameObject;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
}
|
2024-05-24 14:21:11 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
goStraight.IsScaleShow(false);
|
2024-04-12 20:19:13 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
BindButton(button, OnClick);
|
|
|
|
|
|
}
|
2024-04-12 20:19:13 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
public async void SetInfo(LevelInfo info, int index, bool isLast)
|
|
|
|
|
|
{
|
|
|
|
|
|
levelInfo = info;
|
2024-04-12 20:19:13 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
textLevelName.text = info.Name;
|
|
|
|
|
|
if ((index & 1) == 1) // 奇数
|
|
|
|
|
|
{
|
|
|
|
|
|
rtsRoot.anchoredPosition = new Vector2(-170f, 0f);
|
|
|
|
|
|
goUp.IsScaleShow(!isLast);
|
|
|
|
|
|
goDown.IsScaleShow(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
else // 偶数
|
|
|
|
|
|
{
|
|
|
|
|
|
rtsRoot.anchoredPosition = new Vector2(-170f, 72f);
|
|
|
|
|
|
goUp.IsScaleShow(false);
|
|
|
|
|
|
goDown.IsScaleShow(!isLast);
|
2024-04-07 16:22:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
switch (info.ChapterInfo.Cfg.Type)
|
|
|
|
|
|
{
|
|
|
|
|
|
case E_ChapterType.Main:
|
|
|
|
|
|
{
|
|
|
|
|
|
bool[] starResults = info.StarResult;
|
|
|
|
|
|
for (int i = 0; i < goStars.Length && i < starResults.Length; ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
goStars[i].IsScaleShow(starResults[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
await AssetManager.Instance.WaitAllPreloads();
|
|
|
|
|
|
|
|
|
|
|
|
DataEnviorment environmentConfig = CommonUtils.GetEnvironmentConfig(levelInfo.Environment);
|
|
|
|
|
|
imageEnviroment.sprite = AssetManager.Instance.GetPreLoadResult<Sprite>(environmentConfig.Icon);
|
|
|
|
|
|
textEnviroment.text = CommonUtils.GetLocalizeText(environmentConfig.NameLocal);
|
|
|
|
|
|
|
|
|
|
|
|
DataEnWeather weatherConfig = CommonUtils.GetWeatherConfig(levelInfo.Cfg.LevelWeather);
|
|
|
|
|
|
imageWeather.sprite = AssetManager.Instance.GetPreLoadResult<Sprite>(weatherConfig.Icon);
|
|
|
|
|
|
textWeather.text = CommonUtils.GetLocalizeText(weatherConfig.NameLocal);
|
|
|
|
|
|
|
|
|
|
|
|
DataDayNightProp dayNightConfig = CommonUtils.GetDayNightConfig(levelInfo.Cfg.LevelTime);
|
|
|
|
|
|
imageTime.sprite = AssetManager.Instance.GetPreLoadResult<Sprite>(dayNightConfig.Icon);
|
|
|
|
|
|
textTime.text = CommonUtils.GetLocalizeText(dayNightConfig.NameLocal);
|
|
|
|
|
|
|
|
|
|
|
|
goStarRoot.IsScaleShow(true);
|
|
|
|
|
|
goMainInfo.IsScaleShow(true);
|
|
|
|
|
|
goWarInfo.IsScaleShow(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case E_ChapterType.Resource:
|
|
|
|
|
|
{
|
|
|
|
|
|
goStarRoot.IsScaleShow(false);
|
|
|
|
|
|
goMainInfo.IsScaleShow(false);
|
|
|
|
|
|
goWarInfo.IsScaleShow(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case E_ChapterType.Storyline:
|
|
|
|
|
|
{
|
|
|
|
|
|
goStarRoot.IsScaleShow(false);
|
|
|
|
|
|
goMainInfo.IsScaleShow(false);
|
|
|
|
|
|
goWarInfo.IsScaleShow(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case E_ChapterType.War:
|
|
|
|
|
|
{
|
|
|
|
|
|
goStarRoot.IsScaleShow(false);
|
|
|
|
|
|
goMainInfo.IsScaleShow(false);
|
|
|
|
|
|
goWarInfo.IsScaleShow(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"未处理类型{info.ChapterInfo.Cfg.Type}");
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
|
|
|
|
|
IsScaleShow = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnClick()
|
|
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
levelAction?.Invoke(levelInfo);
|
2024-04-07 16:22:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 循环列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private RecycleView recycleView;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 关卡信息列表
|
|
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private List<LevelInfo> listLevelInfo;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 关卡字典
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private readonly Dictionary<int, LevelItem> dicLevelItem = new();
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private readonly Action<LevelInfo> levelAction;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
public LevelList(GameObject root, Action<LevelInfo> level) : base(root)
|
2024-05-06 16:46:00 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
levelAction = level;
|
2024-05-06 16:46:00 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
recycleView = GetComponent<RecycleView>("RecycleView");
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
recycleView.Init(RefreshCell);
|
2024-04-07 16:22:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
public void SetInfo(List<LevelInfo> listInfo)
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
listLevelInfo = listInfo;
|
|
|
|
|
|
if (null == listLevelInfo)
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
DebugUtil.LogError("无效的关卡信息列表");
|
|
|
|
|
|
return;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
recycleView.ShowList(listLevelInfo.Count);
|
|
|
|
|
|
|
|
|
|
|
|
IsScaleShow = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private void RefreshCell(GameObject cell, int index)
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (!dicLevelItem.TryGetValue(cell.GetInstanceID(), out LevelItem levelItem))
|
|
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
levelItem = new(cell, OnLevel);
|
2024-04-07 16:22:58 +08:00
|
|
|
|
dicLevelItem.Add(cell.GetInstanceID(), levelItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
if (null == listLevelInfo)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2024-04-07 16:22:58 +08:00
|
|
|
|
if (index < 0 || index >= listLevelInfo.Count)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
levelItem.SetInfo(listLevelInfo[index], index, index == listLevelInfo.Count - 1);
|
2024-04-07 16:22:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 点击关卡
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// <param name="levelInfo"></param>
|
|
|
|
|
|
private void OnLevel(LevelInfo levelInfo)
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
levelAction?.Invoke(levelInfo);
|
2024-04-07 16:22:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 电池
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private class Batterie : UIGameObjectWrapper
|
2024-04-07 16:22:58 +08:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 电池电量
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 入口
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// <param name="batteryPower"></param>
|
|
|
|
|
|
public void SetInfo()
|
|
|
|
|
|
{
|
|
|
|
|
|
int showCount = Mathf.CeilToInt(listBatteryPower.Count * DeviceHelper.GetBatteryLevel());
|
|
|
|
|
|
if (showCount >= listBatteryPower.Count)
|
|
|
|
|
|
showCount = listBatteryPower.Count - 1;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < listBatteryPower.Count; ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
listBatteryPower[i].IsScaleShow(i == showCount);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IsScaleShow = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// WIFI
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private class NetSignal : UIGameObjectWrapper
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly int[] signalThreshold = new int[] { 30, 60, 120, 200, 300 };//网络延迟阶梯值
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// Wifi信号
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private readonly List<GameObject> listWifi;
|
|
|
|
|
|
|
|
|
|
|
|
public NetSignal(GameObject root) : base(root)
|
|
|
|
|
|
{
|
|
|
|
|
|
listWifi = new(GoRoot.transform.childCount);
|
|
|
|
|
|
for (int i = 0; i < GoRoot.transform.childCount; ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
listWifi.Add(GoRoot.transform.GetChild(i).gameObject);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 入口
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// <param name="networkSignal"></param>
|
|
|
|
|
|
public void SetInfo(float networkSignal)
|
|
|
|
|
|
{
|
|
|
|
|
|
int showCount = Mathf.CeilToInt(listWifi.Count * networkSignal);
|
|
|
|
|
|
for (int i = 0; i < listWifi.Count; ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
listWifi[i].IsScaleShow(i + 1 == showCount);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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-07 16:22:58 +08:00
|
|
|
|
}
|
2024-09-03 19:22:47 +08:00
|
|
|
|
#endregion
|
2023-10-26 20:20:11 +08:00
|
|
|
|
|
2024-05-06 16:46:00 +08:00
|
|
|
|
#region UI
|
|
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 返回
|
2024-05-06 16:46:00 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
private Button buttonBack;
|
|
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 主页
|
2024-05-06 16:46:00 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
private Button buttonHome;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 模式根节点
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private GameObject goModeRoot;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 章节根节点
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private GameObject goChapterRoot;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 关卡根节点
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private GameObject goLevelRoot;
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 私有字段
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 模式按钮字典
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private readonly Dictionary<E_ChapterType, ModeButton> dicModeButton = new();
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 章节列表字典
|
2024-07-10 18:23:40 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private readonly Dictionary<E_ChapterType, ChapterBase> dicChapter = new();
|
2024-07-10 18:23:40 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 选关UI字典
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private readonly Dictionary<E_ChapterType, SelectLevelBase> dicSelectLevel = new();
|
2024-04-02 18:48:02 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 货币栏
|
2024-04-02 18:48:02 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private UI_CurrencyList currencyList;
|
2024-04-02 18:48:02 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 是否隐藏
|
2024-04-02 18:48:02 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private bool isHide;
|
2024-04-02 18:48:02 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 计时器
|
2024-04-02 18:48:02 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
private float timer;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 是否显示选关
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private bool isShowSelectLevel;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 当前选择模式类型
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private E_ChapterType curMode;
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2024-04-08 15:09:59 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 是否显示选关卡
|
2024-04-08 15:09:59 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
public bool IsShowSelectLevel
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return isShowSelectLevel; }
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
goModeRoot.IsScaleShow(!value);
|
|
|
|
|
|
goChapterRoot.IsScaleShow(!value);
|
|
|
|
|
|
goLevelRoot.IsScaleShow(value);
|
2024-08-08 12:19:32 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
isShowSelectLevel = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-04-10 16:20:58 +08:00
|
|
|
|
|
2024-08-28 14:53:39 +08:00
|
|
|
|
public override void PreLoad(object data = null)
|
2024-02-22 19:47:38 +08:00
|
|
|
|
{
|
2024-08-28 14:53:39 +08:00
|
|
|
|
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
|
|
|
|
{
|
2024-05-06 16:46:00 +08:00
|
|
|
|
buttonBack = GetComponent<Button>("Button_Back/Button_back");
|
|
|
|
|
|
buttonHome = GetComponent<Button>("Button_Back/Button_Home");
|
2024-04-22 15:29:20 +08:00
|
|
|
|
currencyList = GetComponent<UI_CurrencyList>("UI_CurrencyList");
|
2024-09-03 19:22:47 +08:00
|
|
|
|
goModeRoot = FindObj("UI_ModeSelect");
|
|
|
|
|
|
goChapterRoot = FindObj("UI_LiuHaiRight");
|
|
|
|
|
|
goLevelRoot = FindObj("UI_LevelSelect");
|
|
|
|
|
|
|
|
|
|
|
|
#region 模式按钮
|
|
|
|
|
|
dicModeButton.Add(E_ChapterType.Main, new ModeButton(FindObj("UI_ModeSelect/UI_MainMission"), E_ChapterType.Main, OnMode));
|
|
|
|
|
|
dicModeButton.Add(E_ChapterType.Resource, new ModeButton(FindObj("UI_ModeSelect/UI_ResourcesCollection"), E_ChapterType.Resource, OnMode));
|
|
|
|
|
|
dicModeButton.Add(E_ChapterType.Storyline, new ModeButton(FindObj("UI_ModeSelect/UI_Story"), E_ChapterType.Storyline, OnMode));
|
|
|
|
|
|
dicModeButton.Add(E_ChapterType.War, new ModeButton(FindObj("UI_ModeSelect/UI_War"), E_ChapterType.War, OnMode));
|
|
|
|
|
|
#endregion
|
2024-04-02 19:50:36 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
#region 章节
|
|
|
|
|
|
dicChapter.Add(E_ChapterType.Main, new MainChapter(FindObj("UI_LiuHaiRight/Image_MainMission"), OnChapter));
|
|
|
|
|
|
dicChapter.Add(E_ChapterType.Resource, new ResourceChapter(FindObj("UI_LiuHaiRight/Image_ResourcesCollection"), OnChapter));
|
|
|
|
|
|
dicChapter.Add(E_ChapterType.Storyline, new StoryChapter(FindObj("UI_LiuHaiRight/Image_Story"), OnChapter));
|
|
|
|
|
|
dicChapter.Add(E_ChapterType.War, new WarChapter(FindObj("UI_LiuHaiRight/Image_War"), OnChapter));
|
|
|
|
|
|
#endregion
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
#region 选关
|
|
|
|
|
|
LevelList levelList = new(FindObj("UI_LevelSelect/UI_LevelPoints"), OnLevel);
|
|
|
|
|
|
dicSelectLevel.Add(E_ChapterType.Main, new MainSelectLevel(FindObj("UI_LevelSelect/UI_MainMission"), levelList));
|
|
|
|
|
|
dicSelectLevel.Add(E_ChapterType.Resource, new ResourceSelectLevel(FindObj("UI_LevelSelect/UI_ResourcesCollection"), levelList));
|
|
|
|
|
|
dicSelectLevel.Add(E_ChapterType.Storyline, new StorySelectLevel(FindObj("UI_LevelSelect/UI_Story"), levelList));
|
|
|
|
|
|
dicSelectLevel.Add(E_ChapterType.War, new WarSelectLevel(FindObj("UI_LevelSelect/UI_War"), levelList));
|
|
|
|
|
|
#endregion
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
2024-05-06 16:46:00 +08:00
|
|
|
|
currencyList.SetData(GLConfig.Inst.data.GoldItemId, GLConfig.Inst.data.DiamondItemId, GLConfig.Inst.data.EnergyPointID);
|
2024-09-03 19:22:47 +08:00
|
|
|
|
curMode = E_ChapterType.Count;
|
2024-04-22 15:29:20 +08:00
|
|
|
|
|
2024-05-06 16:46:00 +08:00
|
|
|
|
BindButton(buttonBack, OnBack);
|
|
|
|
|
|
BindButton(buttonHome, OnHome);
|
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-09-03 19:22:47 +08:00
|
|
|
|
if (isHide)
|
2024-08-08 12:19:32 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
isHide = false;
|
2024-08-08 12:19:32 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-05-31 16:51:38 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
base.OnShowWindow(data);
|
2024-04-22 15:29:20 +08:00
|
|
|
|
|
2024-05-24 13:28:03 +08:00
|
|
|
|
if (data is LevelInfo levelInfo)
|
2024-09-02 18:51:47 +08:00
|
|
|
|
OnMode(levelInfo.ChapterInfo.Cfg.Type);
|
2024-09-03 19:22:47 +08:00
|
|
|
|
else
|
|
|
|
|
|
OnMode(E_ChapterType.Main);
|
2024-05-24 13:28:03 +08:00
|
|
|
|
|
2024-04-22 15:29:20 +08:00
|
|
|
|
currencyList.Refresh();
|
2024-04-02 18:48:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-08 12:19:32 +08:00
|
|
|
|
protected override void OnHideWindow()
|
|
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
isHide = true;
|
2024-08-08 12:19:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
if (dicChapter.TryGetValue(curMode, out ChapterBase chapterBase))
|
|
|
|
|
|
{
|
|
|
|
|
|
chapterBase.RefreshBatterie();
|
|
|
|
|
|
chapterBase.RefreshNetSignal();
|
|
|
|
|
|
}
|
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-08-28 14:53:39 +08:00
|
|
|
|
public override 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-08-28 14:53:39 +08:00
|
|
|
|
CommonUtils.PreLoadOrUnloadEnvironmentWeatherDayNightIcon(false);
|
2024-05-06 16:46:00 +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>
|
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-09-03 19:22:47 +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();
|
2024-09-03 19:22:47 +08:00
|
|
|
|
}*/
|
2023-10-26 20:20:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
#region 回调方法
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 返回
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private void OnBack()
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
if (IsShowSelectLevel)
|
|
|
|
|
|
IsShowSelectLevel = false;
|
|
|
|
|
|
else
|
|
|
|
|
|
OnHome();
|
2023-10-26 20:20:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 主页
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
private void OnHome()
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
CommonUtils.ChangeUIScene(Constants.MAIN_SCENE_PATH);
|
|
|
|
|
|
CloseWindow();
|
|
|
|
|
|
UIManager.Instance.ShowAllUI();
|
2023-10-26 20:20:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 选择模式
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="chapterType"></param>
|
|
|
|
|
|
private void OnMode(E_ChapterType type)
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
if (curMode == type)
|
2024-01-08 19:39:41 +08:00
|
|
|
|
return;
|
2024-01-09 14:00:53 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
if (dicModeButton.TryGetValue(curMode, out ModeButton oldModeButton))
|
|
|
|
|
|
oldModeButton.IsSelect = false;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
if (dicChapter.TryGetValue(curMode, out ChapterBase oldChapterBase))
|
|
|
|
|
|
oldChapterBase.IsScaleShow = false;
|
2024-01-18 19:12:39 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
if (dicSelectLevel.TryGetValue(curMode, out SelectLevelBase oldSelectLevelBase))
|
|
|
|
|
|
oldSelectLevelBase.IsScaleShow = false;
|
2023-10-26 20:20:11 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
curMode = type;
|
2024-01-18 19:12:39 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
if (dicModeButton.TryGetValue(curMode, out ModeButton newModeButton))
|
|
|
|
|
|
newModeButton.IsSelect = true;
|
2024-01-19 19:20:05 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
if (dicChapter.TryGetValue(curMode, out ChapterBase newChapterBase))
|
|
|
|
|
|
newChapterBase.SetInfo();
|
2024-01-18 18:59:33 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
switch (curMode)
|
2024-07-05 23:14:53 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
case E_ChapterType.Main:
|
|
|
|
|
|
{
|
|
|
|
|
|
IsShowSelectLevel = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
2024-07-10 18:23:40 +08:00
|
|
|
|
}
|
2023-10-26 20:20:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// 选择章节
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// <param name="type"></param>
|
2024-04-07 16:22:58 +08:00
|
|
|
|
private void OnChapter(ChapterInfo chapterInfo)
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
if (!dicSelectLevel.TryGetValue(chapterInfo.Cfg.Type, out SelectLevelBase selectLevelBase))
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"不存在{chapterInfo.Cfg.Type}的关卡选择面板");
|
2024-06-13 15:05:32 +08:00
|
|
|
|
return;
|
2024-09-03 19:22:47 +08:00
|
|
|
|
}
|
2024-06-13 15:05:32 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
selectLevelBase.SetInfo(chapterInfo);
|
2023-10-26 20:20:11 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
IsShowSelectLevel = true;
|
2024-04-07 16:22:58 +08:00
|
|
|
|
}
|
2023-10-26 20:20:11 +08:00
|
|
|
|
|
2024-04-07 16:22:58 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 点击关卡
|
|
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
/// <param name="levelInfo"></param>
|
2024-04-07 16:22:58 +08:00
|
|
|
|
private async void OnLevel(LevelInfo levelInfo)
|
|
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
if (null == levelInfo)
|
2023-10-26 20:20:11 +08:00
|
|
|
|
return;
|
|
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
if (E_ChapterType.Storyline == levelInfo.ChapterInfo.Cfg.Type)
|
2024-09-02 14:55:43 +08:00
|
|
|
|
LevelManager.Instance.TryEnterLevel(levelInfo.Cfg.Id);
|
2024-04-07 16:22:58 +08:00
|
|
|
|
else
|
|
|
|
|
|
await UI_LevelDetailController.Open(levelInfo);
|
|
|
|
|
|
}
|
2024-04-22 15:29:20 +08:00
|
|
|
|
#endregion
|
2024-01-18 19:12:39 +08:00
|
|
|
|
}
|