//--------------------------------------------------------
|
// [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);
|
|
GatheringSoulModel model
|
{
|
get { return ModelCenter.Instance.GetModel<GatheringSoulModel>(); }
|
}
|
|
ItemTipUtility.TipData tipData
|
{
|
get { return ItemTipUtility.mainTipData; }
|
}
|
|
#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()
|
{
|
var packType = ItemTipUtility.mainTipData.gatherSoul.packType;
|
m_EquipedSign.gameObject.SetActive(packType == PackType.InterimPack);
|
}
|
|
void Display()
|
{
|
var id = tipData.itemId;
|
var level = tipData.gatherSoul.level;
|
m_Base.Display(id, level);
|
m_Property.Display(id, level);
|
m_Resolve.Display(id, level);
|
}
|
|
void DisplayGetWay()
|
{
|
var config = ItemConfig.Get(tipData.itemId);
|
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 operates = tipData.operates;
|
var index = 0;
|
if (operates != null)
|
{
|
foreach (var type in operates)
|
{
|
var callBackType = type;
|
if (index < m_Funcs.Length)
|
{
|
m_Funcs[index].gameObject.SetActive(true);
|
m_Funcs[index].RemoveAllListeners();
|
m_Funcs[index].AddListener(() =>
|
{
|
ItemTipUtility.GatherSoulOperate(callBackType);
|
});
|
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
|
&& tipData.gatherSoul.packType == PackType.InterimPack
|
&& model.levelUpRedpointHole == tipData.gatherSoul.index);
|
}
|
else if (callBackType == ItemOperateType.Replace)
|
{
|
m_Redpoints[index].gameObject.SetActive(model.replaceRedpoint.state == RedPointState.Simple
|
&& tipData.gatherSoul.packType == PackType.GatherSoul
|
&& tipData.gatherSoul.index == model.replaceRedpointIndex);
|
}
|
}
|
index++;
|
}
|
}
|
for (int i = index; i < m_Funcs.Length; i++)
|
{
|
m_Funcs[i].gameObject.SetActive(false);
|
}
|
}
|
}
|
}
|
|
|
|
|