//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Tuesday, March 12, 2019
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using UnityEngine.Events;
|
|
namespace Snxxz.UI
|
{
|
|
public class EquipTipWin : Window
|
{
|
[SerializeField] RectTransform m_LeftPoint;
|
[SerializeField] RectTransform m_MiddlePoint;
|
[SerializeField] RectTransform m_RightPoint;
|
|
[SerializeField] WidgetGroup m_MainWidgetGroup;
|
[SerializeField] WidgetGroup m_SecondaryWidgetGroup;
|
|
[SerializeField] OperateButton[] m_OpreateButtons;
|
[SerializeField] Button m_Close;
|
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
m_Close.SetListener(() => { WindowCenter.Instance.Close<EquipTipWin>(); });
|
}
|
|
protected override void OnPreOpen()
|
{
|
DisplayTipInfo();
|
InitOperateButton();
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
|
private void DisplayTipInfo()
|
{
|
if (EquipTipUtility.tipType == EquipTipType.EquipCompare)
|
{
|
m_MainWidgetGroup.SetActive(true);
|
m_MainWidgetGroup.SetPosition(m_RightPoint.position);
|
m_MainWidgetGroup.Display(EquipTipUtility.mainTipData);
|
|
m_SecondaryWidgetGroup.SetActive(true);
|
m_SecondaryWidgetGroup.SetPosition(m_LeftPoint.position);
|
m_SecondaryWidgetGroup.Display(EquipTipUtility.secondaryData);
|
}
|
else
|
{
|
m_MainWidgetGroup.SetActive(true);
|
m_MainWidgetGroup.SetPosition(m_MiddlePoint.position);
|
m_MainWidgetGroup.Display(EquipTipUtility.mainTipData);
|
|
m_SecondaryWidgetGroup.SetActive(false);
|
}
|
}
|
|
private void InitOperateButton()
|
{
|
if (string.IsNullOrEmpty(EquipTipUtility.mainTipData.guid))
|
{
|
foreach (var button in m_OpreateButtons)
|
{
|
button.SetActive(false);
|
}
|
}
|
else
|
{
|
var actions = new Dictionary<ItemOperateType, UnityAction>();
|
if (EquipTipUtility.mainTipData.baseInfo.isAuction)
|
{
|
actions[ItemOperateType.putAway] = () => { };
|
}
|
else
|
{
|
|
|
}
|
|
var actionKeys = new List<ItemOperateType>(actions.Keys);
|
for (int i = 0; i < m_OpreateButtons.Length; i++)
|
{
|
var button = m_OpreateButtons[i];
|
if (i < actionKeys.Count)
|
{
|
var action = actions[actionKeys[i]];
|
button.SetActive(true);
|
button.Bind(actionKeys[i], action);
|
}
|
}
|
|
}
|
}
|
|
#endregion
|
|
[Serializable]
|
public class WidgetGroup
|
{
|
public RectTransform container;
|
public TipBaseInfoWidget baseInfoWidget;
|
public TipBasePropertyWidget basePropertyWidget;
|
public TipLegendPropertyWidget legendPropertyWidget;
|
public TipSuitPropertyWidget suitPropertyWidget;
|
public TipGemInfoWidget gemInfoWidget;
|
public TipStrengthenPropertyWidget strengthenPropertyWidget;
|
public TipTrainPropertyWidget trainPropertyWidget;
|
public TipAuctionTipWidget auctionTipWidget;
|
public Text job;
|
public Text equipPlace;
|
|
public void SetActive(bool active)
|
{
|
this.container.gameObject.SetActive(active);
|
}
|
|
public void SetPosition(Vector3 position)
|
{
|
this.container.position = position;
|
}
|
|
public void Display(EquipTipUtility.TipData data)
|
{
|
baseInfoWidget.gameObject.SetActive(true);
|
baseInfoWidget.Display(data.baseInfo);
|
|
basePropertyWidget.gameObject.SetActive(true);
|
basePropertyWidget.Display(data.baseProperty);
|
|
var hasLegendProperty = !data.legendProperty.properties.IsNullOrEmpty();
|
legendPropertyWidget.gameObject.SetActive(hasLegendProperty);
|
if (hasLegendProperty)
|
{
|
legendPropertyWidget.Display(data.legendProperty);
|
}
|
|
var hasSuit = !data.suitInfo.twoSuitProperties.IsNullOrEmpty();
|
suitPropertyWidget.gameObject.SetActive(hasSuit);
|
if (hasSuit)
|
{
|
suitPropertyWidget.Display(data.suitInfo);
|
}
|
|
var hasGem = !data.gemInfo.activeStates.IsNullOrEmpty();
|
gemInfoWidget.gameObject.SetActive(hasGem);
|
if (hasGem)
|
{
|
gemInfoWidget.Display(data.gemInfo);
|
}
|
|
var hasStrengthen = !data.strengthenProperty.properties.IsNullOrEmpty();
|
strengthenPropertyWidget.gameObject.SetActive(hasStrengthen);
|
if (hasStrengthen)
|
{
|
strengthenPropertyWidget.Display(data.strengthenProperty);
|
}
|
|
var hasTrain = !data.trainProperty.properties.IsNullOrEmpty();
|
trainPropertyWidget.gameObject.SetActive(hasTrain);
|
if (hasTrain)
|
{
|
trainPropertyWidget.Display(data.trainProperty);
|
}
|
|
auctionTipWidget.gameObject.SetActive(data.baseInfo.isAuction);
|
if (data.baseInfo.isAuction)
|
{
|
var overdueTime = DateTime.Now.AddSeconds((double)data.baseInfo.auctionSurplusTime);
|
auctionTipWidget.Display(overdueTime);
|
}
|
|
var itemConfig = ItemConfig.Get(data.itemId);
|
if (JobNameConfig.Has(itemConfig.JobLimit))
|
{
|
job.text = Language.Get("EquipWin_JobTitleText_1") + JobNameConfig.Get(itemConfig.JobLimit).name;
|
}
|
else
|
{
|
job.text = "";
|
}
|
|
equipPlace.text = Language.Get("EquipWin_PartTitleText_1") + UIHelper.GetEquipPlaceName(itemConfig.EquipPlace);
|
}
|
|
}
|
|
[Serializable]
|
public class OperateButton
|
{
|
public RectTransform container;
|
public Button button;
|
public Text title;
|
|
public void SetActive(bool active)
|
{
|
container.gameObject.SetActive(active);
|
}
|
|
public void Bind(ItemOperateType type, UnityAction action)
|
{
|
switch (type)
|
{
|
case ItemOperateType.makeUse:
|
this.title.text = "使用";
|
break;
|
case ItemOperateType.inlay:
|
this.title.text = "使用";
|
break;
|
}
|
|
this.button.SetListener(action);
|
}
|
|
}
|
|
|
}
|
|
}
|