update check condition

This commit is contained in:
VDH
2026-02-27 18:18:51 +07:00
parent a10cbb23b6
commit 5de380fd05
14 changed files with 186 additions and 1026 deletions
@@ -1,4 +1,6 @@
using BrewMonster.Network;
using System.Collections;
using EditorAttributes;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
@@ -18,6 +20,10 @@ namespace BrewMonster.Scripts
[Space(10)]
[Header("Command Buttons")]
[SerializeField] Button _btnNoCooldown;
[SerializeField] Button _btnToggleAutoWrath;
private bool _isAutoAddWrathEnabled = false;
private Coroutine _autoAddWrathCoroutine;
private void Awake()
{
@@ -25,8 +31,21 @@ namespace BrewMonster.Scripts
_btnOpen?.onClick.AddListener(OnBtnOpenClicked);
_btnClose?.onClick.AddListener(OnBtnCloseClicked);
_btnNoCooldown?.onClick.AddListener(OnBtnNoCooldownClicked);
}
_btnToggleAutoWrath?.onClick.AddListener(OnBtnToggleAutoWrathClicked);
DontDestroyOnLoad(this);
}
private void OnDestroy()
{
// Stop coroutine if running when object is destroyed
// 对象销毁时如果协程正在运行则停止它
if (_autoAddWrathCoroutine != null)
{
StopCoroutine(_autoAddWrathCoroutine);
_autoAddWrathCoroutine = null;
}
}
#region button events
private void OnBtnSendClicked()
@@ -57,6 +76,61 @@ namespace BrewMonster.Scripts
{
UnityGameSession.c2s_CmdDebug(8903, 73125);
}
private void OnBtnAddWrathClicked()
{
UnityGameSession.c2s_CmdDebug(1992);
}
//1992
#endregion
[ContextMenu("Toggle Auto-Add Wrath")]
public void OnBtnToggleAutoWrathClicked()
{
ToggleAutoAddWrath();
}
/// <summary>
/// Toggle auto-add wrath feature (calls OnBtnAddWrathClicked every 3 seconds)
/// 切换自动添加怒气功能(每3秒调用OnBtnAddWrathClicked
/// </summary>
public void ToggleAutoAddWrath()
{
_isAutoAddWrathEnabled = !_isAutoAddWrathEnabled;
if (_isAutoAddWrathEnabled)
{
// Start the coroutine if not already running
// 如果尚未运行,则启动协程
if (_autoAddWrathCoroutine == null)
{
_autoAddWrathCoroutine = StartCoroutine(AutoAddWrathCoroutine());
}
}
else
{
// Stop the coroutine if running
// 如果正在运行,则停止协程
if (_autoAddWrathCoroutine != null)
{
StopCoroutine(_autoAddWrathCoroutine);
_autoAddWrathCoroutine = null;
}
}
}
/// <summary>
/// Coroutine that calls OnBtnAddWrathClicked every 3 seconds
/// 每3秒调用OnBtnAddWrathClicked的协程
/// </summary>
private IEnumerator AutoAddWrathCoroutine()
{
while (_isAutoAddWrathEnabled)
{
BMLogger.LogError("Auto-Add Wrath: Adding wrath...");
OnBtnAddWrathClicked();
yield return new WaitForSeconds(3.0f);
}
_autoAddWrathCoroutine = null;
}
}
}
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 14a56e4ae79b92747a7e7d9361f3cbb7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,14 @@
using UnityEngine;
using EditorAttributes;
namespace BrewMonster.Scripts
{
public class TestButtonAttribute : MonoBehaviour
{
[Button("Test Button")]
public void TestMethod()
{
Debug.Log("Test button clicked!");
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 1354ffe4a2a98bf4babd611fa7f66452