三国卡牌客户端基础资源仓库
yyl
2025-08-29 3b895f5ab8d619719e8e67795db093cd83dcc66c
logic engine update
2个文件已修改
112 ■■■■ 已修改文件
Assets/Editor/ScriptEditor/TestSkillActionEditorWindow.cs 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Launch/Common/LogicEngine.cs 71 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/ScriptEditor/TestSkillActionEditorWindow.cs
@@ -7,6 +7,10 @@
    protected int skillId = 1;
    protected int hurtIndex = 0;
    protected int effectId = 0;
    protected BattleEffectPlayer effectPlayer;
    [MenuItem("Battle/TestSkillAction生成器")]
    public static void ShowWindow()
    {
@@ -19,6 +23,8 @@
        skillId = EditorGUILayout.IntField("Skill ID", skillId);
        hurtIndex = EditorGUILayout.IntField("Hurt Index", hurtIndex);
        effectId = EditorGUILayout.IntField("Effect ID", effectId);
        if (GUILayout.Button("生成并播放 TestSkillAction"))
        {
@@ -29,6 +35,41 @@
        {
            ResetRecordPlayer();
        }
        if (GUILayout.Button("展示特效"))
        {
        }
    }
    protected void ShowEffect()
    {
        if (effectId <= 0)
        {
            Debug.LogWarning("Effect ID 必须大于0");
            return;
        }
        if (EffectConfig.Get(effectId) == null)
        {
            Debug.LogWarning($"Effect ID {effectId} 在配置表中不存在");
            return;
        }
        HomeWin homeWin = UIManager.Instance.GetUI<HomeWin>();
        effectPlayer = BattleEffectPlayer.Create(effectId, homeWin.transform);
        effectPlayer.Play();
    }
    protected void DestroyEffect()
    {
        if (effectPlayer != null)
        {
            effectPlayer.Stop();
            GameObject.DestroyImmediate(effectPlayer.gameObject);
            effectPlayer = null;
        }
    }
    private void PlayTestSkillAction()
Assets/Launch/Common/LogicEngine.cs
@@ -1,49 +1,64 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class LogicEngine : SingletonMonobehaviour<LogicEngine>
{
    public Action OnUpdate;
    public class LogicEngine : SingletonMonobehaviour<LogicEngine>
    List<LogicUpdate> logicUpdates = new List<LogicUpdate>();
    public void Register(LogicUpdate logicUpdate)
    {
        List<LogicUpdate> logicUpdates = new List<LogicUpdate>();
        public void Register(LogicUpdate logicUpdate)
        if (!logicUpdates.Contains(logicUpdate))
        {
            if (!logicUpdates.Contains(logicUpdate))
            logicUpdates.Add(logicUpdate);
        }
    }
    public void UnRegister(LogicUpdate logicUpdate)
    {
        if (logicUpdates.Contains(logicUpdate))
        {
            logicUpdates.Remove(logicUpdate);
        }
    }
    void Update()
    {
        if (null != OnUpdate)
        {
            try
            {
                logicUpdates.Add(logicUpdate);
                OnUpdate();
            }
            catch (System.Exception ex)
            {
                Debug.LogError(ex);
            }
        }
        public void UnRegister(LogicUpdate logicUpdate)
        for (var i = logicUpdates.Count - 1; i >= 0; i--)
        {
            if (logicUpdates.Contains(logicUpdate))
            var item = logicUpdates[i];
            if (item.destroyDirty)
            {
                logicUpdates.Remove(logicUpdate);
                logicUpdates.RemoveAt(i);
            }
        }
        void Update()
        {
            for (var i = logicUpdates.Count - 1; i >= 0; i--)
            else
            {
                var item = logicUpdates[i];
                if (item.destroyDirty)
                try
                {
                    logicUpdates.RemoveAt(i);
                    item.Update();
                }
                else
                catch (System.Exception ex)
                {
                    try
                    {
                        item.Update();
                    }
                    catch (System.Exception ex)
                    {
                        Debug.LogError(ex);
                    }
                    Debug.LogError(ex);
                }
            }
        }
    }
    }
}