//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Tuesday, December 11, 2018
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
[XLua.Hotfix]
|
public class GatherSoulTipWin : Window
|
{
|
[SerializeField] CanvasGroup m_CanvaGroup;
|
[SerializeField] Image m_EquipedSign;
|
[SerializeField] GatherSoulTipBase m_Base;
|
[SerializeField] ScrollRect m_Scroller;
|
[SerializeField] LayoutElement m_ScrollerLayout;
|
[SerializeField] VerticalLayoutGroup m_ContentLayout;
|
[SerializeField] GatherSoulTipProperty m_Property;
|
[SerializeField] GatherSoulTipResolve m_Resolve;
|
[SerializeField] RectTransform m_ContainerGetWay;
|
[SerializeField] Button[] m_Funcs;
|
[SerializeField] Text[] m_FuncBtnDisplays;
|
[SerializeField] RectTransform[] m_Redpoints;
|
[SerializeField] Text m_GetWay;
|
|
[SerializeField] Button m_Close;
|
|
[SerializeField] Vector2 m_ScrollerHeight = new Vector2(180, 260);
|
|
ItemTipsModel itemTipsModel
|
{
|
get { return ModelCenter.Instance.GetModel<ItemTipsModel>(); }
|
}
|
|
GatheringSoulModel model
|
{
|
get { return ModelCenter.Instance.GetModel<GatheringSoulModel>(); }
|
}
|
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
m_Close.onClick.AddListener(CloseClick);
|
}
|
|
protected override void OnPreOpen()
|
{
|
DisplayEquipedSign();
|
Display();
|
DisplayGetWay();
|
DisplayFuncs();
|
|
m_CanvaGroup.alpha = 0;
|
m_Scroller.verticalNormalizedPosition = 1;
|
}
|
|
protected override void OnActived()
|
{
|
base.OnActived();
|
transform.SetAsLastSibling();
|
StartCoroutine(Co_GetHeight());
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
StopAllCoroutines();
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
#endregion
|
|
IEnumerator Co_GetHeight()
|
{
|
yield return null;
|
yield return null;
|
var height = m_Property.GetHeight();
|
height += m_Resolve.GetHeight();
|
height += m_ContentLayout.padding.top;
|
height += m_ContentLayout.padding.bottom;
|
height += m_ContentLayout.spacing * 1;
|
height = Mathf.Clamp(height, m_ScrollerHeight.x, m_ScrollerHeight.y);
|
m_ScrollerLayout.preferredHeight = height;
|
yield return null;
|
m_CanvaGroup.alpha = 1;
|
}
|
|
void DisplayEquipedSign()
|
{
|
m_EquipedSign.gameObject.SetActive(itemTipsModel.curAttrData.equipHole != -1);
|
}
|
|
void Display()
|
{
|
var id = itemTipsModel.curAttrData.itemId;
|
var level = itemTipsModel.curAttrData.level;
|
m_Base.Display(id, level);
|
m_Property.Display(id, level);
|
m_Resolve.Display(id, level);
|
}
|
|
void DisplayGetWay()
|
{
|
var config = itemTipsModel.curAttrData.itemConfig;
|
m_ContainerGetWay.gameObject.SetActive(config != null && !string.IsNullOrEmpty(config.Description));
|
if (config != null && !string.IsNullOrEmpty(config.Description))
|
{
|
m_GetWay.text = config.Description;
|
}
|
}
|
|
void DisplayFuncs()
|
{
|
var dict = itemTipsModel.curAttrData.tipsFuncBtnDic;
|
var index = 0;
|
foreach (var type in dict.Keys)
|
{
|
var callBackType = type;
|
if (index < m_Funcs.Length)
|
{
|
m_Funcs[index].gameObject.SetActive(true);
|
m_Funcs[index].RemoveAllListeners();
|
m_Funcs[index].AddListener(() =>
|
{
|
if (dict != null && dict.ContainsKey(callBackType))
|
{
|
if (dict[callBackType] != null)
|
{
|
dict[callBackType](callBackType, string.Empty);
|
}
|
}
|
});
|
m_FuncBtnDisplays[index].text = Language.Get(StringUtility.Contact("ItemHandle_", callBackType));
|
m_Redpoints[index].gameObject.SetActive(false);
|
|
if (callBackType == ItemOperateType.LevelUp)
|
{
|
m_Redpoints[index].gameObject.SetActive(model.levelUpRedpoint.state == RedPointState.Simple
|
&& model.levelUpRedpointHole == itemTipsModel.curAttrData.equipHole);
|
}
|
else if (callBackType == ItemOperateType.Replace)
|
{
|
m_Redpoints[index].gameObject.SetActive(model.replaceRedpoint.state == RedPointState.Simple
|
&& itemTipsModel.curAttrData.index == model.replaceRedpointIndex);
|
}
|
}
|
index++;
|
}
|
for (int i = index; i < m_Funcs.Length; i++)
|
{
|
m_Funcs[i].gameObject.SetActive(false);
|
}
|
}
|
}
|
}
|
|
|
|
|