//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Monday, March 05, 2018
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
|
public class ImpactBillRankWin : Window, SecondWindowInterface
|
{
|
|
[SerializeField] Text m_CompareTitle;
|
[SerializeField] ScrollerController m_RankCtrl;
|
[SerializeField] Text m_SelfRank;
|
|
ImpactRankModel model { get { return ModelCenter.Instance.GetModel<ImpactRankModel>(); } }
|
RankModel rankModel { get { return ModelCenter.Instance.GetModel<RankModel>(); } }
|
|
Text m_RankTypeTxt;
|
public Button close { get; set; }
|
#region Built-in
|
|
protected override void BindController()
|
{
|
if (this is SecondWindowInterface)
|
{
|
var frame = this.GetComponentInChildren<SecondFrameLoader2>();
|
frame.Create();
|
close = frame.GetComponentInChildren<Button>();
|
m_RankTypeTxt = frame.GetComponentInChildren<Text>();
|
}
|
}
|
|
protected override void AddListeners()
|
{
|
close.onClick.AddListener(CloseClick);
|
}
|
|
protected override void OnPreOpen()
|
{
|
rankModel.onRankRefresh += OnRefreshRank;
|
OnRefreshRank((int)model.presentBillRankType);
|
}
|
|
protected override void OnActived()
|
{
|
base.OnActived();
|
RefreshRankType();
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
rankModel.onRankRefresh -= OnRefreshRank;
|
}
|
|
protected override void OnAfterClose()
|
{
|
|
}
|
#endregion
|
private void RefreshRankType()
|
{
|
m_CompareTitle.text = Language.Get(StringUtility.Contact("OSCBillRankCompare_", model.presentBillRankType));
|
m_RankTypeTxt.text = Language.Get(StringUtility.Contact("OSCBillRankTitle_", model.presentBillRankType));
|
}
|
|
private void OnRefreshRank(int type)
|
{
|
if ((int)model.presentBillRankType != type)
|
{
|
return;
|
}
|
if (m_RankCtrl.GetNumberOfCells(m_RankCtrl.m_Scorller) < 1)
|
{
|
m_RankCtrl.Refresh();
|
for (int i = 0; i < 500; i++)
|
{
|
if (i % 2 == 0)
|
{
|
m_RankCtrl.AddCell(ScrollerDataType.Normal, i);
|
}
|
else
|
{
|
m_RankCtrl.AddCell(ScrollerDataType.Header, i);
|
}
|
}
|
m_RankCtrl.Restart();
|
m_RankCtrl.JumpIndex(model.viewRankStartIndex);
|
}
|
else
|
{
|
m_RankCtrl.m_Scorller.RefreshActiveCellViews();
|
m_RankCtrl.JumpIndex(model.viewRankStartIndex);
|
}
|
var rank = -1;
|
var data = rankModel.GetMyRank(type);
|
if (data != null)
|
{
|
rank = data.index + 1;
|
}
|
|
if (rank == -1)
|
{
|
m_SelfRank.text = Language.Get("L1045");
|
}
|
else
|
{
|
m_SelfRank.text = Language.Get("L1092", rank);
|
}
|
}
|
|
}
|
|
}
|