//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Thursday, May 30, 2019
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
|
public class ReikiQualityInfomationWin : Window
|
{
|
[SerializeField] ScrollerController m_ScrollerControl;
|
[SerializeField] Image m_ReikiIcon;
|
[SerializeField] Text[] m_PropertyNames;
|
[SerializeField] ReikiRootButton[] m_ReikiRootButtons;
|
[SerializeField] Button m_Close;
|
|
int m_SelectReiki = 0;
|
int selectReiki
|
{
|
get { return m_SelectReiki; }
|
set
|
{
|
if (m_SelectReiki != value)
|
{
|
m_SelectReiki = value;
|
Display();
|
}
|
}
|
}
|
|
|
ReikiRootModel model { get { return ModelCenter.Instance.GetModel<ReikiRootModel>(); } }
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
m_Close.AddListener(CloseClick);
|
m_ScrollerControl.OnRefreshCell += OnRefreshCell;
|
for (int i = 0; i < m_ReikiRootButtons.Length; i++)
|
{
|
var index = i;
|
m_ReikiRootButtons[i].button.SetListener(() =>
|
{
|
OnSelectReiki(index);
|
});
|
}
|
}
|
|
protected override void OnPreOpen()
|
{
|
var list = new List<int>(model.reikiRoots);
|
list.Sort((x, y) =>
|
{
|
var lhs_quality = model.GetReikiRootQuality(x);
|
var rhs_quality = model.GetReikiRootQuality(y);
|
if (lhs_quality != rhs_quality)
|
{
|
return -lhs_quality.CompareTo(rhs_quality);
|
}
|
return x.CompareTo(y);
|
});
|
|
m_SelectReiki = list[0];
|
}
|
|
protected override void OnActived()
|
{
|
base.OnActived();
|
Display();
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
#endregion
|
|
void Display()
|
{
|
DisplayBase();
|
DisplaySelect();
|
DisplayQualitys();
|
}
|
|
void DisplayBase()
|
{
|
m_ReikiIcon.SetSprite("XT_LG_" + selectReiki);
|
var job = PlayerDatas.Instance.baseData.Job;
|
var totalPropertys = model.qualityPropertySorts[job];
|
for (int i = 0; i < m_PropertyNames.Length; i++)
|
{
|
m_PropertyNames[i].SetActive(i < totalPropertys.Count);
|
if (i < totalPropertys.Count)
|
{
|
var config = PlayerPropertyConfig.Get(totalPropertys[i]);
|
m_PropertyNames[i].text = config.Name;
|
}
|
}
|
}
|
|
void DisplayQualitys()
|
{
|
var max = model.GetMaxReikiRootQuality(selectReiki);
|
m_ScrollerControl.Refresh();
|
var index = 0;
|
for (int i = 1; i <= max; i++)
|
{
|
m_ScrollerControl.AddCell(ScrollerDataType.Header, i);
|
if (i == model.GetReikiRootQuality(selectReiki))
|
{
|
index = i - 1;
|
}
|
}
|
m_ScrollerControl.Restart();
|
|
m_ScrollerControl.JumpIndex(index);
|
}
|
|
void DisplaySelect()
|
{
|
for (int i = 0; i < m_ReikiRootButtons.Length; i++)
|
{
|
m_ReikiRootButtons[i].select.SetActive(i == model.reikiRoots.IndexOf(selectReiki));
|
var imageEx = m_ReikiRootButtons[i].button.image as ImageEx;
|
imageEx.gray = i != model.reikiRoots.IndexOf(selectReiki);
|
}
|
}
|
|
private void OnSelectReiki(int index)
|
{
|
selectReiki = model.reikiRoots[index];
|
}
|
|
private void OnRefreshCell(ScrollerDataType type, CellView cell)
|
{
|
var qualityCell = cell as ReikiQualityCell;
|
qualityCell.Display(selectReiki, cell.index);
|
}
|
|
[Serializable]
|
public class ReikiRootButton
|
{
|
public Button button;
|
public Transform select;
|
}
|
}
|
|
}
|
|
|
|
|