//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Thursday, September 07, 2017
|
//--------------------------------------------------------
|
|
using Snxxz.UI;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
|
namespace Snxxz.UI {
|
|
public class GuardianWin : Window
|
{
|
|
#region 成员变量
|
[SerializeField]
|
GuardTip guardTip;
|
[SerializeField]
|
BuyGuardTip buyTip;
|
[SerializeField]
|
CanvasGroup guardTipAlpha;
|
[SerializeField]
|
CanvasGroup buyTipAlpha;
|
#endregion
|
|
private List<GameObject> TempCreatelist = new List<GameObject>();
|
|
ItemTipsModel _itemTipsModel;
|
ItemTipsModel itemTipsModel
|
{
|
get
|
{
|
return _itemTipsModel ?? (_itemTipsModel = ModelCenter.Instance.GetModel<ItemTipsModel>());
|
}
|
}
|
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
}
|
|
protected override void OnPreOpen()
|
{
|
KnapSackEventMgr.Instance.AddGuardWinTempObjEvent = AddTempCreatelist;
|
KnapSackEventMgr.Instance.HideGuardWinEvent = OnHidePanel;
|
guardTipAlpha.alpha = 0;
|
buyTipAlpha.alpha = 0;
|
UIShow();
|
}
|
|
protected override void OnAfterOpen()
|
{
|
this.transform.SetAsLastSibling();
|
}
|
|
protected override void OnPreClose()
|
{
|
for (int i = 0; i < TempCreatelist.Count; i++)
|
{
|
Destroy(TempCreatelist[i]);
|
}
|
TempCreatelist.Clear();
|
guardTip.gameObject.SetActive(false);
|
buyTip.gameObject.SetActive(false);
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
#endregion
|
|
public void UIShow()
|
{
|
if (itemTipsModel.compareAttrData == null)
|
{
|
if (itemTipsModel.curAttrData != null)
|
{
|
switch (itemTipsModel.curAttrData.ChildType)
|
{
|
case ItemTipChildType.Normal:
|
guardTip.InitModel(itemTipsModel.curAttrData);
|
guardTip.gameObject.SetActive(true);
|
break;
|
case ItemTipChildType.Buy:
|
buyTip.InitModel(itemTipsModel.curAttrData);
|
buyTip.gameObject.SetActive(true);
|
break;
|
}
|
|
}
|
}
|
else
|
{
|
if (itemTipsModel.curAttrData != null)
|
{
|
switch (itemTipsModel.curAttrData.ChildType)
|
{
|
case ItemTipChildType.Normal:
|
GuardTip compareTip = CloneEquipUI(this.transform, guardTip.gameObject).GetComponent<GuardTip>();
|
compareTip.InitModel(itemTipsModel.compareAttrData);
|
TempCreatelist.Add(compareTip.gameObject);
|
guardTip.InitModel(itemTipsModel.curAttrData);
|
compareTip.gameObject.SetActive(true);
|
guardTip.gameObject.SetActive(true);
|
break;
|
case ItemTipChildType.Buy:
|
buyTip.InitModel(itemTipsModel.curAttrData);
|
guardTip.InitModel(itemTipsModel.compareAttrData);
|
buyTip.gameObject.SetActive(true);
|
guardTip.gameObject.SetActive(true);
|
break;
|
}
|
}
|
}
|
}
|
|
public GameObject CloneEquipUI(Transform parent, GameObject target)
|
{
|
GameObject go = Instantiate(target);
|
go.transform.SetParent(parent);
|
go.transform.localPosition = Vector3.zero;
|
go.transform.localScale = Vector3.one;
|
return go;
|
}
|
|
public void OnHidePanel()
|
{
|
|
CloseImmediately();
|
}
|
|
private void AddTempCreatelist(GameObject obj)
|
{
|
TempCreatelist.Add(obj);
|
}
|
|
}
|
}
|