Files
JJBB/Assets/Project/Script/GUI/Interaction/BtnInteraction.cs

83 lines
2.1 KiB
C#
Raw Normal View History

2024-08-23 15:49:34 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using GCGame.Table;
public class BtnInteraction : MonoBehaviour {
public GameObject _ItemIcon;
public GameObject _redIcon;
public static BtnInteraction Instance;
private LayoutElement _LayoutElement;
private void Awake()
{
Instance = this;
}
private void OnDestroy()
{
Instance = null;
}
private void OnEnable()
{
//if (_ItemIcon.activeInHierarchy)
// _ItemIcon.SetActive(false);
//ReqInteractionState();
if (_LayoutElement == null)
_LayoutElement = gameObject.GetComponent<LayoutElement>();
gameObject.SetActive(false);
_LayoutElement.ignoreLayout = true;
}
public void ReqInteractionState()
{
ReqInteractionActivityState req = new ReqInteractionActivityState();
req._flag = 1;
req.SendMsg();
}
public void OnPacket(int state, int _isShow)
{
_redIcon.SetActive(_isShow == 1);
if (_LayoutElement == null)
_LayoutElement = gameObject.GetComponent<LayoutElement>();
if (state == 1)
{
var functionTab = TableManager.GetFunctionOpenByID(104, 0);
if(functionTab == null)
{
_ItemIcon.SetActive(false);
_LayoutElement.ignoreLayout = true;
return;
}
if(GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level < functionTab.ShowLevel)
{
gameObject.SetActive(false);
_LayoutElement.ignoreLayout = true;
return;
}
gameObject.SetActive(true);
_ItemIcon.SetActive(true);
_LayoutElement.ignoreLayout = false;
}
else
{
gameObject.SetActive(false);
_LayoutElement.ignoreLayout = true;
}
}
public void ShowRedIcon(bool isShow)
{
_redIcon.SetActive(isShow);
}
public void OnItemClick()
{
UIManager.ShowUI(UIInfo.InteractionPanel);
}
}