331 lines
10 KiB
C#
331 lines
10 KiB
C#
|
|
using cfg.ActorCfg;
|
|||
|
|
using cfg.LevelCfg;
|
|||
|
|
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;
|
|||
|
|
using Button = UnityEngine.UI.Button;
|
|||
|
|
using Image = UnityEngine.UI.Image;
|
|||
|
|
|
|||
|
|
public static class RewardHelper
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
public class RewardForBeforeFightUI : Reward
|
|||
|
|
{
|
|||
|
|
bool isShowNum;
|
|||
|
|
public bool isStableReward;
|
|||
|
|
public RewardForBeforeFightUI(DataRewards data) : base(data)
|
|||
|
|
{
|
|||
|
|
isStableReward = data.RewardType == RewardType.Ensure;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public class UI_LevelDetailController : UIWindow
|
|||
|
|
{
|
|||
|
|
//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;
|
|||
|
|
|
|||
|
|
|
|||
|
|
private LevelInfo _currLevelInfo;
|
|||
|
|
PhxhScrollView _mCurrentScrollView = null;
|
|||
|
|
private Button fightBtn;
|
|||
|
|
|
|||
|
|
public List<RewardForBeforeFightUI> allRewards;
|
|||
|
|
//private int _currTeamIndex = -1;
|
|||
|
|
private Team _currTeam;
|
|||
|
|
private int _teamIndexMax;
|
|||
|
|
///Auto Gen End///
|
|||
|
|
|
|||
|
|
// deal with input data
|
|||
|
|
public override void PreLoad(object data)
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Use this for initialization
|
|||
|
|
public override void OnInit()
|
|||
|
|
{
|
|||
|
|
//bind UI GameObj
|
|||
|
|
UI_LevelDetailBinder.GetComponents(this);
|
|||
|
|
_mCurrentScrollView = GetComponent<PhxhScrollView>("Image_BG/RewardAndSweep/Text_GetReward/PhxhScrollView");
|
|||
|
|
fightBtn = GetComponent<Button>("Image_BG/Image_StartFight");
|
|||
|
|
Text_LevelNum = GetComponent<TMP_Text>("Image_BG/Top/Text_LevelNum");
|
|||
|
|
|
|||
|
|
BindButton(Button_Close, CloseOnClick);
|
|||
|
|
BindButton(Button_Cancel, CloseOnClick);
|
|||
|
|
BindButton(GetComponent<Button>("emptyForAllCloseBtn"), CloseOnClick);
|
|||
|
|
BindButton(fightBtn, FightOnClick);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void FightOnClick()
|
|||
|
|
{
|
|||
|
|
// var team = TeamEditManager.Instance.TeamList[_currTeamIndex];
|
|||
|
|
// if (team.IsMemberEmpty())
|
|||
|
|
// {
|
|||
|
|
// return;
|
|||
|
|
// }
|
|||
|
|
//
|
|||
|
|
// LevelManager.Instance.TryEnterLevel(_currLevelInfo.ID, OnEnterLevelFinished);
|
|||
|
|
UIManager.Instance.OpenWindow(UINameConst.UI_BeforeFight,_currLevelInfo.ID);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void OnEnterLevelFinished()
|
|||
|
|
{
|
|||
|
|
CloseWindow();
|
|||
|
|
}
|
|||
|
|
private void CloseOnClick()
|
|||
|
|
{
|
|||
|
|
CloseWindow();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//invoke when open window
|
|||
|
|
protected override void OnShowWindow(object data)
|
|||
|
|
{
|
|||
|
|
_currLevelInfo = data as LevelInfo;
|
|||
|
|
allRewards = new List<RewardForBeforeFightUI>();
|
|||
|
|
|
|||
|
|
//InitTeamInfo();
|
|||
|
|
|
|||
|
|
RefreshUI();
|
|||
|
|
RefreshAllRewardsData();
|
|||
|
|
SetScrollView();
|
|||
|
|
RefreshScrollview();
|
|||
|
|
CommonUtils.SetImageBlur(GetComponent<Image>("blurObj"));
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
// private void InitTeamInfo()
|
|||
|
|
// {
|
|||
|
|
// var teamList = TeamEditManager.Instance.TeamList;
|
|||
|
|
// _teamIndexMax = teamList.Count - 1;
|
|||
|
|
// _currTeam = _currTeamIndex == -1 ? TeamEditManager.Instance.GetSelectTeam() : teamList[_currTeamIndex];
|
|||
|
|
// if (_currTeam == null)
|
|||
|
|
// {
|
|||
|
|
// DebugUtil.LogError("当前没有任何编队!");
|
|||
|
|
// return;
|
|||
|
|
// }
|
|||
|
|
//
|
|||
|
|
// _currTeamIndex = teamList.IndexOf(_currTeam);
|
|||
|
|
// }
|
|||
|
|
|
|||
|
|
private void RefreshScrollview()
|
|||
|
|
{
|
|||
|
|
_mCurrentScrollView.UpdateData(true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private async void RefreshUI()
|
|||
|
|
{
|
|||
|
|
Text_LevelNum.text = _currLevelInfo.ChapterIndex + "-" + _currLevelInfo.LevelIndex;
|
|||
|
|
Text_LevelName.text = _currLevelInfo.Name;
|
|||
|
|
Text_Buff.text = _currLevelInfo.EnvironmentBuffString;
|
|||
|
|
Image_DayOrNight.sprite= await CommonUtils.GetDayNightIcon(_currLevelInfo.DayNightType);
|
|||
|
|
//Text_DayOrNight.text = CommonUtils.GetDayNightString(curLevelInfo.DayNightType);
|
|||
|
|
Image_weather.sprite=await CommonUtils.GetWeatherIcon(_currLevelInfo.WeatherType);
|
|||
|
|
Text_WeatherAndLand01.text = CommonUtils.GetLocalizeText(TableManager.Instance.Tables.WeatherConfig.Get((int)_currLevelInfo.WeatherType).NameLocal);
|
|||
|
|
Image_environment.sprite=await CommonUtils.GetEnvironmentIcon(_currLevelInfo.EnvironmentType);
|
|||
|
|
Text_WeatherAndLand02.text = CommonUtils.GetLocalizeText(TableManager.Instance.Tables.EnviormentConfig.Get((int)_currLevelInfo.EnvironmentType).NameLocal);
|
|||
|
|
|
|||
|
|
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);
|
|||
|
|
CommonUtils.GetComponent<TMP_Text>(go, "TextDescribe").text = _currLevelInfo.GetStarTargetLocalizationText(i);
|
|||
|
|
int diamondCount = GetDiamondRewardNum((i+1));
|
|||
|
|
TMP_Text getItemText = CommonUtils.GetComponent<TMP_Text>(go, "TextGetItem");
|
|||
|
|
TMP_Text getItemGrayText = CommonUtils.GetComponent<TMP_Text>(go, "TextGetItem_Grey");
|
|||
|
|
|
|||
|
|
if (diamondCount==-1)
|
|||
|
|
{
|
|||
|
|
getItemGrayText.gameObject.SetActive(false);
|
|||
|
|
getItemText.gameObject.SetActive(false);
|
|||
|
|
}else if(diamondCount==0)
|
|||
|
|
{
|
|||
|
|
getItemText.text = CommonUtils.GetItemName(GLConfig.Inst.data.DiamondItemId);
|
|||
|
|
getItemGrayText.text = CommonUtils.GetItemName(GLConfig.Inst.data.DiamondItemId);
|
|||
|
|
}else
|
|||
|
|
{
|
|||
|
|
getItemText.text = CommonUtils.GetItemName(GLConfig.Inst.data.DiamondItemId)+"X"+diamondCount;
|
|||
|
|
getItemGrayText.text = CommonUtils.GetItemName(GLConfig.Inst.data.DiamondItemId)+"X"+diamondCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}else
|
|||
|
|
{
|
|||
|
|
go.SetActive(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
private void SetScrollView()
|
|||
|
|
{
|
|||
|
|
if (!ShowIfNull())
|
|||
|
|
{
|
|||
|
|
_mCurrentScrollView.SetUpdateFunc(RefreshItem);
|
|||
|
|
_mCurrentScrollView.SetItemCountFunc(GetCountFunc);
|
|||
|
|
_mCurrentScrollView.SetButton(SetScrollviewItemButton);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void SetScrollviewItemButton(GameObject @object)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private int GetCountFunc()
|
|||
|
|
{
|
|||
|
|
return allRewards.Count;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void RefreshItem(int index, RectTransform transform)
|
|||
|
|
{
|
|||
|
|
ItemNode itemNode = CommonUtils.GetComponent<ItemNode>(transform.gameObject, "ItemParent/ItemObjStatic");
|
|||
|
|
itemNode.Refresh(allRewards[index].Cfg.ItemID,ItemObj.UIType.shop);
|
|||
|
|
CommonUtils.GetGameObject(transform.gameObject, "ItemParent/ImageBlue").SetActive(allRewards[index].isStableReward);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void RefreshAllRewardsData()
|
|||
|
|
{
|
|||
|
|
DataLevel dataLevel = TableManager.Instance.Tables.Level.Get(_currLevelInfo.ID);
|
|||
|
|
for (int i = 0; i < dataLevel.NormalRewardID.Length; i++)
|
|||
|
|
{
|
|||
|
|
Reward reward= RewardManager.Instance.Get(dataLevel.NormalRewardID[i]);
|
|||
|
|
RewardForBeforeFightUI rewardForBeforeFightUI = new RewardForBeforeFightUI(reward.Cfg);
|
|||
|
|
allRewards.Add(rewardForBeforeFightUI);
|
|||
|
|
}
|
|||
|
|
for (int i = 0; i < dataLevel.FristRewardID.Length; i++)
|
|||
|
|
{
|
|||
|
|
Reward reward = RewardManager.Instance.Get(dataLevel.FristRewardID[i]);
|
|||
|
|
RewardForBeforeFightUI rewardForBeforeFightUI = new RewardForBeforeFightUI(reward.Cfg);
|
|||
|
|
allRewards.Add(rewardForBeforeFightUI);
|
|||
|
|
}
|
|||
|
|
for (int i = 0; i < dataLevel.StarRewardID1.Length; i++)
|
|||
|
|
{
|
|||
|
|
Reward reward = RewardManager.Instance.Get(dataLevel.StarRewardID1[i]);
|
|||
|
|
RewardForBeforeFightUI rewardForBeforeFightUI = new RewardForBeforeFightUI(reward.Cfg);
|
|||
|
|
allRewards.Add(rewardForBeforeFightUI);
|
|||
|
|
}
|
|||
|
|
for (int i = 0; i < dataLevel.StarRewardID2.Length; i++)
|
|||
|
|
{
|
|||
|
|
Reward reward = RewardManager.Instance.Get(dataLevel.StarRewardID2[i]);
|
|||
|
|
RewardForBeforeFightUI rewardForBeforeFightUI = new RewardForBeforeFightUI(reward.Cfg);
|
|||
|
|
allRewards.Add(rewardForBeforeFightUI);
|
|||
|
|
}
|
|||
|
|
for (int i = 0; i < dataLevel.StarRewardID3.Length; i++)
|
|||
|
|
{
|
|||
|
|
Reward reward = RewardManager.Instance.Get(dataLevel.StarRewardID2[i]);
|
|||
|
|
RewardForBeforeFightUI rewardForBeforeFightUI = new RewardForBeforeFightUI(reward.Cfg);
|
|||
|
|
allRewards.Add(rewardForBeforeFightUI);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
private bool ShowIfNull()
|
|||
|
|
{
|
|||
|
|
FindObj("Image_BG/RewardAndSweep/Text_GetReward/NoRewards").SetActive(allRewards.Count == 0);
|
|||
|
|
return allRewards.Count == 0;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private int GetDiamondRewardNum(int index)//返回0表示显示文本但是不显示数量,返回-1表示不显示文本
|
|||
|
|
{
|
|||
|
|
DataLevel levelCfg = TableManager.Instance.Tables.Level.Get(_currLevelInfo.ID);
|
|||
|
|
int[] rewardId=null;
|
|||
|
|
int diamondNum = 0;
|
|||
|
|
switch (index)
|
|||
|
|
{
|
|||
|
|
case 1:
|
|||
|
|
rewardId = levelCfg.StarRewardID1;
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
rewardId = levelCfg.StarRewardID2;
|
|||
|
|
break;
|
|||
|
|
case 3:
|
|||
|
|
rewardId = levelCfg.StarRewardID3;
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
if ((rewardId.Length == 1) && rewardId[0]==0)//奖励填0不显示
|
|||
|
|
{
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
bool isHaveDiamond = false;
|
|||
|
|
for (int i = 0; i < rewardId.Length; i++)
|
|||
|
|
{
|
|||
|
|
Reward reward = RewardManager.Instance.Get(rewardId[i]);
|
|||
|
|
if(reward.Cfg.ItemID==GLConfig.Inst.data.DiamondItemId)
|
|||
|
|
{
|
|||
|
|
isHaveDiamond=true;
|
|||
|
|
if(reward.Cfg.MinCount==reward.Cfg.MaxCount)
|
|||
|
|
{
|
|||
|
|
diamondNum += reward.Cfg.MinCount;
|
|||
|
|
|
|||
|
|
}else
|
|||
|
|
{
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
if(!isHaveDiamond)
|
|||
|
|
{
|
|||
|
|
return -1;
|
|||
|
|
}
|
|||
|
|
return diamondNum;
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
//invoke when reload window
|
|||
|
|
protected override void OnReloadWindow(object data = null)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//invoke when close window
|
|||
|
|
|
|||
|
|
|
|||
|
|
//invoke when destroy
|
|||
|
|
public override void OnRelease()
|
|||
|
|
{
|
|||
|
|
base.OnRelease();
|
|||
|
|
}
|
|||
|
|
}
|