2024-01-29 16:30:26 +08:00
|
|
|
|
using cfg.ActorCfg;
|
|
|
|
|
|
using cfg.LevelCfg;
|
2024-03-28 18:58:39 +08:00
|
|
|
|
using Cysharp.Threading.Tasks;
|
2024-01-29 16:30:26 +08:00
|
|
|
|
using Framework;
|
|
|
|
|
|
using Gameplay;
|
|
|
|
|
|
using Gameplay.Common;
|
|
|
|
|
|
using Gameplay.Level;
|
|
|
|
|
|
using PhxhSDK;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using TMPro;
|
|
|
|
|
|
using UnityEngine;
|
2024-03-28 18:58:39 +08:00
|
|
|
|
using UnityEngine.UI;
|
2024-01-29 16:30:26 +08:00
|
|
|
|
using Button = UnityEngine.UI.Button;
|
|
|
|
|
|
using Image = UnityEngine.UI.Image;
|
2024-02-22 19:47:38 +08:00
|
|
|
|
using Object = UnityEngine.Object;
|
2024-01-29 16:30:26 +08:00
|
|
|
|
|
2024-02-20 15:54:14 +08:00
|
|
|
|
public class UI_LevelDetailController : UIWindow
|
2024-01-29 16:30:26 +08:00
|
|
|
|
{
|
2024-02-22 19:47:38 +08:00
|
|
|
|
//UI GameObj
|
|
|
|
|
|
///Auto Gen Start///
|
|
|
|
|
|
public Image Image_BG;
|
|
|
|
|
|
|
|
|
|
|
|
public Button Button_Close;
|
|
|
|
|
|
public TMP_Text Text_LevelNum;
|
|
|
|
|
|
public TMP_Text Text_LevelName;
|
|
|
|
|
|
public Image Image_Shadow;
|
|
|
|
|
|
public Image Image_Misson;
|
|
|
|
|
|
public Image Image_Weather;
|
|
|
|
|
|
public Image Image_DayOrNight;
|
|
|
|
|
|
public TMP_Text Text_DayOrNight;
|
|
|
|
|
|
public Image Image_Seperate;
|
|
|
|
|
|
public Image Image_weather;
|
|
|
|
|
|
public TMP_Text Text_WeatherAndLand01;
|
|
|
|
|
|
public Image Image_environment;
|
|
|
|
|
|
public TMP_Text Text_WeatherAndLand02;
|
|
|
|
|
|
public Image Image_Buff;
|
|
|
|
|
|
public TMP_Text Text_Buff;
|
|
|
|
|
|
public TMP_Text Text_GetReward;
|
|
|
|
|
|
public TMP_Text Text_AlreadyGet;
|
|
|
|
|
|
|
|
|
|
|
|
public TMP_Text Text_Sweep;
|
|
|
|
|
|
public Image Image_SweepNum;
|
|
|
|
|
|
public TMP_Text Text_Num;
|
|
|
|
|
|
public Button Button_Minus;
|
|
|
|
|
|
public Button Button_Plus;
|
|
|
|
|
|
public Button Button_StartSweep;
|
|
|
|
|
|
public Image Image_physicalBG;
|
|
|
|
|
|
public Image Image_Physical;
|
|
|
|
|
|
public TMP_Text Text_PhysicalNum;
|
|
|
|
|
|
public TMP_Text Text_StartSweep;
|
|
|
|
|
|
public Button Button_Cancel;
|
|
|
|
|
|
public TMP_Text Text_Cancel;
|
|
|
|
|
|
public Image Image_StartFight;
|
|
|
|
|
|
public TMP_Text Text_StartFight;
|
|
|
|
|
|
|
2024-02-23 16:13:25 +08:00
|
|
|
|
///Auto Gen End///
|
2024-03-06 14:04:57 +08:00
|
|
|
|
|
2024-03-28 18:58:39 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 打开关卡详情界面
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static async UniTask<UIWindow> Open(LevelInfo levelInfo)
|
|
|
|
|
|
{
|
2024-08-13 14:29:50 +08:00
|
|
|
|
await CommonUtils.CaptureScreenshot();
|
2024-03-28 18:58:39 +08:00
|
|
|
|
|
2024-05-16 12:40:15 +08:00
|
|
|
|
return await UIManager.Instance.CreateAndOpenWindow(UINameConst.UI_LevelDetail, levelInfo);
|
2024-03-28 18:58:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 高斯模糊遮罩
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private RawImage rawImageGaussianBlurMask;
|
2024-04-02 13:10:37 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 循环列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private RecycleView recycleView;
|
|
|
|
|
|
private ScrollRect _numScrollView;
|
2024-03-06 14:04:57 +08:00
|
|
|
|
|
2024-03-08 12:20:00 +08:00
|
|
|
|
private UIScrollFocusHelper _scrollFocusCmp;
|
|
|
|
|
|
|
2024-03-06 14:04:57 +08:00
|
|
|
|
private GameObject _numItem;
|
2024-03-21 16:08:31 +08:00
|
|
|
|
private GameObject _maskObj;
|
2024-03-06 14:04:57 +08:00
|
|
|
|
|
|
|
|
|
|
private const int MAX_SWEEPNUM = 10;
|
2024-03-08 12:20:00 +08:00
|
|
|
|
private const int SWEEP_NUM_CONST = 3; //扫荡列表前后默认item数量
|
2024-02-23 16:13:25 +08:00
|
|
|
|
private class RewardShowItem
|
|
|
|
|
|
{
|
|
|
|
|
|
public RewardItem rewardItem;
|
|
|
|
|
|
|
|
|
|
|
|
public ERewardType rewardType;
|
|
|
|
|
|
|
|
|
|
|
|
public bool hasGet;
|
|
|
|
|
|
|
|
|
|
|
|
public RewardShowItem(RewardItem rewardItem, ERewardType rewardType, bool hasGet)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.rewardItem = rewardItem;
|
|
|
|
|
|
this.rewardType = rewardType;
|
|
|
|
|
|
this.hasGet = hasGet;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-02-22 19:47:38 +08:00
|
|
|
|
|
2024-04-02 13:10:37 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 通关奖励字典
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private readonly Dictionary<int, GenericItem_PassReward> dicPassReward = new();
|
2024-02-22 19:47:38 +08:00
|
|
|
|
private LevelInfo _currLevelInfo;
|
2024-02-23 16:13:25 +08:00
|
|
|
|
private Button _fightBtn;
|
2024-01-29 16:30:26 +08:00
|
|
|
|
|
2024-02-23 16:13:25 +08:00
|
|
|
|
private int _sweepNum = -1;
|
|
|
|
|
|
|
|
|
|
|
|
private int SweepNum
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _sweepNum;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_sweepNum != value)
|
|
|
|
|
|
{
|
|
|
|
|
|
_sweepNum = value;
|
|
|
|
|
|
if (_sweepNum < 0)
|
|
|
|
|
|
_sweepNum = 0;
|
2024-03-04 18:13:35 +08:00
|
|
|
|
//Text_Num.text = _sweepNum.ToString();
|
2024-03-21 16:08:31 +08:00
|
|
|
|
_SetCostEnergyItemCount();
|
2024-02-23 16:13:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private List<RewardShowItem> _allRewards = new();
|
2024-02-22 19:47:38 +08:00
|
|
|
|
|
2024-02-20 15:54:14 +08:00
|
|
|
|
//private int _currTeamIndex = -1;
|
2024-01-29 16:30:26 +08:00
|
|
|
|
private Team _currTeam;
|
|
|
|
|
|
private int _teamIndexMax;
|
2024-02-22 19:47:38 +08:00
|
|
|
|
|
2024-01-29 16:30:26 +08:00
|
|
|
|
// deal with input data
|
|
|
|
|
|
public override void PreLoad(object data)
|
|
|
|
|
|
{
|
2024-02-23 16:13:25 +08:00
|
|
|
|
_currLevelInfo = data != null?data as LevelInfo : _currLevelInfo;
|
2024-02-22 19:47:38 +08:00
|
|
|
|
CommonUtils.PreLoadOrUnloadEnvironmentWeatherDayNightIcon(true);
|
2024-01-29 16:30:26 +08:00
|
|
|
|
}
|
2024-02-22 19:47:38 +08:00
|
|
|
|
|
|
|
|
|
|
// Use this for initialization
|
|
|
|
|
|
public override void OnInit()
|
|
|
|
|
|
{
|
|
|
|
|
|
//bind UI GameObj
|
|
|
|
|
|
UI_LevelDetailBinder.GetComponents(this);
|
2024-03-28 18:58:39 +08:00
|
|
|
|
|
|
|
|
|
|
rawImageGaussianBlurMask = GetComponent<RawImage>("GaussianBlurMask");
|
2024-04-02 13:10:37 +08:00
|
|
|
|
recycleView = GetComponent<RecycleView>("Image_BG/RewardAndSweep/Text_GetReward/RecycleView");
|
2024-02-23 16:13:25 +08:00
|
|
|
|
_fightBtn = GetComponent<Button>("Image_BG/Image_StartFight");
|
2024-02-22 19:47:38 +08:00
|
|
|
|
Text_LevelNum = GetComponent<TMP_Text>("Image_BG/Top/Text_LevelNum");
|
2024-03-06 17:47:03 +08:00
|
|
|
|
// _numScrollView = GetComponent<UnityEngine.UI.ScrollRect>("Image_BG/RewardAndSweep/Text_Sweep/SweepNum/ScrollView");
|
|
|
|
|
|
// _numItem = FindObj("Image_BG/RewardAndSweep/Text_Sweep/SweepNum/ItemNum");
|
2024-03-21 16:08:31 +08:00
|
|
|
|
_maskObj = FindObj("Image_BG/ImageMask");
|
2024-03-28 18:58:39 +08:00
|
|
|
|
|
2024-08-15 13:31:51 +08:00
|
|
|
|
rawImageGaussianBlurMask.texture = CommonUtils.GetScreenTexture2D();
|
2024-03-28 18:58:39 +08:00
|
|
|
|
|
2024-03-21 16:08:31 +08:00
|
|
|
|
//test
|
|
|
|
|
|
_maskObj.gameObject.SetActive(true);
|
2024-03-26 19:28:14 +08:00
|
|
|
|
|
|
|
|
|
|
var dayBtnEx = Image_DayOrNight.GetComponent<UIButtonEx>();
|
|
|
|
|
|
var weatherBtnEx = Image_weather.GetComponent<UIButtonEx>();
|
|
|
|
|
|
var environmentBtnEx = Image_environment.GetComponent<UIButtonEx>();
|
2024-04-02 13:10:37 +08:00
|
|
|
|
|
|
|
|
|
|
recycleView.Init(RefreshRewardItem);
|
|
|
|
|
|
|
2024-01-29 16:30:26 +08:00
|
|
|
|
BindButton(Button_Close, CloseOnClick);
|
2024-02-22 19:47:38 +08:00
|
|
|
|
BindButton(Button_Cancel, CloseOnClick);
|
|
|
|
|
|
BindButton(GetComponent<Button>("emptyForAllCloseBtn"), CloseOnClick);
|
2024-02-23 16:13:25 +08:00
|
|
|
|
BindButton(_fightBtn, FightOnClick);
|
|
|
|
|
|
BindButton(Button_Plus, PlusOnClick);
|
|
|
|
|
|
BindButton(Button_Minus, MinusOnClick);
|
2024-03-26 19:28:14 +08:00
|
|
|
|
|
|
|
|
|
|
dayBtnEx.AddLongPressListener(OnLongPressDay);
|
|
|
|
|
|
dayBtnEx.AddClickListener(OnPointUpDay);
|
|
|
|
|
|
weatherBtnEx.AddLongPressListener(OnLongPressWeather);
|
|
|
|
|
|
weatherBtnEx.AddClickListener(OnPointUpWeather);
|
|
|
|
|
|
environmentBtnEx.AddLongPressListener(OnLongPressEnvironment);
|
|
|
|
|
|
environmentBtnEx.AddClickListener(OnPointUpEnvironment);
|
2024-02-22 19:47:38 +08:00
|
|
|
|
}
|
2024-01-29 16:30:26 +08:00
|
|
|
|
|
2024-03-08 20:00:56 +08:00
|
|
|
|
private async void FightOnClick()
|
2024-01-29 16:30:26 +08:00
|
|
|
|
{
|
2024-04-11 12:50:48 +08:00
|
|
|
|
await UI_TeamAndSkillSelectController.Open(_currLevelInfo);
|
2024-01-29 16:30:26 +08:00
|
|
|
|
}
|
2024-02-22 19:47:38 +08:00
|
|
|
|
|
2024-01-29 16:30:26 +08:00
|
|
|
|
private void OnEnterLevelFinished()
|
|
|
|
|
|
{
|
|
|
|
|
|
CloseWindow();
|
|
|
|
|
|
}
|
2024-02-22 19:47:38 +08:00
|
|
|
|
|
2024-01-29 16:30:26 +08:00
|
|
|
|
private void CloseOnClick()
|
|
|
|
|
|
{
|
2024-02-22 19:47:38 +08:00
|
|
|
|
CloseWindow();
|
2024-01-29 16:30:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-02-23 16:13:25 +08:00
|
|
|
|
private void PlusOnClick()
|
|
|
|
|
|
{
|
|
|
|
|
|
SweepNum++;
|
2024-03-08 12:20:00 +08:00
|
|
|
|
_scrollFocusCmp.ChangeIndex(true);
|
2024-02-23 16:13:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void MinusOnClick()
|
|
|
|
|
|
{
|
|
|
|
|
|
SweepNum --;
|
2024-03-08 12:20:00 +08:00
|
|
|
|
_scrollFocusCmp.ChangeIndex(false);
|
2024-03-26 19:28:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnLongPressDay()
|
|
|
|
|
|
{
|
|
|
|
|
|
Image_Buff.gameObject.SetActive(true);
|
|
|
|
|
|
var dayNightConfig = CommonUtils.GetDayNightConfig(_currLevelInfo.DayNightType);
|
|
|
|
|
|
var txtName = CommonUtils.GetLocalizeText(dayNightConfig.NameLocal);
|
|
|
|
|
|
var txtDesc = CommonUtils.GetLocalizeText(dayNightConfig.DescLocal);
|
|
|
|
|
|
var txtContent = txtName + ": " + txtDesc;
|
|
|
|
|
|
Text_Buff.text = txtContent;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnLongPressWeather()
|
|
|
|
|
|
{
|
|
|
|
|
|
Image_Buff.gameObject.SetActive(true);
|
|
|
|
|
|
var weatherConfig = CommonUtils.GetWeatherConfig(_currLevelInfo.WeatherType);
|
|
|
|
|
|
var txtName = CommonUtils.GetLocalizeText(weatherConfig.NameLocal);
|
|
|
|
|
|
var txtDesc = CommonUtils.GetLocalizeText(weatherConfig.DescLocal);
|
|
|
|
|
|
var txtContent = txtName + ": " + txtDesc;
|
|
|
|
|
|
Text_Buff.text = txtContent;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnLongPressEnvironment()
|
|
|
|
|
|
{
|
|
|
|
|
|
Image_Buff.gameObject.SetActive(true);
|
|
|
|
|
|
var environmentConfig = CommonUtils.GetEnvironmentConfig(_currLevelInfo.EnvironmentType);
|
|
|
|
|
|
var txtName = CommonUtils.GetLocalizeText(environmentConfig.NameLocal);
|
|
|
|
|
|
var txtDesc = CommonUtils.GetLocalizeText(environmentConfig.DescLocal);
|
|
|
|
|
|
var txtContent = txtName + ": " + txtDesc;
|
|
|
|
|
|
Text_Buff.text = txtContent;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnPointUpDay()
|
|
|
|
|
|
{
|
|
|
|
|
|
Image_Buff.gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnPointUpWeather()
|
|
|
|
|
|
{
|
|
|
|
|
|
Image_Buff.gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnPointUpEnvironment()
|
|
|
|
|
|
{
|
|
|
|
|
|
Image_Buff.gameObject.SetActive(false);
|
2024-02-23 16:13:25 +08:00
|
|
|
|
}
|
2024-03-21 16:08:31 +08:00
|
|
|
|
|
|
|
|
|
|
private void _SetCostEnergyItemCount()
|
|
|
|
|
|
{
|
|
|
|
|
|
var costItems = _currLevelInfo.CostItems;
|
|
|
|
|
|
var itemCount = costItems.Find(itemCount => itemCount.Id == GLConfig.Inst.data.EnergyPointID);
|
|
|
|
|
|
if (itemCount != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Text_PhysicalNum.text = itemCount.Count.ToString();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Text_PhysicalNum.text = "0";
|
|
|
|
|
|
}
|
2024-02-23 16:13:25 +08:00
|
|
|
|
|
2024-01-29 16:30:26 +08:00
|
|
|
|
//invoke when open window
|
|
|
|
|
|
protected override void OnShowWindow(object data)
|
2024-02-22 19:47:38 +08:00
|
|
|
|
{
|
2024-05-31 19:02:13 +08:00
|
|
|
|
base.OnShowWindow(data);
|
|
|
|
|
|
|
2024-02-23 16:13:25 +08:00
|
|
|
|
SweepNum = 0;
|
2024-01-29 16:30:26 +08:00
|
|
|
|
RefreshUI();
|
2024-02-22 19:47:38 +08:00
|
|
|
|
RefreshAllRewardsData();
|
|
|
|
|
|
SetScrollView();
|
2024-04-02 13:10:37 +08:00
|
|
|
|
recycleView.ShowList(_allRewards.Count);
|
2024-03-06 14:04:57 +08:00
|
|
|
|
RefreshNumScroll();
|
2024-01-29 16:30:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-06 16:56:20 +08:00
|
|
|
|
private async void RefreshUI()
|
2024-01-29 16:30:26 +08:00
|
|
|
|
{
|
2024-02-22 19:47:38 +08:00
|
|
|
|
Text_LevelNum.text = _currLevelInfo.ChapterIndex + "-" + _currLevelInfo.LevelIndex;
|
|
|
|
|
|
Text_LevelName.text = _currLevelInfo.Name;
|
|
|
|
|
|
Text_Buff.text = _currLevelInfo.EnvironmentBuffString;
|
2024-01-29 16:30:26 +08:00
|
|
|
|
|
2024-02-22 19:47:38 +08:00
|
|
|
|
var dayNightConfig = CommonUtils.GetDayNightConfig(_currLevelInfo.DayNightType);
|
|
|
|
|
|
Image_DayOrNight.sprite = AssetManager.Instance.GetPreLoadResult<Sprite>(dayNightConfig.Icon);
|
|
|
|
|
|
Text_DayOrNight.text = CommonUtils.GetLocalizeText(dayNightConfig.NameLocal);
|
|
|
|
|
|
|
|
|
|
|
|
var weatherConfig = CommonUtils.GetWeatherConfig(_currLevelInfo.WeatherType);
|
|
|
|
|
|
Image_weather.sprite = AssetManager.Instance.GetPreLoadResult<Sprite>(weatherConfig.Icon);
|
|
|
|
|
|
Text_WeatherAndLand01.text = CommonUtils.GetLocalizeText(weatherConfig.NameLocal);
|
|
|
|
|
|
|
|
|
|
|
|
var environmentConfig = CommonUtils.GetEnvironmentConfig(_currLevelInfo.EnvironmentType);
|
|
|
|
|
|
Image_environment.sprite = AssetManager.Instance.GetPreLoadResult<Sprite>(environmentConfig.Icon);
|
|
|
|
|
|
Text_WeatherAndLand02.text = CommonUtils.GetLocalizeText(environmentConfig.NameLocal);
|
|
|
|
|
|
|
|
|
|
|
|
var starResult = _currLevelInfo.StarResult;
|
|
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
GameObject go =
|
|
|
|
|
|
FindObj(string.Format("Image_BG/LevelDetail/Image_Misson/ImageMissionBar{0}", (i).ToString()));
|
|
|
|
|
|
if (i < _currLevelInfo.LevelData.starTarget.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
go.SetActive(true);
|
2024-04-15 17:59:58 +08:00
|
|
|
|
CommonUtils.GetComponent<TMP_Text>(go, "TextDescribe").text = _currLevelInfo.GetStarTargetLocalizationText(i);
|
2024-02-22 19:47:38 +08:00
|
|
|
|
var rewardIDs = i == 0 ? _currLevelInfo.StarRewardID_1 :
|
|
|
|
|
|
i == 1 ? _currLevelInfo.StarRewardID_2 : _currLevelInfo.StarRewardID_3;
|
|
|
|
|
|
bool isFinish = starResult[i];
|
|
|
|
|
|
if (rewardIDs.Length != 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"关卡星级奖励配置id数目不正确!只能有一个ID! levelID:{_currLevelInfo.ID} 星级:{i + 1}");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2024-07-03 19:05:46 +08:00
|
|
|
|
//var rewardItemList = RewardManager.Instance.Get(rewardIDs[0]).ItemList.Get();
|
|
|
|
|
|
var rewardItemList = CommonUtils.GetFilterRewardItemList(RewardManager.Instance.Get(rewardIDs[0])).Get();
|
2024-02-22 19:47:38 +08:00
|
|
|
|
if (rewardItemList.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"星级目标的奖励数目大于1!levelID:{_currLevelInfo.ID} 星级:{i + 1}");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var rewardItem = rewardItemList[0];
|
2024-05-06 14:30:05 +08:00
|
|
|
|
TMP_Text getItemText = CommonUtils.GetComponent<TMP_Text>(go, "RewardContent/TextGetItem");
|
|
|
|
|
|
TMP_Text getItemGrayText = CommonUtils.GetComponent<TMP_Text>(go, "RewardContent/TextGetItem_Grey");
|
2024-02-22 19:47:38 +08:00
|
|
|
|
var text = isFinish ? getItemText : getItemGrayText;
|
2024-05-06 14:30:05 +08:00
|
|
|
|
text.text = rewardItem.ShowCountText;
|
|
|
|
|
|
getItemText.gameObject.SetActive(isFinish);
|
|
|
|
|
|
getItemGrayText.gameObject.SetActive(!isFinish);
|
|
|
|
|
|
var imgItem = CommonUtils.GetComponent<Image>(go, "RewardContent/ImageItem");
|
|
|
|
|
|
var spritePath = CommonUtils.GetItemPath(rewardItem.ID);
|
2024-05-06 16:56:20 +08:00
|
|
|
|
imgItem.sprite = await LoadAssetAsync<Sprite>(spritePath);
|
2024-02-22 19:47:38 +08:00
|
|
|
|
}
|
2024-01-29 16:30:26 +08:00
|
|
|
|
|
2024-02-22 19:47:38 +08:00
|
|
|
|
var finishedStarImage = CommonUtils.GetComponent<Image>(go, "ImageWinStart");
|
|
|
|
|
|
var notFinishedStarImage = CommonUtils.GetComponent<Image>(go, "ImageFailedStart");
|
|
|
|
|
|
finishedStarImage.gameObject.SetActive(isFinish);
|
|
|
|
|
|
notFinishedStarImage.gameObject.SetActive(!isFinish);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
go.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-01-29 16:30:26 +08:00
|
|
|
|
}
|
2024-02-22 19:47:38 +08:00
|
|
|
|
|
|
|
|
|
|
private void SetScrollView()
|
|
|
|
|
|
{
|
2024-04-02 13:10:37 +08:00
|
|
|
|
ShowIfNull();
|
2024-01-29 16:30:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-02-23 16:13:25 +08:00
|
|
|
|
// private void SetScrollviewItemButton(GameObject @object)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// }
|
2024-01-29 16:30:26 +08:00
|
|
|
|
|
2024-04-02 13:10:37 +08:00
|
|
|
|
private void RefreshRewardItem(GameObject cell, int index)
|
2024-01-29 16:30:26 +08:00
|
|
|
|
{
|
2024-04-02 13:10:37 +08:00
|
|
|
|
if (!dicPassReward.TryGetValue(cell.GetInstanceID(), out GenericItem_PassReward item))
|
2024-02-23 16:13:25 +08:00
|
|
|
|
{
|
2024-04-02 13:10:37 +08:00
|
|
|
|
item = new GenericItem_PassReward(cell);
|
|
|
|
|
|
dicPassReward.Add(cell.GetInstanceID(), item);
|
2024-02-23 16:13:25 +08:00
|
|
|
|
}
|
2024-04-02 13:10:37 +08:00
|
|
|
|
|
|
|
|
|
|
var rewardInfo = _allRewards[index];
|
|
|
|
|
|
item.SetInfo(rewardInfo.rewardItem, rewardInfo.hasGet, rewardInfo.rewardType);
|
2024-01-29 16:30:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void RefreshAllRewardsData()
|
2024-02-22 19:47:38 +08:00
|
|
|
|
{
|
2024-02-23 16:13:25 +08:00
|
|
|
|
_allRewards.Clear();
|
|
|
|
|
|
for (int i = 0; i < _currLevelInfo.NomralRewardID.Length; i++)
|
2024-02-22 19:47:38 +08:00
|
|
|
|
{
|
2024-02-23 16:13:25 +08:00
|
|
|
|
Reward reward = RewardManager.Instance.Get(_currLevelInfo.NomralRewardID[i]);
|
2024-07-03 19:05:46 +08:00
|
|
|
|
var itemList = CommonUtils.GetFilterRewardItemList(reward);
|
|
|
|
|
|
foreach (var rewardItem in itemList.Get())
|
2024-02-23 16:13:25 +08:00
|
|
|
|
{
|
|
|
|
|
|
RewardShowItem RewardShowItem =
|
|
|
|
|
|
new RewardShowItem(rewardItem, ERewardType.LevelNormalPassReward, false);
|
|
|
|
|
|
_allRewards.Add(RewardShowItem);
|
|
|
|
|
|
}
|
2024-01-29 16:30:26 +08:00
|
|
|
|
}
|
2024-02-22 19:47:38 +08:00
|
|
|
|
|
2024-02-23 16:13:25 +08:00
|
|
|
|
for (int i = 0; i < _currLevelInfo.FirstRewardID.Length; i++)
|
2024-01-29 16:30:26 +08:00
|
|
|
|
{
|
2024-02-23 16:13:25 +08:00
|
|
|
|
Reward reward = RewardManager.Instance.Get(_currLevelInfo.FirstRewardID[i]);
|
2024-07-03 19:05:46 +08:00
|
|
|
|
var itemList = CommonUtils.GetFilterRewardItemList(reward);
|
|
|
|
|
|
foreach (var rewardItem in itemList.Get())
|
2024-02-23 16:13:25 +08:00
|
|
|
|
{
|
|
|
|
|
|
RewardShowItem RewardShowItem =
|
|
|
|
|
|
new RewardShowItem(rewardItem, ERewardType.LevelFirstPassReward, _currLevelInfo.HasPass);
|
|
|
|
|
|
_allRewards.Add(RewardShowItem);
|
|
|
|
|
|
}
|
2024-01-29 16:30:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-02-22 19:47:38 +08:00
|
|
|
|
|
2024-01-29 16:30:26 +08:00
|
|
|
|
private bool ShowIfNull()
|
|
|
|
|
|
{
|
2024-02-23 16:13:25 +08:00
|
|
|
|
FindObj("Image_BG/RewardAndSweep/Text_GetReward/NoRewards").SetActive(_allRewards.Count == 0);
|
|
|
|
|
|
return _allRewards.Count == 0;
|
2024-01-29 16:30:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-06 14:04:57 +08:00
|
|
|
|
#region NumScroll
|
|
|
|
|
|
|
|
|
|
|
|
private void RefreshNumScroll()
|
|
|
|
|
|
{
|
2024-03-06 17:47:03 +08:00
|
|
|
|
if (_numScrollView != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
_numScrollView = GetComponent<UnityEngine.UI.ScrollRect>("Image_BG/RewardAndSweep/Text_Sweep/SweepNum/ScrollView");
|
|
|
|
|
|
_numItem = FindObj("Image_BG/RewardAndSweep/Text_Sweep/SweepNum/ItemNum");
|
2024-03-06 14:04:57 +08:00
|
|
|
|
var content = CommonUtils.GetGameObject(_numScrollView.gameObject, "Viewport/Content");
|
2024-03-06 17:47:03 +08:00
|
|
|
|
|
|
|
|
|
|
List<GameObject> itemL = new List<GameObject>();
|
2024-03-08 12:20:00 +08:00
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var go = Instantiate(_numItem);
|
|
|
|
|
|
go.transform.SetParent(content.transform);
|
|
|
|
|
|
RefreshItemHide(go);
|
|
|
|
|
|
itemL.Add(go);
|
|
|
|
|
|
}
|
2024-03-06 14:04:57 +08:00
|
|
|
|
for (int i = 0; i < MAX_SWEEPNUM; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var go = Instantiate(_numItem);
|
|
|
|
|
|
go.transform.SetParent(content.transform);
|
|
|
|
|
|
RefreshItem(go, i);
|
2024-03-06 17:47:03 +08:00
|
|
|
|
itemL.Add(go);
|
|
|
|
|
|
}
|
2024-03-08 12:20:00 +08:00
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var go = Instantiate(_numItem);
|
|
|
|
|
|
go.transform.SetParent(content.transform);
|
|
|
|
|
|
RefreshItemHide(go);
|
|
|
|
|
|
itemL.Add(go);
|
|
|
|
|
|
}
|
2024-03-06 17:47:03 +08:00
|
|
|
|
|
2024-03-08 12:20:00 +08:00
|
|
|
|
_scrollFocusCmp = _numScrollView.GetComponent<UIScrollFocusHelper>();
|
|
|
|
|
|
if (_scrollFocusCmp)
|
2024-03-06 17:47:03 +08:00
|
|
|
|
{
|
2024-03-08 12:20:00 +08:00
|
|
|
|
_scrollFocusCmp.SetData(itemL, MAX_SWEEPNUM + SWEEP_NUM_CONST - 1, SWEEP_NUM_CONST - 1);
|
|
|
|
|
|
_scrollFocusCmp.SetFocusItemFunc(_FocusItemFunc);
|
|
|
|
|
|
_scrollFocusCmp.SetUnFocusItemFunc(_UnFocusItemFunc);
|
|
|
|
|
|
_scrollFocusCmp.Init();
|
2024-03-06 14:04:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-08 12:20:00 +08:00
|
|
|
|
private void RefreshItemHide(GameObject obj)
|
|
|
|
|
|
{
|
|
|
|
|
|
var txtNum = CommonUtils.GetComponent<TMP_Text>(obj, "TextNum");
|
|
|
|
|
|
var imgTri = CommonUtils.GetComponent<Image>(obj, "ImageTri");
|
|
|
|
|
|
|
|
|
|
|
|
obj.SetActive(true);
|
|
|
|
|
|
txtNum.gameObject.SetActive(false);
|
|
|
|
|
|
imgTri.gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-06 14:04:57 +08:00
|
|
|
|
private void RefreshItem(GameObject obj, int idx)
|
|
|
|
|
|
{
|
|
|
|
|
|
var txtNum = CommonUtils.GetComponent<TMP_Text>(obj, "TextNum");
|
|
|
|
|
|
var imgTri = CommonUtils.GetComponent<Image>(obj, "ImageTri");
|
|
|
|
|
|
|
|
|
|
|
|
txtNum.text = idx.ToString();
|
|
|
|
|
|
if (idx == MAX_SWEEPNUM - 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
imgTri.gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
obj.SetActive(true);
|
|
|
|
|
|
}
|
2024-03-06 17:47:03 +08:00
|
|
|
|
|
|
|
|
|
|
private void _FocusItemFunc(GameObject go)
|
|
|
|
|
|
{
|
|
|
|
|
|
//DebugUtil.LogError("触发聚焦 FocusItemFunc");
|
2024-03-08 12:20:00 +08:00
|
|
|
|
var txtNum = CommonUtils.GetComponent<TMP_Text>(go, "TextNum");
|
|
|
|
|
|
txtNum.fontSize = 66f;
|
2024-03-06 17:47:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void _UnFocusItemFunc(GameObject go)
|
|
|
|
|
|
{
|
2024-03-08 12:20:00 +08:00
|
|
|
|
var txtNum = CommonUtils.GetComponent<TMP_Text>(go, "TextNum");
|
|
|
|
|
|
txtNum.fontSize = 40f;
|
2024-03-06 17:47:03 +08:00
|
|
|
|
}
|
2024-03-06 14:04:57 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
2024-02-22 19:47:38 +08:00
|
|
|
|
//invoke when reload window
|
|
|
|
|
|
protected override void OnReloadWindow(object data = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
2024-01-29 16:30:26 +08:00
|
|
|
|
|
2024-02-22 19:47:38 +08:00
|
|
|
|
//invoke when close window
|
2024-01-29 16:30:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
2024-02-22 19:47:38 +08:00
|
|
|
|
//invoke when destroy
|
|
|
|
|
|
public override void OnRelease()
|
|
|
|
|
|
{
|
2024-05-08 13:42:53 +08:00
|
|
|
|
|
2024-02-22 19:47:38 +08:00
|
|
|
|
CommonUtils.PreLoadOrUnloadEnvironmentWeatherDayNightIcon(false);
|
2024-05-08 13:42:53 +08:00
|
|
|
|
|
|
|
|
|
|
foreach (GenericItem_PassReward genericItem_PassReward in dicPassReward.Values)
|
|
|
|
|
|
{
|
|
|
|
|
|
genericItem_PassReward.Dispose();
|
|
|
|
|
|
}
|
|
|
|
|
|
dicPassReward.Clear();
|
2024-08-08 12:19:32 +08:00
|
|
|
|
CommonUtils.ScreenshotReset();
|
|
|
|
|
|
|
2024-05-08 13:42:53 +08:00
|
|
|
|
base.OnRelease();
|
2024-01-29 16:30:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|