using vnxbqy.UI;
|
using System.Collections;
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
using UnityEngine.UI;
|
namespace EnhancedUI.EnhancedScroller
|
{
|
public class FairyViewCell : ScrollerUI
|
{
|
[SerializeField] EmblemCell emblemCell;
|
[SerializeField] Image m_SelectImg;
|
[SerializeField] Image m_RankImg;
|
[SerializeField] Image m_RealmImg;
|
[SerializeField] Text m_RankTxt;
|
[SerializeField] Text m_FairyNameTxt;
|
[SerializeField] Text m_FairyLeaderNameTxt;
|
[SerializeField] Text m_FairyLvTxt;
|
[SerializeField] Text m_FairyMemberCntTxt;
|
[SerializeField] Text m_FairyGradeTxt;
|
|
private FairyModel m_Model;
|
private FairyModel model
|
{
|
get
|
{
|
return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<FairyModel>());
|
}
|
}
|
public override void Refresh(CellView cell)
|
{
|
int index = cell.index;
|
bool jiaFairy = false;
|
if (index >= FairyModel.JiaFairyStartIndex)
|
{
|
index = index - FairyModel.JiaFairyStartIndex;
|
jiaFairy = true;
|
}
|
if (!jiaFairy && index >= model.fairyList.Count)
|
{
|
return;
|
}
|
PlayerFairyData.FairyData fairy = null;
|
if (!jiaFairy)
|
{
|
fairy = model.fairyList[index];
|
}
|
DisplayRank(jiaFairy ? (index + model.fairyList.Count) : index);
|
var _jiaId = jiaFairy ? model.jiaFairyIds[index] : 0;
|
|
if (fairy != null)
|
{
|
if (PlayerDatas.Instance.fairyData.fairy == null)
|
{
|
emblemCell.InitUI(EmblemHelper.GetOtherEmblemModel(fairy.EmblemID));
|
}
|
else
|
{
|
emblemCell.InitUI(EmblemHelper.GetEmblemModel(jiaFairy ? model.jiaFairyIds[index] : (int)fairy.FamilyID, fairy.EmblemID));
|
}
|
}
|
else
|
{
|
emblemCell.InitUI(EmblemHelper.GetOtherEmblemModel(EmblemHelper.GetDefaultFamilyEmblemId()));
|
}
|
|
m_FairyNameTxt.text = jiaFairy ? model.jiaFairyNames[_jiaId - 1] : fairy.FamilyName;
|
m_FairyNameTxt.color = jiaFairy || !SelfFairy(fairy) ? UIHelper.GetUIColor(TextColType.NavyBrown) : UIHelper.GetUIColor(TextColType.Green, true);
|
m_FairyLeaderNameTxt.text = jiaFairy ? string.Empty : fairy.leaderName;
|
m_RealmImg.SetActive(!jiaFairy && fairy.OfficialRank > 0);
|
if (!jiaFairy && fairy.OfficialRank > 0)
|
{
|
RealmConfig presentCfg = RealmConfig.Get(fairy.OfficialRank);
|
if (presentCfg != null)
|
{
|
m_RealmImg.SetSprite(presentCfg.Img);
|
m_RealmImg.SetNativeSize();
|
}
|
}
|
m_FairyLvTxt.text = jiaFairy ? "1" : fairy.FamilyLV.ToString();
|
FamilyConfig cfg = FamilyConfig.Get(jiaFairy ? 1 : fairy.FamilyLV);
|
if (cfg != null)
|
{
|
m_FairyMemberCntTxt.text = StringUtility.Contact(jiaFairy ? 0 : fairy.MemberCount, "/", cfg.memberCnt);
|
}
|
|
if (jiaFairy)
|
{
|
m_FairyGradeTxt.text = string.Empty;
|
}
|
else
|
{
|
if (fairy.WarRank != 0)
|
{
|
m_FairyGradeTxt.text = FairyModel.GetFairyGradeLabel((int)fairy.WarRank);
|
}
|
else
|
{
|
m_FairyGradeTxt.text = UIHelper.ReplaceLargeNum(fairy.totalFightPower);
|
}
|
}
|
|
m_SelectImg.SetSprite(model.presentFairy == (jiaFairy ? index + FairyModel.JiaFairyStartIndex : index) ? "RankList_ChoosenBottom" :
|
(jiaFairy ? index + model.fairyList.Count : index) % 2 == 0 ? "RankList_SingleBottom" : "RankList_QuanTouMing");
|
if (PlayerDatas.Instance.fairyData.IsSearching)
|
{
|
return;
|
}
|
if (!jiaFairy && index >= PlayerFairyData.PageCnt / 2 + model.page * PlayerFairyData.PageCnt && model.fairyList.Count >= PlayerFairyData.PageCnt * (model.page + 1))
|
{
|
model.page++;
|
model.OnSearchPageList();
|
}
|
}
|
|
private void DisplayRank(int _index)
|
{
|
m_RankImg.SetActive(_index < 3);
|
m_RankTxt.SetActive(_index >= 3);
|
if (_index < 3)
|
{
|
m_RankImg.SetSprite(_index == 0 ? "Rank_First" : _index == 1 ? "Rank_Second" : "Rank_Third");
|
}
|
else
|
{
|
m_RankTxt.text = (_index + 1).ToString();
|
}
|
}
|
|
private bool SelfFairy(PlayerFairyData.FairyData _fairy)
|
{
|
if (!PlayerDatas.Instance.fairyData.HasFairy)
|
{
|
return false;
|
}
|
return PlayerDatas.Instance.fairyData.fairy.FamilyID == _fairy.FamilyID;
|
}
|
}
|
}
|
|