关于gameobject销毁,文件enabled = false ,,协程执行情况的测试

本文详细探讨了在Unity引擎中,如何通过`Destroy(gameObject)`和`enabled = false`来销毁游戏对象,并研究了这两种方法对协程(Coroutine)执行的影响。在测试代码中,启动了一个无限循环的协程,然后在不同条件下销毁或禁用游戏对象,观察协程的运行状态。实验结果显示,`Destroy(gameObject)`会立即停止所有协程,而`enabled = false`则会使游戏对象及其组件暂停,但协程会继续执行直到完成当前循环。这对于理解和优化Unity项目的资源管理至关重要。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

using UnityEngine;
using System.Collections;

public class colliderCnt : MonoBehaviour {

    // Use this for initialization
    Collider[] collider;
    void Start () {
        collider = GetComponents<Collider >();
        //Debug.Log (collider.Length);
        Debug.Log (transform.childCount);
        //Invoke ("f");
        //Debug.Log ("One");
        StartCoroutine ("f");
        Destroy (gameObject,8);
        //Destroy (gameObject);
        //GetComponent<colliderCnt> ().enabled = false;
    }
    IEnumerator f()
    {
        //Debug.Log ("Two");
        while (true) {
            yield return new WaitForSeconds(2);
            Debug.Log("On");
            f ();
            //StartCoroutine(f());// create a new coroutine !!
        }
    }
    // Update is called once per frame
    void Update () {
    
    }
}
using UnityEngine; using System.Collections; public class Helper : MonoBehaviour { public Texture2D[] helpTextures; public Texture2D leftArrows; public Texture2D rightArrows; private int helpValue = 0; public GUIStyle myStyle; public Texture2D backButton; public int w; public int h; // Use this for initialization void Start () { this.enabled=false; } // Update is called once per frame void Update () { if(Input.GetKeyUp(KeyCode.Escape)) { helpValue = 0; this.enabled=false; InitButton s=(InitButton)GetComponent("InitButton"); s.enabled=true; } } void OnGUI () { GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), helpTextures[helpValue], ScaleMode.StretchToFill); if(helpValue != 0 && helpValue != helpTextures.Length - 1){ if(GUI.Button(new Rect(Screen.width * 0.1f, Screen.height * 0.4f, Screen.width * 0.1f, Screen.height * 0.2f), leftArrows, myStyle)){ helpValue--; } if(GUI.Button(new Rect(Screen.width * 0.8f, Screen.height * 0.4f, Screen.width * 0.1f, Screen.height * 0.2f), rightArrows, myStyle)){ helpValue++; } }else if(helpValue == 0){ if(GUI.Button(new Rect(Screen.width * 0.8f, Screen.height * 0.4f, Screen.width * 0.1f, Screen.height * 0.2f), rightArrows, myStyle)){ helpValue++; } }else if(helpValue == helpTextures.Length - 1){ if(GUI.Button(new Rect(Screen.width * 0.1f, Screen.height * 0.4f, Screen.width * 0.1f, Screen.height * 0.2f), leftArrows, myStyle)){ helpValue--; } if(GUI.Button(new Rect(Screen.width * 0.8f, Screen.height * 0.4f, Screen.width/5, Screen.height/5), backButton, myStyle)){ helpValue = 0; Chooes s=(Chooes)GetComponent("Chooes"); s.enabled=true; GameObject fly=GameObject.Find("flyer"); Transform plane=fly.transform.Find("plane"); plane.renderer.enabled=false; Transform p=plane.transform.Find("p47 prop01"); p.renderer.enabled=false; this.enabled=false; } } } }这个·代码实现了什么功能
05-29
using System.Collections.Generic; using UnityEngine; using TMPro; using System.Collections; using UnityEngine.UI; using UnityEngine.SceneManagement; using UnityEngine.EventSystems; public class DialogueManager : MonoBehaviour { public enum DialogueState { Before, Win, Lost } public static DialogueManager Instance; [Header("UI Elements")] public TextMeshProUGUI tmpText; public float typingSpeed = 0.05f; [Header("Dialogue Content")] public List<string> beforeBattleDialogues = new List<string>(); public List<string> winDialogues = new List<string>(); public List<string> lostDialogues = new List<string>(); [Header("场景布置")] public GameObject image; public GameObject image1; public GameObject image2; public TextMeshProUGUI text; [Header("按钮设置")] public Button startButton; public Button loseButton; public Button winButton; [Header("UI 元素路径")] public string tmpTextPath = "Canvas/DialoguePanel/TMPText"; public string startButtonPath = "Canvas/Buttons/StartButton"; public string winButtonPath = "Canvas/Buttons/WinButton"; public string loseButtonPath = "Canvas/Buttons/LoseButton"; public string imagePath = "Canvas/Background"; private bool isTyping = false; private Coroutine typingCoroutine; private string currentSentence; public DialogueState currentState = DialogueState.Before; public int currentDialogueIndex = 0; private List<string> currentDialogueList; private TextMeshProUGUI _currentTmpText; private Button _currentStartButton; private Button _currentWinButton; private Button _currentLoseButton; private GameObject _currentImage; void Awake() { // 单例模式实现 if (Instance == null) { Instance = this; DontDestroyOnLoad(gameObject); // 关键:跨场景不销毁 SceneManager.sceneLoaded += OnSceneLoaded; } else { Destroy(gameObject); return; } } void Start() { // 初始状态加载 LoadInitialState(); StartCoroutine(ReinitializeUIAfterFrame()); } void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; } private void LoadInitialState() { // 检查存档中的对话状态 if (SaveSystem.Instance != null && SaveSystem.Instance.SaveExists()) { currentState = SaveSystem.Instance.GetDialogueState(); currentDialogueIndex = SaveSystem.Instance.GetDialogueIndex(); Debug.Log($"从存档加载对话状态: {currentState} 索引: {currentDialogueIndex}"); } else { // 检查战斗结果 int result = PlayerPrefs.GetInt("LastBattleResult", -1); if (result == 1) { Debug.Log("战斗胜利 - 触发胜利对话"); SetDialogueState(DialogueState.Win); } else if (result == 0) { Debug.Log("战斗失败 - 触发失败对话"); SetDialogueState(DialogueState.Lost); } else { Debug.Log("首次进入 - 默认对话"); SetDialogueState(DialogueState.Before); } } // 清除状态 PlayerPrefs.DeleteKey("LastBattleResult"); } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { StartCoroutine(ReinitializeUIAfterFrame()); } private IEnumerator ReinitializeUIAfterFrame() { yield return null; // 等待一帧确保场景完全加载 // 1. 重新获取当前场景的UI引用 _currentTmpText = GameObject.Find(tmpTextPath)?.GetComponent<TextMeshProUGUI>(); _currentStartButton = GameObject.Find(startButtonPath)?.GetComponent<Button>(); _currentWinButton = GameObject.Find(winButtonPath)?.GetComponent<Button>(); _currentLoseButton = GameObject.Find(loseButtonPath)?.GetComponent<Button>(); _currentImage = GameObject.Find(imagePath); // 2. 更新公共引用 if (_currentTmpText != null) tmpText = _currentTmpText; if (_currentStartButton != null) startButton = _currentStartButton; if (_currentWinButton != null) winButton = _currentWinButton; if (_currentLoseButton != null) loseButton = _currentLoseButton; if (_currentImage != null) image = _currentImage; // 3. 重新绑定按钮事件 if (startButton != null) { startButton.onClick.RemoveAllListeners(); startButton.onClick.AddListener(OnStartClick); } if (loseButton != null) { loseButton.onClick.RemoveAllListeners(); loseButton.onClick.AddListener(OnLoseClick); } if (winButton != null) { winButton.onClick.RemoveAllListeners(); winButton.onClick.AddListener(OnWinClick); } // 4. 确保事件系统存在 EnsureEventSystemExists(); // 5. 恢复UI状态 if (tmpText != null) { tmpText.gameObject.SetActive(false); } // 6. 继续之前的对话状态 StartStateDialogue(); } void Update() { if (tmpText == null) return; // 添加跳过功能:按E键跳过当前打字效果 if (Input.GetKeyDown(KeyCode.E) && isTyping) { SkipTyping(); } // 按E键继续下一句对话 else if (Input.GetKeyDown(KeyCode.E) && !isTyping && tmpText.gameObject.activeSelf) { NextSentence(); } } // 设置当前对话状态 public void SetDialogueState(DialogueState newState) { currentState = newState; currentDialogueIndex = 0; switch (newState) { case DialogueState.Before: currentDialogueList = beforeBattleDialogues; break; case DialogueState.Win: currentDialogueList = winDialogues; break; case DialogueState.Lost: currentDialogueList = lostDialogues; break; } Debug.Log($"状态已切换至: {newState}"); // 保存状态 SaveDialogueState(); } // 保存对话状态 private void SaveDialogueState() { if (SaveSystem.Instance != null) { SaveSystem.Instance.SaveDialogueState(currentState, currentDialogueIndex); } } // 启动当前状态的对话 public void StartStateDialogue() { if (currentDialogueList == null || currentDialogueList.Count == 0) return; if (tmpText == null) return; // 确保索引在有效范围内 currentDialogueIndex = Mathf.Clamp(currentDialogueIndex, 0, currentDialogueList.Count - 1); currentSentence = currentDialogueList[currentDialogueIndex]; // 暂停玩家移动 playercontrol player = FindObjectOfType<playercontrol>(); if (player != null) player.canMove = false; // 锁定玩家输入 Cursor.lockState = CursorLockMode.None; Cursor.visible = true; // 显示对话框UI tmpText.gameObject.SetActive(true); // 启动打字效果协程 if (isTyping) { StopCoroutine(typingCoroutine); } typingCoroutine = StartCoroutine(TypeSentence(currentSentence)); } // 显示下一句对话 public void NextSentence() { currentDialogueIndex++; if (currentDialogueIndex < currentDialogueList.Count) { StartStateDialogue(); // 保存当前进度 SaveDialogueState(); } else { // 对话结束 EndDialogue(); } } IEnumerator TypeSentence(string sentence) { isTyping = true; tmpText.text = ""; // 逐字显示 foreach (char letter in sentence.ToCharArray()) { tmpText.text += letter; yield return new WaitForSeconds(typingSpeed); } isTyping = false; } // 跳过当前打字效果 public void SkipTyping() { if (isTyping && typingCoroutine != null) { StopCoroutine(typingCoroutine); tmpText.text = currentSentence; isTyping = false; } } public void EndDialogue() { if (isTyping && typingCoroutine != null) { StopCoroutine(typingCoroutine); isTyping = false; } // 恢复玩家控制 playercontrol player = FindObjectOfType<playercontrol>(); if (player != null) player.canMove = true; // 隐藏对话框 if (tmpText != null) tmpText.gameObject.SetActive(false); // 根据状态显示对应按钮 switch (currentState) { case DialogueState.Before: if (startButton != null) startButton.gameObject.SetActive(true); break; case DialogueState.Win: if (winButton != null) winButton.gameObject.SetActive(true); break; case DialogueState.Lost: if (loseButton != null) loseButton.gameObject.SetActive(true); break; } // 确保事件系统可用 EnsureEventSystemExists(); // 设置按钮为选中状态 if (currentState == DialogueState.Before && startButton != null) { EventSystem.current.SetSelectedGameObject(startButton.gameObject); } else if (currentState == DialogueState.Win && winButton != null) { EventSystem.current.SetSelectedGameObject(winButton.gameObject); } else if (currentState == DialogueState.Lost && loseButton != null) { EventSystem.current.SetSelectedGameObject(loseButton.gameObject); } // 保存完成状态 SaveDialogueState(); } private void EnsureEventSystemExists() { EventSystem eventSystem = FindObjectOfType<EventSystem>(); if (eventSystem == null) { GameObject eventSystemObj = new GameObject("EventSystem"); eventSystem = eventSystemObj.AddComponent<EventSystem>(); eventSystemObj.AddComponent<StandaloneInputModule>(); } else if (eventSystem.GetComponent<StandaloneInputModule>() == null) { eventSystem.gameObject.AddComponent<StandaloneInputModule>(); } } private void OnMainMenuClick() { Debug.Log("主菜单按钮点击"); SceneManager.LoadScene("MainMenu"); } private void OnStartClick() { Debug.Log("开始作战"); SceneManager.LoadScene("Fight"); } private void OnLoseClick() { Debug.Log("失败按钮点击"); SceneManager.LoadScene("Fight"); } private void OnWinClick() { if (currentState != DialogueState.Win) { Debug.LogWarning("尝试在非胜利状态执行胜利逻辑"); return; } playercontrol player = FindObjectOfType<playercontrol>(); if (player != null) player.canMove = true; Debug.Log("执行胜利逻辑"); if (image != null) image.SetActive(false); if (image1 != null) image1.SetActive(false); if (image2 != null) image2.SetActive(false); if (text != null) text.gameObject.SetActive(false); if (tmpText != null) tmpText.gameObject.SetActive(false); if (winButton != null) winButton.gameObject.SetActive(false); // 清除对话存档 if (SaveSystem.Instance != null) { SaveSystem.Instance.SaveDialogueState(DialogueState.Before, 0); } } } using TMPro; using UnityEngine; using UnityEngine.UI; public class NPC2 : MonoBehaviour { public GameObject image; public GameObject image1; public GameObject image2; public TextMeshProUGUI text; [Header("按钮设置")] public Button mainMenuButton; public Button startButton; public Button loseButton; public Button winButton; void Start() { // 将按钮引用传递给DialogueManager if (DialogueManager.Instance != null) { DialogueManager.Instance.startButton = startButton; DialogueManager.Instance.loseButton = loseButton; DialogueManager.Instance.winButton = winButton; } // 初始化时隐藏所有按钮 if (mainMenuButton != null) mainMenuButton.gameObject.SetActive(false); if (startButton != null) startButton.gameObject.SetActive(false); if (loseButton != null) loseButton.gameObject.SetActive(false); if (winButton != null) winButton.gameObject.SetActive(false); } void OnTriggerStay2D(Collider2D other) { if (other.CompareTag("Player") && Input.GetKeyDown(KeyCode.F)) { image.SetActive(true); image1.SetActive(true); image2.SetActive(true); text.gameObject.SetActive(true); DialogueManager.Instance.StartStateDialogue(); switch (DialogueManager.Instance.currentState) { case DialogueManager.DialogueState.Before: startButton.gameObject.SetActive(true); break; case DialogueManager.DialogueState.Win: winButton.gameObject.SetActive(true); break; case DialogueManager.DialogueState.Lost: loseButton.gameObject.SetActive(true); break; } } } }为什么我的对话文本不出来呀
最新发布
08-09
using System.Collections.Generic; using UnityEngine; using TMPro; using System.Collections; using UnityEngine.UI; using UnityEngine.SceneManagement; using UnityEngine.EventSystems; using Unity.Burst; public class DialogueManager : MonoBehaviour { public enum DialogueState { Before, Win, Lost } public static DialogueManager Instance; [Header("UI Elements")] public TextMeshProUGUI tmpText; public float typingSpeed = 0.05f; [Header("Dialogue Content")] public List<string> beforeBattleDialogues = new List<string>(); public List<string> winDialogues = new List<string>(); public List<string> lostDialogues = new List<string>(); private bool isTyping = false; private Coroutine typingCoroutine; private string currentSentence; private DialogueState currentState = DialogueState.Before; private int currentDialogueIndex = 0; private List<string> currentDialogueList; [Header("场景搭建")] public GameObject image; public GameObject image1; public GameObject image2; public TextMeshProUGUI text; [Header("按键显示")] public GameObject victoryButton1; public GameObject retryButton1; public GameObject exitButton1; public GameObject startButton1; [Header("按钮设置")] public Button victoryButton; // 胜利按钮 public Button retryButton; // 重新挑战按钮 public Button exitButton; public Button startButton; void Start() { // 检查战斗结果 int result = PlayerPrefs.GetInt("LastBattleResult", -1); if (result == 1) { Debug.Log("战斗胜利 - 触发胜利对话"); SetDialogueState(DialogueState.Win); } else if (result == 0) { Debug.Log("战斗失败 - 触发失败对话"); SetDialogueState(DialogueState.Lost); } else { Debug.Log("首次进入 - 默认对话"); SetDialogueState(DialogueState.Before); } // 清除状态 PlayerPrefs.DeleteKey("LastBattleResult"); } void Awake() { if (Instance == null) { Instance = this; } else { Destroy(gameObject); } // 初始化当前对话列表 currentDialogueList = beforeBattleDialogues; // 设置按钮点击事件 if (startButton != null) startButton.onClick.AddListener(OnStartClick); if (victoryButton != null) victoryButton.onClick.AddListener(OnVictoryClick); if (retryButton != null) retryButton.onClick.AddListener(OnRetryClick); if (exitButton != null) exitButton.onClick.AddListener(OnExitClick); } void Update() { // 添加跳过功能:按E键跳过当前打字效果 if (Input.GetKeyDown(KeyCode.E) && isTyping) { SkipTyping(); } // 按E键继续下一句对话 else if (Input.GetKeyDown(KeyCode.E) && !isTyping && tmpText.gameObject.activeSelf) { NextSentence(); } } // 设置当前对话状态 public void SetDialogueState(DialogueState newState) { currentState = newState; currentDialogueIndex = 0; switch (newState) { case DialogueState.Before: currentDialogueList = beforeBattleDialogues; break; case DialogueState.Win: currentDialogueList = winDialogues; break; case DialogueState.Lost: currentDialogueList = lostDialogues; break; } Debug.Log($"状态已切换至: {newState}"); } // 启动当前状态的对话 public void StartStateDialogue() { if (currentDialogueList == null || currentDialogueList.Count == 0) return; // 如果正在显示其他文本,先停止 if (isTyping) { StopCoroutine(typingCoroutine); } // 确保索引在有效范围内 currentDialogueIndex = Mathf.Clamp(currentDialogueIndex, 0, currentDialogueList.Count - 1); currentSentence = currentDialogueList[currentDialogueIndex]; // 暂停玩家移动 playercontrol player = FindObjectOfType<playercontrol>(); if (player != null) player.canMove = false; // 锁定玩家输入 Cursor.lockState = CursorLockMode.None; Cursor.visible = true; // 显示对话框UI tmpText.gameObject.SetActive(true); // 启动打字效果协程 typingCoroutine = StartCoroutine(TypeSentence(currentSentence)); } // 显示下一句对话 public void NextSentence() { currentDialogueIndex++; if (currentDialogueIndex < currentDialogueList.Count) { StartStateDialogue(); } else { // 对话结束 EndDialogue(); } } IEnumerator TypeSentence(string sentence) { isTyping = true; tmpText.text = ""; // 逐字显示 foreach (char letter in sentence.ToCharArray()) { tmpText.text += letter; yield return new WaitForSeconds(typingSpeed); } isTyping = false; } // 跳过当前打字效果 public void SkipTyping() { if (isTyping) { StopCoroutine(typingCoroutine); tmpText.text = currentSentence; isTyping = false; } } public void EndDialogue() { if (isTyping) { StopCoroutine(typingCoroutine); isTyping = false; } // 恢复玩家控制 playercontrol player = FindObjectOfType<playercontrol>(); if (player != null) player.canMove = true; // 隐藏对话框 tmpText.gameObject.SetActive(false); // 强制刷新UI层级 Canvas.ForceUpdateCanvases(); // 创建专用按钮层确保显示在最上层 GameObject buttonLayer = new GameObject("ButtonLayer"); buttonLayer.transform.SetParent(transform, false); Canvas buttonCanvas = buttonLayer.AddComponent<Canvas>(); buttonCanvas.overrideSorting = true; buttonCanvas.sortingOrder = 9999; // 设置为最高层级 // 将按钮移动到专用层 if (startButton != null) startButton.transform.SetParent(buttonLayer.transform, false); if (victoryButton != null) victoryButton.transform.SetParent(buttonLayer.transform, false); if (retryButton != null) retryButton.transform.SetParent(buttonLayer.transform, false); if (exitButton != null) exitButton.transform.SetParent(buttonLayer.transform, false); // 确保按钮可交互 if (startButton != null) startButton.interactable = true; if (victoryButton != null) victoryButton.interactable = true; if (retryButton != null) retryButton.interactable = true; if (exitButton != null) exitButton.interactable = true; // 根据状态显示对应按钮 switch (currentState) { case DialogueState.Before: if (startButton1 != null) startButton1.SetActive(true); if (exitButton1 != null) exitButton1.SetActive(true); break; case DialogueState.Win: if (victoryButton1 != null) victoryButton1.SetActive(true); if (exitButton1 != null) exitButton1.SetActive(true); break; case DialogueState.Lost: if (retryButton1 != null) retryButton1.SetActive(true); if (exitButton1 != null) exitButton1.SetActive(true); break; } // 确保事件系统可用 EnsureEventSystemExists(); // 设置按钮为选中状态 if (currentState == DialogueState.Before && startButton != null) { EventSystem.current.SetSelectedGameObject(startButton.gameObject); } else if (currentState == DialogueState.Win && victoryButton != null) { EventSystem.current.SetSelectedGameObject(victoryButton.gameObject); } else if (currentState == DialogueState.Lost && retryButton != null) { EventSystem.current.SetSelectedGameObject(retryButton.gameObject); } } void OnTriggerExit2D(Collider2D other) { if (other.CompareTag("Player")) {if (Input.GetKeyDown(KeyCode.F)) { image.SetActive(true); image1.SetActive(true); image2.SetActive(true); text.gameObject.SetActive(true); } } } private void EnsureEventSystemExists() { EventSystem eventSystem = FindObjectOfType<EventSystem>(); if (eventSystem == null) { GameObject eventSystemObj = new GameObject("EventSystem"); eventSystemObj.AddComponent<EventSystem>(); eventSystemObj.AddComponent<StandaloneInputModule>(); Debug.Log("创建新事件系统"); } else { // 确保输入模块存在 if (!eventSystem.TryGetComponent<StandaloneInputModule>(out _)) { eventSystem.gameObject.AddComponent<StandaloneInputModule>(); } } } private void OnStartClick() { Debug.Log("开始按钮点击"); // 实际逻辑:如加载战斗场景 SceneManager.LoadScene("Fight"); } private void OnVictoryClick() { Debug.Log("胜利按钮点击"); //解除玩家限制,让玩家重新自由活动 playercontrol player = FindObjectOfType<playercontrol>(); if (player != null) player.canMove = true; } private void OnRetryClick() { Debug.Log("重试按钮点击"); // 重新挑战:重新加载当前战斗场景 SceneManager.LoadScene("Fight"); } private void OnExitClick() { Debug.Log("退出按钮点击"); // 退出到主菜单 SceneManager.LoadScene("MainMenu"); } }帮我查看问题,并修改,不需要增加或减少功能
08-01
using System.Collections; using System.Collections.Generic; using UnityEngine; /*主要任务: *1.管理敌人的当前生命值和最大生命值。 *2.处理敌人受伤的逻辑,包括伤害冷却时间和受伤停顿。 *3.控制敌人动画(例如受伤和死亡动画)。 *4.处理敌人死亡后将其返回到对象池。 *5.与其他组件(如 healthBar、MonsterPatrol 和 enemyPool)交互。 */ public class enemylife : MonoBehaviour { public Animator anim; public int MaxHealth = 10; public int currentHealth; public healthBar healthbar; public bool isHurt = false; public bool isDie = false; public EnemyBehaviorLogic enemyBehaviorLogic; private PlayerATK playerATK; [Header("对象池")] public enemyPool enemyPool; private float lastDamageTime = 0f; // 记录上次受伤害的时间 public float damageCooldown = 0.5f; // 伤害冷却时间 [Header("受伤停顿")] public static bool isStunned = false; private Coroutine currentStunCoroutine; private void Awake() { enemyPool = FindObjectOfType<enemyPool>(); playerATK = FindObjectOfType<PlayerATK>(); } void Start() { currentHealth = MaxHealth; } void FixedUpdate() { enemyIsActive(); if (currentHealth <= 0 && !isDie) { anim.SetTrigger("die"); Debug.Log("敌人死亡"); isDie = true; StartCoroutine(DieAfterDelay()); } } // 延迟处理敌人死亡逻辑 private IEnumerator DieAfterDelay() { yield return new WaitForSeconds(0.5f); gameObject.SetActive(false); EnemyDefeated(gameObject); } //是否受到攻击----逻辑的开始 private void OnTriggerStay2D(Collider2D other) { if (other.CompareTag("attack")) { float currentTime = Time.time; if (currentTime - lastDamageTime >= damageCooldown) { lastDamageTime = currentTime; PlayerDamage(playerATK.PlayerDamage); OnEnemyHurt(); } } } private void PlayerDamage(int damage) { // 确保每次伤害都能触发动画和血条更新 currentHealth -= damage; healthba
03-17
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值