//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Saturday, January 06, 2018
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
|
public class TitleDetailsWin : Window
|
{
|
[SerializeField] List<PropertyBehaviour> m_Propertys;
|
[SerializeField] Text m_TitleDescription;
|
[SerializeField] Text m_TitleTime;
|
[SerializeField] Image m_TitleIcon;
|
[SerializeField] RectTransform m_ContainerSkill;
|
[SerializeField] Text m_SkillDescription;
|
[SerializeField] Button m_CloseBtn;
|
|
[SerializeField, Header("技能名字色")] string m_SkillNameHexColor;
|
|
TitleModel m_Model;
|
TitleModel model
|
{
|
get
|
{
|
return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<TitleModel>());
|
}
|
}
|
|
DienstgradConfig titleConfig = null;
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
m_CloseBtn.onClick.AddListener(CloseClick);
|
}
|
|
protected override void OnPreOpen()
|
{
|
titleConfig = DienstgradConfig.Get(model.presentSelectTitle);
|
if (titleConfig == null)
|
{
|
return;
|
}
|
DisplayTitleTime();
|
DisplayTitle();
|
DisplayProperty();
|
DisplaySkill();
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
|
float timer = 0f;
|
float delay = 0.5f;
|
protected override void LateUpdate()
|
{
|
base.LateUpdate();
|
if (titleConfig == null || titleConfig.Prescription == 0)
|
{
|
return;
|
}
|
timer += Time.deltaTime;
|
if (timer >= delay)
|
{
|
timer = 0;
|
DisplayTitleTime();
|
}
|
}
|
#endregion
|
|
private void DisplayTitle()
|
{
|
m_TitleIcon.SetSprite(titleConfig.Image);
|
m_TitleDescription.text = titleConfig.Content;
|
}
|
|
private void DisplayTitleTime()
|
{
|
if (!model.IsTitleGain(model.presentSelectTitle))
|
{
|
m_TitleTime.text = Language.Get("L1057");
|
m_TitleTime.color = UIHelper.GetUIColor(TextColType.Red);
|
}
|
else
|
{
|
m_TitleTime.color = UIHelper.GetUIColor(TextColType.Green);
|
TitleData title = model.GetGainTitle(model.presentSelectTitle);
|
if (titleConfig.Prescription == 0)
|
{
|
m_TitleTime.text = Language.Get("L1058");
|
if (!titleConfig.OutTimeDesc.Equals(string.Empty))
|
{
|
m_TitleTime.text = titleConfig.OutTimeDesc;
|
}
|
}
|
else
|
{
|
int surplusSeconds = model.GetTitleSurplusSeconds(model.presentSelectTitle);
|
if (surplusSeconds > 0)
|
{
|
m_TitleTime.text = StringUtility.Contact(TimeUtility.SecondsToTitleDHMS(surplusSeconds), Language.Get("TitleCoolDown"));
|
}
|
else
|
{
|
m_TitleTime.text = Language.Get("TitleOutTime");
|
m_TitleTime.color = UIHelper.GetUIColor(TextColType.Red);
|
}
|
}
|
}
|
}
|
|
private void DisplayProperty()
|
{
|
int[] _types = titleConfig.LightType;
|
int[] _values = titleConfig.LightAttribute;
|
for (int i = 0; i < m_Propertys.Count; i++)
|
{
|
if (_types == null || i >= _types.Length)
|
{
|
m_Propertys[i].gameObject.SetActive(false);
|
}
|
else
|
{
|
m_Propertys[i].gameObject.SetActive(true);
|
m_Propertys[i].DisplayUpper(_types[i], _values[i]);
|
}
|
}
|
}
|
|
private void DisplaySkill()
|
{
|
var _skills = titleConfig.Skills;
|
m_ContainerSkill.gameObject.SetActive(_skills != null && _skills.Length > 0);
|
if (_skills != null && _skills.Length > 0)
|
{
|
var skill = _skills[0];
|
var config = SkillConfig.Get(skill);
|
if (config != null)
|
{
|
m_SkillDescription.text = StringUtility.Contact("<color=#", m_SkillNameHexColor, ">", config.SkillName, ":", "</color>", config.Description);
|
}
|
}
|
}
|
}
|
}
|
|
|
|
|