//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Tuesday, March 12, 2019
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using UnityEngine.Events;
|
|
namespace vnxbqy.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] TipOperateButton[] m_OpreateButtons;
|
[SerializeField] Button m_Close;
|
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
m_Close.SetListener(CloseClick);
|
}
|
|
protected override void OnPreOpen()
|
{
|
DisplayTipInfo();
|
InitOperateButton();
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
m_MainWidgetGroup.Dispose();
|
m_SecondaryWidgetGroup.Dispose();
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
|
private void DisplayTipInfo()
|
{
|
if (ItemTipUtility.secondaryData != null)
|
{
|
m_MainWidgetGroup.SetActive(true);
|
m_MainWidgetGroup.SetPosition(m_RightPoint.position);
|
m_MainWidgetGroup.SetDynamicHeightActive(false);
|
m_MainWidgetGroup.Display(ItemTipUtility.mainTipData);
|
|
m_SecondaryWidgetGroup.SetActive(true);
|
m_SecondaryWidgetGroup.SetPosition(m_LeftPoint.position);
|
m_SecondaryWidgetGroup.SetDynamicHeightActive(false);
|
m_SecondaryWidgetGroup.Display(ItemTipUtility.secondaryData);
|
|
}
|
else
|
{
|
m_MainWidgetGroup.SetActive(true);
|
m_MainWidgetGroup.SetPosition(m_MiddlePoint.position);
|
m_MainWidgetGroup.SetDynamicHeightActive(true);
|
m_MainWidgetGroup.Display(ItemTipUtility.mainTipData);
|
|
m_SecondaryWidgetGroup.SetActive(false);
|
}
|
}
|
|
private void InitOperateButton()
|
{
|
var operates = ItemTipUtility.mainTipData.operates;
|
var guid = ItemTipUtility.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("EquipTipWin", operates[i], guid);
|
}
|
else
|
{
|
button.SetActive(false);
|
}
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
[Serializable]
|
public class WidgetGroup
|
{
|
public RectTransform container;
|
public ScrollRect scrollRect;
|
public LayoutElementSizeClamp sizeClamp;
|
public TipEquipBaseInfoWidget baseInfoWidget;
|
public TipBasePropertyWidget basePropertyWidget;
|
public TipShenPropertyWidget shenPropertyWidget;
|
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 TipJobAndPlaceWidget jobAndPlaceWidget;
|
public TipGetWayEntranceWidget getWayEntranceWidget;
|
public TipGetWaysWidget getWaysWidget;
|
public TipBuyItemWidget buyItemWidget;
|
public TipItemDescriptionWidget itemDescriptionWidget;
|
|
public void SetActive(bool active)
|
{
|
this.container.SetActive(active);
|
}
|
|
public void SetPosition(Vector3 position)
|
{
|
this.container.position = position;
|
}
|
|
public void SetDynamicHeightActive(bool active)
|
{
|
sizeClamp.clampEnable = active;
|
if (!active)
|
{
|
var preferHeight = sizeClamp.clamp.maxY;
|
sizeClamp.preferredHeight = preferHeight;
|
}
|
}
|
|
public void Display(ItemTipUtility.TipData data)
|
{
|
scrollRect.verticalNormalizedPosition = 1f;
|
|
baseInfoWidget.SetActive(true);
|
baseInfoWidget.Display(data.baseInfo);
|
|
var hasBaseProperty=!data.baseProperty.baseProperties.IsNullOrEmpty();
|
basePropertyWidget.SetActive(hasBaseProperty);
|
if (hasBaseProperty)
|
{
|
basePropertyWidget.Display(data.baseProperty);
|
}
|
|
//神装属性
|
var hasShenProperty = !data.shenProperty.properties.IsNullOrEmpty();
|
shenPropertyWidget.SetActive(hasShenProperty);
|
if (hasShenProperty)
|
{
|
shenPropertyWidget.Display(data.shenProperty);
|
}
|
|
var hasLegendProperty = !data.legendProperty.properties.IsNullOrEmpty();
|
legendPropertyWidget.SetActive(hasLegendProperty);
|
if (hasLegendProperty)
|
{
|
legendPropertyWidget.Display(data.legendProperty);
|
}
|
|
var hasSkill = !data.skillInfo.skills.IsNullOrEmpty();
|
skillInfoWidget.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.SetActive(true);
|
suitBriefWidget.SetActive(false);
|
suitPropertyWidget.Display(data.suitInfo);
|
}
|
else
|
{
|
suitPropertyWidget.SetActive(true);
|
suitBriefWidget.SetActive(false);
|
suitPropertyWidget.Display(ItemTipUtility.GetSuitInfo(data.itemId));
|
}
|
}
|
else
|
{
|
suitPropertyWidget.SetActive(false);
|
suitBriefWidget.SetActive(false);
|
}
|
|
var hasStar = data.starInfo.maxLevel > 0;
|
starInfoWidget.SetActive(hasStar);
|
if (hasStar)
|
{
|
starInfoWidget.Display(data.starInfo);
|
}
|
|
var hasGem = !data.gemInfo.activeStates.IsNullOrEmpty();
|
gemInfoWidget.SetActive(hasGem);
|
if (hasGem)
|
{
|
gemInfoWidget.Display(data.gemInfo);
|
}
|
|
var hasStrengthen = false;
|
if (!data.strengthenProperty.properties.IsNullOrEmpty())
|
{
|
var anyValue = 0;
|
foreach (var item in data.strengthenProperty.properties)
|
{
|
anyValue += item.y;
|
}
|
|
hasStrengthen = anyValue > 0;
|
}
|
|
strengthenPropertyWidget.SetActive(hasStrengthen);
|
if (hasStrengthen)
|
{
|
strengthenPropertyWidget.Display(data.strengthenProperty);
|
}
|
|
var hasTrain = false;
|
if (!data.trainProperty.properties.IsNullOrEmpty())
|
{
|
var anyValue = 0;
|
foreach (var item in data.trainProperty.properties)
|
{
|
anyValue += item.y;
|
}
|
|
hasTrain = anyValue > 0;
|
}
|
|
trainPropertyWidget.SetActive(hasTrain);
|
if (hasTrain)
|
{
|
trainPropertyWidget.Display(data.trainProperty);
|
}
|
|
auctionTipWidget.SetActive(false);// data.baseInfo.isAuction);
|
//if (data.baseInfo.isAuction)
|
//{
|
// var overdueTime = TimeUtility.ServerNow.AddSeconds((double)data.baseInfo.auctionSurplusTime);
|
// auctionTipWidget.Display(overdueTime);
|
//}
|
|
if (ItemLogicUtility.Instance.IsRealmEquip(data.itemId))
|
{
|
jobAndPlaceWidget.SetActive(true);
|
jobAndPlaceWidget.Display(data.itemId);
|
}
|
else
|
{
|
jobAndPlaceWidget.SetActive(false);
|
}
|
|
if (buyItemWidget != null)
|
{
|
buyItemWidget.SetActive(data.goodId > 0);
|
if (data.goodId > 0)
|
{
|
buyItemWidget.Display(data.goodId);
|
}
|
}
|
|
if (getWayEntranceWidget != null && getWaysWidget != null)
|
{
|
var getWay = ItemTipUtility.mainTipData.getWay;
|
var hasGetWay = !getWay.ways.IsNullOrEmpty();
|
getWayEntranceWidget.SetActive(hasGetWay);
|
getWaysWidget.SetActive(false);
|
if (hasGetWay)
|
{
|
getWayEntranceWidget.SetListener(() =>
|
{
|
if (!getWaysWidget.gameObject.activeSelf)
|
{
|
getWaysWidget.Display(getWay);
|
getWaysWidget.Bind("EquipTipWin");
|
}
|
else
|
{
|
getWaysWidget.Hide();
|
}
|
});
|
|
if (getWay.defaultUnfold)
|
{
|
getWaysWidget.Display(getWay);
|
getWaysWidget.Bind("EquipTipWin");
|
}
|
}
|
}
|
|
if (itemDescriptionWidget != null)
|
{
|
var config = ItemConfig.Get(data.itemId);
|
if (!string.IsNullOrEmpty(config.Description))
|
{
|
itemDescriptionWidget.SetActive(true);
|
itemDescriptionWidget.Display(data.itemId);
|
}
|
else
|
{
|
itemDescriptionWidget.SetActive(false);
|
}
|
}
|
}
|
|
public void Dispose()
|
{
|
if (buyItemWidget != null)
|
{
|
buyItemWidget.Dispose();
|
}
|
}
|
|
}
|
|
|
}
|
|
}
|