Files
JJBB/Assets/Project/Script/GUI/StroyCopy/CopyScenePanelCtr.cs

152 lines
4.3 KiB
C#
Raw Permalink Normal View History

2024-08-23 15:49:34 +08:00
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.Collections.Generic;
public class CopyScenePanelCtr : MonoBehaviour
{
#region static
public static void ShowCopyScene()
{
UIManager.ShowUI(UIInfo.CopyScenePanelCtr);
}
public static void ShowCopyScenePage(string pageStr, string tagStr)
{
int page = int.Parse(pageStr);
int tag = int.Parse(tagStr);
UIManager.ShowUI(UIInfo.CopyScenePanelCtr, (sucess, param)=>
{
CopyScenePanelCtr.Instance.ShowPage(page);
CopyScenePanelCtr.Instance.OnMenuItemClick(page, tag);
});
}
#endregion
private int _UnLockTestingCopyLevel;
public GameObject _TestingUnLockPanel;
public GameObject _TestingLockPanel;
public List<GameObject> remainTimeIconList;
public List<Text> reaminTimeTextList;
public static CopyScenePanelCtr Instance;
private void Awake()
{
GetUnLockLevel();
}
private void OnEnable()
{
Instance = this;
ShowDefaultFirst();
ShowRemainTimeIcon();
}
private void OnDisable()
{
Instance = null;
}
public void ShowRemainTimeIcon()
{
for (int index = 0; index < GameManager.gameManager.PlayerDataPool.FunctionRemainTimeStateManager.copyBaseRemainTimeStateList.Length; index++)
{
int totalTime = GameManager.gameManager.PlayerDataPool.FunctionRemainTimeStateManager.copyBaseRemainTimeStateList[index].totalRemainTimes;
remainTimeIconList[index].SetActive(totalTime > 0);
if (remainTimeIconList[index].gameObject.activeInHierarchy)
{
reaminTimeTextList[index].text = (totalTime >= 99 ? 99 : totalTime).ToString();
}
}
}
//遍历取最小值,最小值即为解锁等级
private void GetUnLockLevel()
{
var testingCopyBaseTab = GCGame.Table.TableManager.GetTestingCopy().Values;
var lowLevel = 999;
foreach(var info in testingCopyBaseTab)
{
if(info.UnlockLevel <= lowLevel)
{
lowLevel = info.UnlockLevel;
}
}
if (lowLevel != 999)
_UnLockTestingCopyLevel = lowLevel;
}
void ShowDefaultFirst()
{
if (menuItemList.Count > 0)
{
menuItemList[0].OnMenuItemClick();
}
JudgeMenuItemState();
}
public void JudgeMenuItemState()
{
_TestingUnLockPanel.SetActive(GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level >= _UnLockTestingCopyLevel);
_TestingLockPanel.SetActive(GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level < _UnLockTestingCopyLevel);
}
public void OnLockItemClick()
{
GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{65004}"));
}
public List<CopySceneMenuItem> menuItemList;
public List<GameObject> pageList;
public void OnMenuItemClick(int _Index, int _subIndex = -1)
{
ShowPage(_Index);
switch (_Index)
{
case 0:
if (DailyCopySceneRootCtr.Instance != null && DailyCopySceneRootCtr.Instance.gameObject.activeInHierarchy)
{
DailyCopySceneRootCtr.Instance.ShowPage(_subIndex);
}
break;
case 1:
if (_subIndex != -1)
{
pageList[1].GetComponent<StroyCopySceneRootCtrl>()._Select.OnToggleClick(_subIndex);
}
break;
case 2:
{
if (AdvanceCopySceneRootCtr.Instance)
AdvanceCopySceneRootCtr.Instance.SetPositionIndex(_subIndex + 1);
}
break;
default:
break;
}
}
public void ShowPage(int _Index)
{
for (int index = 0; index < menuItemList.Count; index++)
{
menuItemList[index].markIcon.SetActive(index == _Index ? true : false);
menuItemList[index].originObj.SetActive(index == _Index ? false : true);
pageList[index].SetActive(index == _Index ? true : false);
}
}
public void OnCloseBtnClick()
{
UIManager.CloseUI(UIInfo.CopyScenePanelCtr);
}
}