using System.Collections;
|
using System.Collections.Generic;
|
using vnxbqy.UI;
|
using UnityEngine;
|
using UnityEngine.UI;
|
namespace EnhancedUI.EnhancedScroller
|
{
|
public class FairyLeagueRankCell : ScrollerUI
|
{
|
[SerializeField] Image m_RankBG;
|
[SerializeField] Text m_RankTxt;
|
[SerializeField] Image m_RankImg;
|
[SerializeField] Image m_FirstRankSign;
|
[SerializeField] Text m_PlayerNameTxt;
|
[SerializeField] Text m_CrystalTxt;
|
[SerializeField] Text m_KillNumTxt;
|
[SerializeField] Text m_BuffNumTxt;
|
[SerializeField] Text m_FightTimeTxt;
|
[SerializeField] Text m_IntegralTxt;
|
[SerializeField] Image m_WinImg;
|
[SerializeField] AwardItemUI m_IntegralAward;
|
[SerializeField] RectTransform m_ContainChampion;
|
[SerializeField] AwardItemUI m_ChampionAward;
|
[SerializeField] Button m_ChampionAwardBtn;
|
|
FairyLeagueModel m_Model;
|
FairyLeagueModel model
|
{
|
get
|
{
|
return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<FairyLeagueModel>());
|
}
|
}
|
public override void Refresh(CellView cell)
|
{
|
var _list = model.fairyLeagueResults;
|
var _index = cell.index;
|
m_RankTxt.SetActive(_index > 2);
|
m_RankImg.SetActive(_index < 3);
|
m_RankBG.SetSprite(_index % 2 == 0 ? "RankList_SingleBottom" : "RankList_QuanTouMing");
|
if (_index < 3)
|
{
|
m_RankImg.SetSprite(_index == 0 ? "Rank_First" : _index == 1 ? "Rank_Second" : "Rank_Third");
|
}
|
else
|
{
|
m_RankTxt.text = (_index + 1).ToString();
|
}
|
FairyLeagueResultData _data = model.fairyLeagueResults[_index];
|
m_PlayerNameTxt.text = _data.PlayerName;
|
m_BuffNumTxt.text = _data.TakeBuffs.ToString();
|
m_CrystalTxt.text = _data.TakeCrystals.ToString();
|
m_KillNumTxt.text = _data.KillNums.ToString();
|
m_IntegralTxt.text = _data.Integral.ToString();
|
m_FightTimeTxt.text = TimeUtility.SecondsToHMS(_data.FightTime);
|
m_WinImg.SetActive(_data.IsWin);
|
var _rankKey = UIHelper.GetIntervalAward(model.integralRankAwardDict.Keys, _index + 1);
|
var _item = model.integralRankAwardDict[_rankKey][0];
|
var _per = 100;
|
if ((model.fairyLeagueGroupId - 1) >= 0
|
&& (model.fairyLeagueGroupId - 1) < model.integralRankAwardPer.Length)
|
{
|
_per = model.integralRankAwardPer[model.fairyLeagueGroupId - 1];
|
}
|
var _count = (int)Mathf.Max(_item.count * (_item.isPer == 1 ? ((float)_per / 100) : 1), 1);
|
m_IntegralAward.Init(_item.id, _count, _item.bind);
|
m_IntegralAward.itemCnt.text = StringUtility.Contact("X", _count);
|
bool winChampion = _index == model.GetBattleWinFirstPlayer();
|
bool defeatChampion = _index == model.GetBattleDefeatFirstPlayer();
|
m_FirstRankSign.SetActive(winChampion || defeatChampion);
|
if (winChampion || defeatChampion)
|
{
|
m_FirstRankSign.SetSprite(winChampion ? "UnionMatchNo1" : "UnionMatchNo2");
|
m_FirstRankSign.SetNativeSize();
|
}
|
m_ContainChampion.SetActive(model.fairyLeagueGroupId == 5 && (winChampion || defeatChampion));
|
m_ChampionAwardBtn.onClick.RemoveAllListeners();
|
if (model.fairyLeagueGroupId == 5 && (winChampion || defeatChampion))
|
{
|
Dictionary<int, List<Item>> _dict = null;
|
if (winChampion)
|
{
|
_dict = (model.fairyLeagueSession == 1 && model.fairyLeagueHelp.fairyWarEnter.IsFinalMatch == 1) ?
|
model.finalWarChampionWinAwardDict : model.finalWarWinAwardDict;
|
}
|
else
|
{
|
_dict = (model.fairyLeagueSession == 1 && model.fairyLeagueHelp.fairyWarEnter.IsFinalMatch == 1) ?
|
model.finalWarChampionDefeatAwardDict : model.finalWarDefeatAwardDict;
|
}
|
if (_dict != null && _dict.Count > 0)
|
{
|
_rankKey = UIHelper.GetIntervalAward(_dict.Keys, (int)PlayerDatas.Instance.worldLv);
|
var _Award = _dict[_rankKey][0];
|
m_ChampionAward.Init(_Award.id, Mathf.Min(1, _Award.count));
|
m_ChampionAwardBtn.onClick.AddListener(() =>
|
{
|
ItemTipUtility.Show(_Award.id);
|
});
|
}
|
}
|
}
|
}
|
}
|