| | |
| | | |
| | | public GameObjectPoolManager.GameObjectPool pool; |
| | | |
| | | public BattleField battleField; |
| | | |
| | | public Action onComplete; |
| | | |
| | | private bool isPlaying = false; |
| | |
| | | bool isHeroFront = funcIsHeroFront(); |
| | | |
| | | int finalSortingOrder = isHeroFront ? |
| | | (isEffectFront ? BattleConst.ActiveHeroActionSortingOrder : BattleConst.ActiveHeroBackSortingOrder) : (isEffectFront ? BattleConst.UnactiveHeroFrontSortingOrder : BattleConst.UnactiveHeroBackSortingOrder); |
| | | (isEffectFront ? BattleConst.ActiveHeroActionSortingOrder + 1 : BattleConst.ActiveHeroBackSortingOrder) : (isEffectFront ? BattleConst.UnactiveHeroFrontSortingOrder : BattleConst.UnactiveHeroBackSortingOrder); |
| | | |
| | | |
| | | blocker.SetSortingOrder(finalSortingOrder); |
| | |
| | | { |
| | | PlayUnityEffect(); |
| | | } |
| | | |
| | | battleField?.soundManager.PlayEffectSound(effectConfig.audio); |
| | | |
| | | OnAlphaChanged(); |
| | | } |
| | | |
| | | protected void PlaySpineEffect() |
| | | { |
| | | // 这里是纯spine的逻辑 |
| | | |
| | | if (spineComp == null) |
| | | { |
| | | Debug.LogError("BattleEffectPlayer spineComp is null, effect id is " + effectId); |
| | | return; |
| | | } |
| | | |
| | | SkeletonDataAsset skeletonDataAsset = ResManager.Instance.LoadAsset<SkeletonDataAsset>("UIEffect/" + effectConfig.packageName, effectConfig.fxName); |
| | | // ===== 简化:直接从缓存获取,缓存内部会自动加载 ===== |
| | | string directory = "UIEffect/" + effectConfig.packageName; |
| | | SkeletonDataAsset skeletonDataAsset = BattleResManager.Instance.GetSpineResource( |
| | | directory, |
| | | effectConfig.fxName, |
| | | battleField?.guid |
| | | ); |
| | | |
| | | if (skeletonDataAsset == null) |
| | | { |
| | | Debug.LogError($"BattleEffectPlayer: Failed to load effect spine {effectConfig.fxName}"); |
| | | return; |
| | | } |
| | | // ================================ |
| | | |
| | | spineComp.skeletonDataAsset = skeletonDataAsset; |
| | | spineComp.Initialize(true); |
| | | spineComp.timeScale = speedRate; |
| | |
| | | } |
| | | |
| | | // 从特效预制体池获取特效 |
| | | pool = GameObjectPoolManager.Instance.RequestPool(effectPrefab); |
| | | pool = GameObjectPoolManager.Instance.GetPool(effectPrefab); |
| | | effectTarget = pool.Request(); |
| | | // 设置父节点和位置 |
| | | effectTarget.transform.SetParent(transform); |
| | |
| | | |
| | | |
| | | // 创建后的特效会自动隐藏 需要手动调用Play才能播放 |
| | | public static BattleEffectPlayer Create(int effectId, Transform parent, bool isRedCamp) |
| | | public static BattleEffectPlayer Create(int effectId, BattleField _battleField, Transform parent, bool isRedCamp) |
| | | { |
| | | // 直接创建特效播放器,不使用对象池 |
| | | BattleEffectPlayer battleEffectPlayer = null; |
| | |
| | | GameObject newGo = new GameObject("BattleEffectPlayer_" + effectId); |
| | | newGo.transform.SetParent(parent, false); |
| | | battleEffectPlayer = newGo.AddComponent<BattleEffectPlayer>(); |
| | | battleEffectPlayer.battleField = _battleField; |
| | | battleEffectPlayer.rectTrans = newGo.AddMissingComponent<RectTransform>(); |
| | | |
| | | battleEffectPlayer.effectId = effectId; |