Files
MinFt/Client/Assets/Scripts/UI/Home/HomeBuildBtn.cs
Liubing\LB 3d8d4d18f3 first commit
先修复一下,错误的场景

删除不必要的钓场资产

修复into场景

update:更新meta文件,修复报错

update:修复资源

修复第一章节建造

修复建造第三章

update:删除多余内容

update:更新README.md

update:还原图标

update:更新README

update:更新配置
2026-04-28 02:17:22 +08:00

148 lines
4.4 KiB
C#

using asap.core;
using game;
using GameCore;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class HomeBuildBtn : MonoBehaviour, IUIRedPoint
{
string key;
public GameObject redPoint;
public GameObject redpoint_big;
public GameObject bubble_tips;
public TMP_Text text_redpoint_big;
public Button btn_building;
public CanvasGroup homeCanvasGroup;
CampDataMM campData;
private void Awake()
{
campData = GContext.container.Resolve<CampDataMM>();
}
private void Start()
{
btn_building.onClick.AddListener(OnBuildingClick);
}
private void OnEnable()
{
if (campData.IsCanSkyscraper)
{
SetKey(RedPointName.Home_Skyscraper);
}
else
{
SetKey(RedPointName.Home_Build);
}
}
private void OnDisable()
{
if (!string.IsNullOrEmpty(key))
{
RedPointManager.Instance.RemoveRedPoint(key);
key = "";
}
}
public void SetKey(string _key)
{
if (!string.IsNullOrEmpty(key))
{
RedPointManager.Instance.RemoveRedPoint(key);
}
key = _key;
RedPointManager.Instance.AddRedPoint(key, this);
SetRedPointState(RedPointManager.Instance.GetRedPointState(key));
}
public void SetRedPointState(bool state)
{
int count = 0;
if (state)
{
if (!campData.IsCanSkyscraper && campData.GoBuilding())
{
bubble_tips.SetActive(true);
state = false;
}
else
{
bubble_tips.SetActive(false);
count = RedPointManager.Instance.GetRedPointCount(key);
}
}
if (redpoint_big != null && text_redpoint_big != null)
{
if (count > 1)
{
redpoint_big.SetActive(true);
if (count > 99)
{
text_redpoint_big.text = "99+";
}
else
{
text_redpoint_big.text = count.ToString();
}
state = false;
}
else
{
redpoint_big.SetActive(false);
}
}
if (redPoint == null || campData == null)
{
return;
}
redPoint.SetActive(state);
}
void OnBuildingClick()
{
homeCanvasGroup.blocksRaycasts = false;
if (campData.IsCanSkyscraper)
{
InfiniteBuildingAct();
}
else
{
InBuildAct();
}
}
async void InfiniteBuildingAct()
{
ILoadResourceService loadResourceService = GContext.container.Resolve<ILoadResourceService>();
bool isCanEnter = await loadResourceService.Load("InfiniteBuildingAct");
if (isCanEnter)
{
GContext.Publish(new UnloadActToNextAct("InfiniteBuildingAct"));
}
else
{
var panel = await UIManager.Instance.ShowUI(UITypes.CloudTransitionPanel);
panel.GetComponent<CloudTransitionPanel>().SetBtn(true, () => GContext.Publish(new UnloadActToNextAct("InfiniteBuildingAct")));
//var panel = await UIManager.Instance.ShowUI(UITypes.FishingDownLoadPopupPanel);
//panel.GetComponent<FishingDownLoadPopupPanel>().SetBtn(null, () => GContext.Publish(new UnloadActToNextAct("InfiniteBuildingAct")));
}
homeCanvasGroup.blocksRaycasts = true;
}
async void InBuildAct()
{
ILoadResourceService loadResourceService = GContext.container.Resolve<ILoadResourceService>();
bool isCanEnter = await loadResourceService.Loads(campData.AllPrefabs);
if (isCanEnter)
{
GContext.Publish(new UnloadActToNextAct("BuildAct"));
}
else
{
var panel = await UIManager.Instance.ShowUI(UITypes.CloudTransitionPanel);
panel.GetComponent<CloudTransitionPanel>().SetBtn(true, () => GContext.Publish(new UnloadActToNextAct("BuildAct")));
//var panel = await UIManager.Instance.ShowUI(UITypes.FishingDownLoadPopupPanel);
//panel.GetComponent<FishingDownLoadPopupPanel>().SetBtn(null, () => GContext.Publish(new UnloadActToNextAct("BuildAct")));
}
homeCanvasGroup.blocksRaycasts = true;
}
}