Files
JJBB/Assets/Project/Script/GUI/Interaction/MarryInteractionItem.cs
2024-08-23 15:49:34 +08:00

111 lines
3.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using GCGame.Table;
public class MarryInteractionItem : UIItemBase {
public List<Image> _TypeIcon;
public Text titleDesc;
public UIContainerBase rewContainer;
public Text rewDesc;
public GameObject _GetBtn;
public GameObject _GetedBtn;
public GameObject _BanQuetBtn;
public GameObject redIcon;
public int interactionNodeId = -1;
private int curInteractionNodeType = -1;
public override void Show(Hashtable hash)
{
base.Show(hash);
interactionNodeId = (int)hash["InitObj"];
var nodeTab = TableManager.GetInteractionNodeByID(interactionNodeId, 0);
if(nodeTab == null)
{
gameObject.SetActive(false);
return;
}
for(int index = 0; index < _TypeIcon.Count; index++)
{
_TypeIcon[index].gameObject.SetActive(index == int.Parse(nodeTab.Param) - 1);
}
titleDesc.text = nodeTab.Title;
if (interactionNodeId == 4)
{
rewDesc.gameObject.SetActive(false);
rewDesc.text = "";
}
else
{
rewDesc.gameObject.SetActive(true);
rewDesc.text = StrDictionary.GetClientDictionaryString("#{ " + nodeTab.RewDescStrdicId + "}");
}
curInteractionNodeType = nodeTab.InteractiveType;
InitOriginState();
var itemList = new List<InteractionRewItem.InteractionRewItemData>();
for (int index = 0; index < nodeTab.getRewardCount(); index++)
{
if(nodeTab.GetRewardbyIndex(index) != -1)
{
InteractionRewItem.InteractionRewItemData item = new InteractionRewItem.InteractionRewItemData(nodeTab.GetRewardbyIndex(index), nodeTab.GetNumbyIndex(index));
itemList.Add(item);
}
}
rewContainer.InitContentItem(itemList);
}
//初始一个不可以领取的状态
public void InitOriginState()
{
if(interactionNodeId == 4)
{
_BanQuetBtn.SetActive(true);
}
else
{
_BanQuetBtn.SetActive(false);
}
_GetBtn.SetActive(false);
_GetedBtn.SetActive(false);
rewDesc.gameObject.SetActive(true);
redIcon.SetActive(false);
}
public void RefreshMarryInteractionItemState(int state)
{
if(interactionNodeId == 4)
{
if((state == 1 || state == 2))
_BanQuetBtn.SetActive(false);
else
_BanQuetBtn.SetActive(true);
}
else
{
_BanQuetBtn.SetActive(false);
}
_GetBtn.SetActive(state == 1);
_GetedBtn.SetActive(state == 2);
rewDesc.gameObject.SetActive(state < 1);
redIcon.SetActive(state == 1);
}
public void OnBnquQuetBtn()
{
MarryInteractionPanelCtr.Instance.OnGoForMarryBtnClick();
}
public void OnGetBtnClick()
{
ReqGetInteractionRew req = new ReqGetInteractionRew();
req._type = curInteractionNodeType;
req._nodeId = interactionNodeId;
req.SendMsg();
}
}