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

106 lines
3.1 KiB
C#

using GCGame.Table;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CommonMenuItemContainerBase : MonoBehaviour {
//记录配套使用的MenuItem
public GameObject _CommonMenuItemPrafab;
public List<CommonMenuItemBase> _MenuItemList;
public List<GameObject> _PanelList;
public GameObject _NoDataPanel;
public Text _Desc;
public int _CurSelectIndex = -1;
public void OnCommonMenuItemClick(int _index = 0)
{
_CurSelectIndex = _index;
for (int index = 0; index < _MenuItemList.Count; index++)
{
_MenuItemList[index].ShowMask(index == _index);
if (!isShowNoDataPanel)
_PanelList[index].SetActive(index == _index);
else
_PanelList[index].SetActive(false);
}
}
private void OnDisable()
{
_CurSelectIndex = -1;
}
public void ShowDefaultFirst(int index = 0)
{
OnCommonMenuItemClick(index);
}
private bool isShowNoDataPanel = false;
public void ShowNoDataPanel(bool isShow)
{
isShowNoDataPanel = isShow;
if (isShowNoDataPanel)
{
if (_NoDataPanel)
_NoDataPanel.SetActive(true);
HidelAllFuncPanel();
} else
{
if (_NoDataPanel)
_NoDataPanel.SetActive(false);
OnCommonMenuItemClick(_CurSelectIndex);
}
}
void HidelAllFuncPanel()
{
for (int index = 0; index < _PanelList.Count; index++)
_PanelList[index].SetActive(false);
InitDesc();
}
void InitDesc()
{
_Desc.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{86812}");
}
private const int marryNpcAutosearchId = 9008;
public void OnEmbBtn()
{
if (GameManager.gameManager.m_RunningScene == 658)
{
GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{79512}"));
return;
}
//UIManager.ShowUI(UIInfo.WeddingOperationPanel);
Tab_AutoSearch autoSearch = TableManager.GetAutoSearchByID(marryNpcAutosearchId, 0);
if (autoSearch == null)
{
return;
}
Vector3 pos = new Vector3();
pos.x = autoSearch.X;
pos.z = autoSearch.Z;
int sceneId = autoSearch.DstSceneID;
AutoSearchPoint targetPoint = new AutoSearchPoint(sceneId, pos.x, pos.z);
if (GameManager.gameManager && GameManager.gameManager.AutoSearch)
{
GameManager.gameManager.AutoSearch.BuildPath(targetPoint);
Tab_RoleBaseAttr RoleBase = TableManager.GetRoleBaseAttrByID(autoSearch.DataId, 0);
if (null != RoleBase && null != GameManager.gameManager.AutoSearch.Path)
{
GameManager.gameManager.AutoSearch.Path.AutoSearchTargetName = RoleBase.Name;
GameManager.gameManager.AutoSearch.Path.autoSearchRadius = RoleBase.DialogRadius;
}
}
UIManager.CloseUI(UIInfo.ChildPanel);
}
}