using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using System;
|
|
|
namespace vnxbqy.UI
|
{
|
public class DungeonIntegralRankBehaviour : MonoBehaviour
|
{
|
[SerializeField] ScrollerController scrollerController;
|
[SerializeField] Text m_SelfRankTxt;
|
[SerializeField] Text m_SelfNameTxt;
|
[SerializeField] Text m_SelfIntegralTxt;
|
[SerializeField] AwardItemUI m_AwardItem;
|
FairyLeagueModel m_FairyLeagueModel;
|
FairyLeagueModel fairyLeagueModel
|
{
|
get
|
{
|
return m_FairyLeagueModel ?? (m_FairyLeagueModel = ModelCenter.Instance.GetModel<FairyLeagueModel>());
|
}
|
}
|
|
private void OnEnable()
|
{
|
fairyLeagueModel.UpdateWarRankEvent += RefreshRank;
|
RefreshRank();
|
}
|
|
private void RefreshRank()
|
{
|
scrollerController.Refresh();
|
for (int i = 0; i < fairyLeagueModel.fairyLeagueResults.Count; i++)
|
{
|
scrollerController.AddCell(ScrollerDataType.Header, i);
|
}
|
scrollerController.Restart();
|
RefreshSelf();
|
}
|
|
private void RefreshSelf()
|
{
|
var _index = fairyLeagueModel.fairyLeagueResults.FindIndex((x) =>
|
{
|
return x.PlayerId == PlayerDatas.Instance.PlayerId;
|
});
|
if (_index != -1)
|
{
|
m_SelfRankTxt.text = (_index + 1).ToString();
|
m_SelfIntegralTxt.text = fairyLeagueModel.fairyLeagueResults[_index].Integral.ToString();
|
m_SelfNameTxt.text = fairyLeagueModel.fairyLeagueResults[_index].PlayerName;
|
}
|
else
|
{
|
m_SelfRankTxt.text = Language.Get("FamilyMatchUnBeOnList");
|
m_SelfIntegralTxt.text = "0";
|
m_SelfNameTxt.text = PlayerDatas.Instance.baseData.PlayerName;
|
}
|
var rankKey = UIHelper.GetIntervalAward(fairyLeagueModel.integralRankAwardDict.Keys, _index + 1);
|
if (rankKey != -1)
|
{
|
var _item = fairyLeagueModel.integralRankAwardDict[rankKey][0];
|
var _per = 100;
|
if ((fairyLeagueModel.fairyLeagueGroupId - 1) >= 0
|
&& (fairyLeagueModel.fairyLeagueGroupId - 1) < fairyLeagueModel.integralRankAwardPer.Length)
|
{
|
_per = fairyLeagueModel.integralRankAwardPer[fairyLeagueModel.fairyLeagueGroupId - 1];
|
}
|
var _count = (int)Mathf.Max(_item.count * (_item.isPer == 1 ? ((float)_per / 100) : 1), 1);
|
m_AwardItem.Init(_item.id, _count, _item.bind);
|
}
|
}
|
|
private void OnDisable()
|
{
|
fairyLeagueModel.UpdateWarRankEvent -= RefreshRank;
|
}
|
}
|
}
|