360 lines
8.2 KiB
C#
360 lines
8.2 KiB
C#
using System.Collections.Generic;
|
|
using Framework;
|
|
using Gameplay;
|
|
using Gameplay.Character;
|
|
using Gameplay.Level;
|
|
using Gameplay.Net;
|
|
using Gameplay.Unit;
|
|
using NLDPB;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using Button = UnityEngine.UI.Button;
|
|
using Image = UnityEngine.UI.Image;
|
|
|
|
public class UIPassGameController : UIWindow{
|
|
|
|
//UI GameObj
|
|
///Auto Gen Start///
|
|
public Image Image_WinBG;
|
|
public Image Image_PosterLu;
|
|
public Image Image_TextRect;
|
|
public TMP_Text Text_Win;
|
|
public Image Image_BlueBar;
|
|
public TMP_Text Text_LevelNum;
|
|
public TMP_Text Text_LevelName;
|
|
public TMP_Text Text_FightTime;
|
|
public Image Image_Clock;
|
|
public TMP_Text Text_Time;
|
|
public TMP_Text Text_CharacterID;
|
|
public TMP_Text Text_CharacterLV;
|
|
public Image Image_EXEmpty;
|
|
public Image Image_EXFull;
|
|
public TMP_Text Text_EX;
|
|
public TMP_Text Text_LVUp;
|
|
public TMP_Text Text_Target;
|
|
public Image Image_DownShadow;
|
|
public TMP_Text Text_GeneralEX;
|
|
public Image Image_ELogo;
|
|
public TMP_Text Text_EXPHave;
|
|
public TMP_Text Text_EXPGet;
|
|
|
|
///Auto Gen End///
|
|
|
|
private List<Image> _imgWinStar;
|
|
|
|
private List<Image> _imageFailedStart;
|
|
|
|
private List<GameObject> _aimObjList;
|
|
|
|
private int _levelID;
|
|
|
|
private List<GameObject> _itemHeadList;
|
|
|
|
private List<uint> _charIDs;
|
|
|
|
private ItemList _itemList;
|
|
// Use this for initialization
|
|
public override void OnAwake()
|
|
{
|
|
//bind UI GameObj
|
|
UIPassGameBinder.GetComponents(this);
|
|
|
|
BindButton("Button_Close", _OnClickClose);
|
|
|
|
_imgWinStar = new List<Image>();
|
|
_imageFailedStart = new List<Image>();
|
|
_aimObjList = new List<GameObject>();
|
|
_itemHeadList = new List<GameObject>();
|
|
_charIDs = new List<uint>();
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
var img = GetComponent<Image>("Image_WinBG/MissionDetail/ImageMissionBar" + i + "/ImageWinStart");
|
|
var imgFail = GetComponent<Image>("Image_WinBG/MissionDetail/ImageMissionBar" + i + "/ImageFailedStart");
|
|
_imgWinStar.Add(img);
|
|
_imageFailedStart.Add(imgFail);
|
|
|
|
_aimObjList.Add(FindObj("Image_WinBG/MissionDetail/ImageMissionBar" + i));
|
|
}
|
|
|
|
for (int i = 0; i < 7; i++)
|
|
{
|
|
var go = FindObj("Image_WinBG/HeroLevelUp/Image_DownShadow/ItemHead" + i);
|
|
_itemHeadList.Add(go);
|
|
}
|
|
}
|
|
|
|
private void _Refresh()
|
|
{
|
|
var team = LevelManager.Instance.SettleData.Team;
|
|
var charIDArray = team.GetCharacterIDs();
|
|
for (int i = 0; i < charIDArray.Length; i++)
|
|
{
|
|
if (charIDArray[i] != Team.NONE_ID)
|
|
{
|
|
_charIDs.Add(charIDArray[i]);
|
|
}
|
|
}
|
|
|
|
_RefreshInfo();
|
|
_RefreshMissionDetail();
|
|
_RefreshCommonExp();
|
|
_RefreshHeads();
|
|
}
|
|
|
|
//invoke when open window
|
|
protected override void OnOpenWindow(object data)
|
|
{
|
|
_itemList = data as ItemList;
|
|
_levelID = LevelManager.Instance.SettleData.LevelID;
|
|
_Refresh();
|
|
}
|
|
|
|
//invoke when reload window
|
|
protected override void OnReloadWindow()
|
|
{
|
|
|
|
}
|
|
|
|
#region RefreshWindow
|
|
|
|
private void _RefreshInfo()
|
|
{
|
|
_RefreshMapDetail();
|
|
}
|
|
|
|
private void _RefreshMapDetail()
|
|
{
|
|
_RefreshTime();
|
|
_RefreshLevelInfo();
|
|
_RefreshPlayerInfo();
|
|
}
|
|
|
|
private async void _RefreshLevelInfo()
|
|
{
|
|
var level = LevelManager.Instance.CurrLevel;
|
|
var levelName = level.Name;
|
|
Text_LevelName.text = levelName;
|
|
Text_LevelNum.text = level.ID.ToString();
|
|
}
|
|
|
|
private void _RefreshTime()
|
|
{
|
|
var minutes = TeamManager.Instance.GetFightPastMinute();
|
|
var seconds = TeamManager.Instance.GetFightPastSecond();
|
|
var timeStr = "";
|
|
|
|
if (minutes < 10)
|
|
{
|
|
timeStr += minutes;
|
|
}
|
|
else
|
|
{
|
|
timeStr += "0";
|
|
timeStr += minutes;
|
|
}
|
|
|
|
timeStr += ":";
|
|
|
|
if (minutes < 10)
|
|
{
|
|
timeStr += seconds;
|
|
}
|
|
else
|
|
{
|
|
timeStr += "0";
|
|
timeStr += seconds;
|
|
}
|
|
|
|
Text_Time.text = timeStr;
|
|
}
|
|
|
|
private void _RefreshPlayerInfo()
|
|
{
|
|
var playerID = Actor.Instance.Base.GetProp(ActorProp.ActorId);
|
|
var playerLv = Actor.Instance.Base.GetProp(ActorProp.Level);
|
|
Text_CharacterID.text = playerID.ToString();
|
|
Text_CharacterLV.text = "LV:" + playerLv;
|
|
|
|
var actorCfg = TableManager.Instance.Tables.ActorLevel.DataList[(int)playerLv];
|
|
var max = actorCfg.Exp;
|
|
var cur = Actor.Instance.Base.GetProp(ActorProp.Exp);
|
|
var process = (float)cur / max;
|
|
|
|
var oldLvExp = LevelManager.Instance.SettleData.PlayerLvExp;
|
|
var lvDiff = playerLv - oldLvExp.Lv;
|
|
var oldLv = oldLvExp.Lv;
|
|
int add = (int)oldLvExp.Exp;
|
|
if (lvDiff > 0)
|
|
{
|
|
var oldActorLvCfg = TableManager.Instance.Tables.ActorLevel.DataList[(int)oldLv];
|
|
add += oldActorLvCfg.Exp - add;
|
|
|
|
for (uint i = oldLv + 1; i < playerLv; i++)
|
|
{
|
|
var actorLvCfg = TableManager.Instance.Tables.ActorLevel.DataList[(int)i];
|
|
add += actorLvCfg.Exp;
|
|
}
|
|
|
|
add += (int)cur;
|
|
}
|
|
else
|
|
{
|
|
add = (int)(cur - oldLvExp.Exp);
|
|
}
|
|
|
|
Text_LVUp.text = "+" + add;
|
|
Text_EX.text = cur + "/" + max;
|
|
Image_EXFull.fillAmount = process;
|
|
}
|
|
|
|
private void _RefreshMissionDetail()
|
|
{
|
|
_RefreshStars();
|
|
_RefreshAimInfo();
|
|
}
|
|
private void _RefreshStars()
|
|
{
|
|
var starCount = LevelManager.Instance.CurrentLevel.StarCount;
|
|
for (int i = 0; i < _imgWinStar.Count; i++)
|
|
{
|
|
var isFinish = LevelManager.Instance.CurrentLevel.GetStarIsSuccess(i);
|
|
_imgWinStar[i].gameObject.SetActive(isFinish);
|
|
_imageFailedStart[i].gameObject.SetActive(!isFinish);
|
|
}
|
|
}
|
|
|
|
private void _RefreshAimInfo()
|
|
{
|
|
var levelInfo = LevelManager.Instance.GetLevelInfoByID(_levelID);
|
|
for (int i = 0; i < _aimObjList.Count; i++)
|
|
{
|
|
var aimObj = _aimObjList[i];
|
|
var txtDesc = CommonUtils.GetComponent<TMP_Text>(aimObj, "TextDescribe");
|
|
|
|
txtDesc.text = LevelManager.Instance.CurrentLevel.GetStarTargetLocalization(i);
|
|
}
|
|
}
|
|
|
|
private void _RefreshCommonExp()
|
|
{
|
|
var list = _itemList.Lists;
|
|
int itemCount = 0;
|
|
for (var i = ItemSource.LevelPassNormal; i <= ItemSource.LevelPassStar3; i++)
|
|
{
|
|
itemCount += _CalculateExpItemCount(list[(int)i]);
|
|
}
|
|
|
|
var settleData = LevelManager.Instance.SettleData;
|
|
Text_EXPHave.text = settleData.CommonExp.ToString();
|
|
Text_EXPGet.text = "+" + itemCount;
|
|
}
|
|
|
|
private int _CalculateExpItemCount(ItemCounts itemCounts)
|
|
{
|
|
int retCount = 0;
|
|
if (itemCounts.Ids.Count > 0)
|
|
{
|
|
var idx = itemCounts.Ids.IndexOf(3);
|
|
if (idx >= 0)
|
|
{
|
|
var count = itemCounts.Counts[idx];
|
|
retCount = (int)count;
|
|
}
|
|
}
|
|
|
|
return retCount;
|
|
}
|
|
|
|
private void _RefreshHeads()
|
|
{
|
|
for (int i = 0; i < _itemHeadList.Count; i++)
|
|
{
|
|
_RefreshHead(i);
|
|
}
|
|
}
|
|
|
|
private void _RefreshHead(int idx)
|
|
{
|
|
var item = _itemHeadList[idx];
|
|
if (idx >= _charIDs.Count)
|
|
{
|
|
item.SetActive(false);
|
|
return;
|
|
}
|
|
item.SetActive(true);
|
|
|
|
var uid = _charIDs[idx];
|
|
var headNode = CommonUtils.GetComponent<UIHeadItemNode>(item, "HeadNode");
|
|
if (headNode)
|
|
{
|
|
var headInfo = new UIHeadInfo(uid);
|
|
headNode.SetData(headInfo);
|
|
headNode.Refresh(false);
|
|
}
|
|
|
|
var txtExpAdd = CommonUtils.GetComponent<TMP_Text>(item, "ImageHeroEXpEmpty/TextHeroEXPUp");
|
|
var imgExpProcess = CommonUtils.GetComponent<Image>(item, "ImageHeroEXpEmpty/ImageHeroEXpFull");
|
|
var txtLv = CommonUtils.GetComponent<TMP_Text>(item, "TextHeroLV");
|
|
var addExp = _CalculateCharExpAdd(uid);
|
|
if (addExp > 0)
|
|
{
|
|
txtExpAdd.text = "+" + addExp;
|
|
}
|
|
else
|
|
{
|
|
txtExpAdd.text = "";
|
|
}
|
|
|
|
if (CharacterDataInfoManager.Instance.DataDic.TryGetValue(uid, out var charDataInfo))
|
|
{
|
|
var cur = charDataInfo.Exp;
|
|
var cfg = TableManager.Instance.Tables.CharacterLevelExp.GetOrDefault((int)charDataInfo.Level);
|
|
var process = (float)cur / cfg.EXP;
|
|
imgExpProcess.fillAmount = process;
|
|
txtLv.text = "LV" + charDataInfo.Level;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
private uint _CalculateCharExpAdd(uint roleID)
|
|
{
|
|
uint add = 0;
|
|
var lvExp = LevelManager.Instance.SettleData.PlayerLvExp;
|
|
if(CharacterDataInfoManager.Instance.DataDic.TryGetValue(roleID, out var charDataInfo))
|
|
{
|
|
var oldLv = lvExp.Lv;
|
|
var oldExp = lvExp.Exp;
|
|
|
|
var curLv = charDataInfo.Level;
|
|
var curExp = charDataInfo.Exp;
|
|
|
|
if (oldLv < curLv)
|
|
{
|
|
var expCfg = TableManager.Instance.Tables.CharacterLevelExp.GetOrDefault((int)oldLv);
|
|
add += (uint)expCfg.EXP - oldExp;
|
|
|
|
for (uint i = oldLv + 1; i < curLv; i++)
|
|
{
|
|
var cfg = TableManager.Instance.Tables.CharacterLevelExp.GetOrDefault((int)i);
|
|
add += (uint)cfg.EXP;
|
|
}
|
|
|
|
add += curExp;
|
|
}
|
|
else
|
|
{
|
|
add += curExp - oldExp;
|
|
}
|
|
}
|
|
|
|
return add;
|
|
}
|
|
|
|
private async void _OnClickClose()
|
|
{
|
|
await UIManager.Instance.OpenWindow(UINameConst.UI_GetItemSettle, _itemList);
|
|
CloseWindow();
|
|
}
|
|
}
|