using Snxxz.UI;
|
using System.Collections;
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
using UnityEngine.UI;
|
namespace EnhancedUI.EnhancedScroller
|
{
|
public class FairyViewCell : ScrollerUI
|
{
|
[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 fakeFairy = false;
|
if (index >= FairyModel.FakeFairyStartIndex)
|
{
|
index = index - FairyModel.FakeFairyStartIndex;
|
fakeFairy = true;
|
}
|
if (!fakeFairy && index >= model.fairyList.Count)
|
{
|
return;
|
}
|
PlayerFairyData.FairyData fairy = null;
|
if (!fakeFairy)
|
{
|
fairy = model.fairyList[index];
|
}
|
DisplayRank(fakeFairy ? (index + model.fairyList.Count) : index);
|
var _fakeId = fakeFairy ? model.fakeFairyIds[index] : 0;
|
m_FairyNameTxt.text = fakeFairy ? model.fakeFairyNames[_fakeId - 1] : fairy.FamilyName;
|
m_FairyNameTxt.color = fakeFairy || !SelfFairy(fairy) ? UIHelper.GetUIColor(TextColType.NavyBrown) : UIHelper.GetUIColor(TextColType.Green, true);
|
m_FairyLeaderNameTxt.text = fakeFairy ? string.Empty : fairy.leaderName;
|
m_RealmImg.gameObject.SetActive(!fakeFairy && fairy.OfficialRank > 0);
|
if (!fakeFairy && fairy.OfficialRank > 0)
|
{
|
RealmConfig presentCfg = RealmConfig.Get(fairy.OfficialRank);
|
if (presentCfg != null)
|
{
|
m_RealmImg.SetSprite(presentCfg.Img);
|
m_RealmImg.SetNativeSize();
|
}
|
}
|
m_FairyLvTxt.text = fakeFairy ? "1" : fairy.FamilyLV.ToString();
|
FamilyConfig cfg = FamilyConfig.Get(fakeFairy ? 1 : fairy.FamilyLV);
|
if (cfg != null)
|
{
|
m_FairyMemberCntTxt.text = StringUtility.Contact(fakeFairy ? 0 : fairy.MemberCount, "/", cfg.memberCnt);
|
}
|
|
if (fakeFairy)
|
{
|
m_FairyGradeTxt.text = string.Empty;
|
}
|
else
|
{
|
if (fairy.WarRank != 0)
|
{
|
m_FairyGradeTxt.text = GetGrade((int)fairy.WarRank);
|
}
|
else
|
{
|
m_FairyGradeTxt.text = UIHelper.ReplaceLargeNum(fairy.totalFightPower);
|
}
|
}
|
|
m_SelectImg.SetSprite(model.presentFairy == (fakeFairy ? index + FairyModel.FakeFairyStartIndex : index) ? "RankList_ChoosenBottom" :
|
(fakeFairy ? index + model.fairyList.Count : index) % 2 == 0 ? "RankList_SingleBottom" : "RankList_QuanTouMing");
|
if (PlayerDatas.Instance.fairyData.IsSearching)
|
{
|
return;
|
}
|
if (!fakeFairy && 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.gameObject.SetActive(_index < 3);
|
m_RankTxt.gameObject.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();
|
}
|
}
|
|
public string GetGrade(int _rank)
|
{
|
_rank = Mathf.CeilToInt((float)_rank / 4);
|
switch (_rank)
|
{
|
case 1:
|
return Language.Get("Fairy_S");
|
case 2:
|
return Language.Get("Fairy_A");
|
case 3:
|
return Language.Get("Fairy_B");
|
case 4:
|
return Language.Get("Fairy_C");
|
default:
|
return Language.Get("Fairy_D");
|
}
|
}
|
|
private bool SelfFairy(PlayerFairyData.FairyData _fairy)
|
{
|
if (!PlayerDatas.Instance.fairyData.HasFairy)
|
{
|
return false;
|
}
|
return PlayerDatas.Instance.fairyData.fairy.FamilyID == _fairy.FamilyID;
|
}
|
}
|
}
|
|