using UnityEngine;
|
|
namespace vnxbqy.UI
|
{
|
public class FairySiegeBattleReportDefCell : CellView
|
{
|
[SerializeField] ButtonEx btnGo;
|
[SerializeField] EmblemCell emblemCell;
|
[SerializeField] ImageEx imgRank;
|
[SerializeField] TextEx txtFairyName;
|
[SerializeField] TextEx txtHealthLoss;
|
[SerializeField] TextEx txtLeaderName;
|
[SerializeField] TextEx txtRank;
|
FairySiegeActModel model { get { return ModelCenter.Instance.GetModel<FairySiegeActModel>(); } }
|
|
public void Display(int index, CellView cellView)
|
{
|
int rankNum = index + 1;
|
int tagFamilyID = cellView.info.Value.infoInt1;
|
|
txtRank.text = rankNum.ToString();
|
var isRankImageDisplay = model.IsRankImageDisplay(rankNum);
|
imgRank.SetActive(isRankImageDisplay);
|
if (isRankImageDisplay)
|
{
|
var key = model.GetRankNumImage(rankNum);
|
imgRank.SetSprite(key);
|
}
|
|
if (!model.batReportDefDict.TryGetValue(model.nowBatReportFamilyID, out var dict))
|
return;
|
if (!dict.TryGetValue((uint)tagFamilyID, out var hurtValue))
|
return;
|
|
if (tagFamilyID == model.BossCityId)
|
{
|
emblemCell.InitUI(EmblemHelper.GetOtherEmblemModel(EmblemHelper.GetDefaultFamilyEmblemId()));
|
txtFairyName.text = Language.Get("FairySiege150");
|
txtLeaderName.text = string.Empty;
|
}
|
else
|
{
|
if (!model.TryGetFairySiegeFamilyInfo((uint)tagFamilyID, out FairySiegeFamilyInfo familyInfo))
|
return;
|
emblemCell.InitUI(EmblemHelper.GetOtherEmblemModel((int)familyInfo.EmblemID));
|
txtFairyName.text = familyInfo.Name;
|
txtLeaderName.text = Language.Get("FairySiege087", familyInfo.LeaderName);
|
}
|
|
btnGo.SetListener(() =>
|
{
|
model.JumpToCityAction?.Invoke((uint)tagFamilyID);
|
WindowCenter.Instance.Close<FairySiegeBattleReportWin>();
|
});
|
|
string rate = string.Empty;
|
// 自己看自己的战报
|
if (model.nowBatReportFamilyID == model.myFamilyID)
|
{
|
rate = model.CalculateDamagePercentage(hurtValue, model.myCityHPMax);
|
}
|
else
|
{
|
bool isBatSceneCityInfo = model.TryGetBatSceneCityInfo(model.showBatType, model.showBatGroup, model.nowBatReportFamilyID, out var cityInfo);
|
if (isBatSceneCityInfo)
|
{
|
rate = model.CalculateDamagePercentage(hurtValue, cityInfo.HPMax);
|
}
|
}
|
txtHealthLoss.text = rate;
|
}
|
}
|
}
|