//--------------------------------------------------------
|
// [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.secondaryData != null)
|
{
|
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()
|
{
|
var operates = EquipTipUtility.mainTipData.operates;
|
var guid = EquipTipUtility.mainTipData.guid;
|
if (operates.IsNullOrEmpty())
|
{
|
for (int i = 0; i < m_OpreateButtons.Length; i++)
|
{
|
var button = m_OpreateButtons[i];
|
button.SetActive(false);
|
}
|
}
|
else
|
{
|
for (int i = 0; i < m_OpreateButtons.Length; i++)
|
{
|
var button = m_OpreateButtons[i];
|
if (i < operates.Count)
|
{
|
button.SetActive(true);
|
button.Bind(operates[i], guid);
|
}
|
else
|
{
|
button.SetActive(false);
|
}
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
[Serializable]
|
public class WidgetGroup
|
{
|
public RectTransform container;
|
public ScrollRect scrollRect;
|
public TipEquipBaseInfoWidget baseInfoWidget;
|
public TipBasePropertyWidget basePropertyWidget;
|
public TipLegendPropertyWidget legendPropertyWidget;
|
public TipSkillInfoWidget skillInfoWidget;
|
public TipSuitBriefWidget suitBriefWidget;
|
public TipSuitPropertyWidget suitPropertyWidget;
|
public TipGemInfoWidget gemInfoWidget;
|
public TipStarPropertyWidget starInfoWidget;
|
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)
|
{
|
scrollRect.verticalNormalizedPosition = 1f;
|
|
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 hasSkill = !data.skillInfo.skills.IsNullOrEmpty();
|
skillInfoWidget.gameObject.SetActive(hasSkill);
|
if (hasSkill)
|
{
|
skillInfoWidget.Display(data.skillInfo);
|
}
|
|
var hasSuit = data.suitInfo.places != null;
|
if (hasSuit)
|
{
|
if (data.suitInfo.twoSuitProperties != null && data.suitInfo.fiveSuitProperties != null && data.suitInfo.eightSuits != null)
|
{
|
suitPropertyWidget.gameObject.SetActive(true);
|
suitBriefWidget.gameObject.SetActive(false);
|
suitPropertyWidget.Display(data.suitInfo);
|
}
|
else
|
{
|
suitPropertyWidget.gameObject.SetActive(false);
|
suitBriefWidget.gameObject.SetActive(true);
|
suitBriefWidget.Display(data.suitInfo);
|
}
|
}
|
else
|
{
|
suitPropertyWidget.gameObject.SetActive(false);
|
suitBriefWidget.gameObject.SetActive(false);
|
}
|
|
var hasStar = data.starInfo.maxLevel > 0;
|
starInfoWidget.gameObject.SetActive(hasStar);
|
if (hasStar)
|
{
|
starInfoWidget.Display(data.starInfo);
|
}
|
|
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 = Language.Get("StoreWin110");
|
}
|
|
equipPlace.text = Language.Get("EquipWin_PartTitleText_1") + UIHelper.GetEquipPlaceName(itemConfig.EquipPlace);
|
}
|
|
}
|
|
[Serializable]
|
public class OperateButton
|
{
|
public RectTransform container;
|
public Button button;
|
public Text title;
|
|
ItemOperateType operateType;
|
string guid;
|
|
public void SetActive(bool active)
|
{
|
container.gameObject.SetActive(active);
|
}
|
|
public void Bind(ItemOperateType type, string guid)
|
{
|
operateType = type;
|
this.guid = guid;
|
switch (type)
|
{
|
case ItemOperateType.putOn:
|
this.title.text = "穿上";
|
break;
|
case ItemOperateType.putOff:
|
this.title.text = "脱下";
|
break;
|
case ItemOperateType.putAway:
|
this.title.text = "上架";
|
break;
|
case ItemOperateType.strength:
|
this.title.text = "强化";
|
break;
|
case ItemOperateType.star:
|
this.title.text = "升星";
|
break;
|
case ItemOperateType.inlay:
|
this.title.text = "镶嵌";
|
break;
|
case ItemOperateType.train:
|
this.title.text = "洗炼";
|
break;
|
case ItemOperateType.sell:
|
this.title.text = "出售";
|
break;
|
case ItemOperateType.putOut:
|
this.title.text = "取出";
|
break;
|
case ItemOperateType.putIn:
|
this.title.text = "放入";
|
break;
|
default:
|
this.title.text = "";
|
break;
|
}
|
|
button.SetListener(() =>
|
{
|
WindowCenter.Instance.Close<EquipTipWin>();
|
EquipTipUtility.Operate(operateType, this.guid);
|
});
|
}
|
|
}
|
|
|
}
|
|
}
|