using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using cfg.FightCfg;
using cfg.LevelCfg;
using Cysharp.Threading.Tasks;
using Framework;
using Gameplay;
using Gameplay.Common;
using Gameplay.Level;
using PhxhSDK;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using Button = UnityEngine.UI.Button;
using Constants = Framework.Constants;
using Image = UnityEngine.UI.Image;
public class UI_LevelSelectController : UIWindow
{
//UI GameObj
///Auto Gen Start///
public Button Button_Back;
public TMP_Text Text_Back;
public Button Button_Home;
//public Button Button_MainLevel;
public Image Image_MainlevelLogo;
public Button Button_DungeonlEVEL;
public Image Image_TextBG;
public TMP_Text Text_MainLevel;
public TMP_Text Text_Campaignnode;
public Image Image_BlackBar;
public TMP_Text Text_MainLevelProcess;
public TMP_Text Text_MainLevelNum;
public TMP_Text Text_MainLevelName;
public Image Image_Seperate;
public Image Image_LastRect;
public TMP_Text Text_LastLevel;
public TMP_Text Text_LastLevelNum;
public TMP_Text Text_LastLevelName;
public Button Button_BranchLevel;
public Image Image_ChapterBG;
public TMP_Text Text_Title;
public Image Image_FractionlLogo;
public Image Image_LevelBG;
public TMP_Text Text_ChapterName;
public TMP_Text Text_ChapterNum;
public Image Image_ProcessBG;
public Image Image_ProcessBar;
public Image Image_Reward01;
public Image Image_Reward02;
public Image Image_Reward03;
public Button Button_GetAll;
public TMP_Text Text_StarNum;
public Image Image_Start;
public Image Image_ModeBG;
public Image Image_SelectBG;
public Button Button_Plot;
public TMP_Text Text_Read;
public Image Image_Pot;
public Button Button_Easy;
public TMP_Text Text_Simple;
public Button Button_Hard;
public TMP_Text Text_Hard;
public Image Image_pot;
public TMP_Text Text_Mode;
///Auto Gen End///
///
/// 打开关卡选择界面
///
///
public static async UniTask Open()
{
CommonUtils.ChangeUIScene(Constants.UI_LEVEL_SELECTED_SCENE_PATH); // 切换到关卡选择场景
return await UIManager.Instance.OpenWindow(UINameConst.UI_LevelSelect);
}
#region 类
///
/// 电池
///
private class Batterie : UIGameObjectWrapper
{
///
/// 电池电量
///
private readonly List 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);
}
}
///
/// 入口
///
///
public void SetInfo(float batteryPower)
{
int showCount = Mathf.CeilToInt(listBatteryPower.Count * batteryPower);
for (int i = 0; i < listBatteryPower.Count; ++i)
{
listBatteryPower[i].IsScaleShow(i + 1 == showCount);
}
}
}
///
/// WIFI
///
private class NetSignal : UIGameObjectWrapper
{
///
/// Wifi信号
///
private readonly List 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);
}
}
///
/// 入口
///
///
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);
}
}
}
///
/// 选择面板基类
///
private abstract class BaseChoosePanel : UIGameObjectWrapper
{
protected ScrollRect scrollRect;
///
/// 章节类型
///
private LevelChapterType chapterType;
///
/// 章节信息
///
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();
}
///
/// 模式选择面板
///
private class ModeChoosePanel : BaseChoosePanel
{
///
/// 模式选项
///
private class ModeItem : UIGameObjectWrapper
{
#region UI
///
/// 模式名
///
private TMP_Text textModeName;
///
/// 当前关卡名
///
private TMP_Text textCurLevelName;
///
/// 当前关卡编号
///
private TMP_Text textCurLevelNum;
///
/// 上一次关卡名
///
private TMP_Text textLastLevelName;
///
/// 上一次关卡编号
///
private TMP_Text textLastLevelNum;
///
/// 当前关卡
///
private GameObject goCurLevel;
///
/// 上一次关卡
///
private GameObject goLastLevel;
///
/// 选择章节按钮
///
private Button buttonSelectChapter;
///
/// 进入当前关卡按钮
///
private Button buttonCurLevel;
///
/// 进入上一次关卡按钮
///
private Button buttonLastLevel;
#endregion
///
/// 关卡章节类型
///
private readonly LevelChapterType type;
///
/// 点击模式
///
private readonly Action mode;
///
/// 点击关卡
///
private readonly Action level;
private LevelInfo curLevelInfo;
private LevelInfo lastLevelInfo;
public ModeItem(GameObject root, LevelChapterType levelChapterType, Action modeAction, Action levelAction) : base(root)
{
type = levelChapterType;
mode = modeAction;
level = levelAction;
buttonSelectChapter = GoRoot.GetComponent