| | |
| | | |
| | | private float m_Alpha = 1f; |
| | | |
| | | public float scaleFactor = 1f;// 长期为1,只在需要跟模型一起缩放的时候更改 值为teamHero.ModelScale |
| | | |
| | | public float Alpha |
| | | { |
| | | get |
| | |
| | | // 有特效可能带spine又带unity特效的情况 |
| | | spineComp = gameObject.GetComponentInChildren<SkeletonAnimation>(true); |
| | | |
| | | |
| | | |
| | | if (effectConfig.effectPos != null && effectConfig.effectPos.Length >= 2) |
| | | { |
| | | rectTrans.anchoredPosition += new Vector2((isRedCamp ? 1f : -1f) * effectConfig.effectPos[0], effectConfig.effectPos[1]); |
| | |
| | | { |
| | | rectTrans.localScale *= effectConfig.effectScale; |
| | | } |
| | | |
| | | |
| | | spineComp.loop = effectConfig.isLoop != 0; |
| | | } |
| | |
| | | |
| | | bool isHeroFront = funcIsHeroFront(); |
| | | |
| | | int finalSortingOrder = isHeroFront ? |
| | | (isEffectFront ? BattleConst.ActiveHeroActionSortingOrder + 1 : BattleConst.ActiveHeroBackSortingOrder) : (isEffectFront ? BattleConst.UnactiveHeroFrontSortingOrder : BattleConst.UnactiveHeroBackSortingOrder); |
| | | int baseSortingOrder = isHeroFront ? BattleConst.SkillMaskOrder : BattleConst.BattleBackgroundOrder - BattleConst.BattleFrontHeroEffect - 1; |
| | | |
| | | // 区分是否在特效前面 还要再区分是否在UI前面 isBindBone |
| | | int dynamicOffset = isBindBone |
| | | ? BattleConst.BattleFrontHeroBehindUIEffect : (isEffectFront ? BattleConst.BattleFrontHeroEffect : BattleConst.BattleBehindHeroEffect); |
| | | |
| | | int finalSortingOrder = baseSortingOrder + dynamicOffset; |
| | | |
| | | |
| | | blocker.SetSortingOrder(finalSortingOrder); |
| | | } |
| | |
| | | spineComp.Initialize(true); |
| | | spineComp.timeScale = speedRate; |
| | | |
| | | if (scaleX != 0f && spineComp != null && spineComp.skeleton != null) |
| | | { |
| | | spineComp.skeleton.ScaleX = scaleX; |
| | | } |
| | | |
| | | spineComp.skeleton.A = Alpha; |
| | | |
| | | spineAnimationState = spineComp.state; |
| | |
| | | |
| | | spineComp.timeScale = speedRate; |
| | | |
| | | spineComp.LateUpdate(); |
| | | |
| | | |
| | | Spine.Animation animation = spineAnimationState.Data.SkeletonData.Animations.First(); |
| | | spineAnimationState.SetAnimation(0, animation, effectConfig.isLoop != 0); |
| | | |
| | | SoundPlayer.Instance.PlayUIAudio(effectConfig.audio); |
| | | // SoundPlayer.Instance.PlayUIAudio(effectConfig.audio); |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | // 从特效预制体池获取特效 |
| | | pool = GameObjectPoolManager.Instance.RequestPool(effectPrefab); |
| | | pool = GameObjectPoolManager.Instance.GetPool(effectPrefab); |
| | | effectTarget = pool.Request(); |
| | | // 设置父节点和位置 |
| | | effectTarget.transform.SetParent(transform); |
| | |
| | | |
| | | blocker.onSortingChanged = OnSortingChanged; |
| | | |
| | | SoundPlayer.Instance.PlayUIAudio(effectConfig.audio); |
| | | // SoundPlayer.Instance.PlayUIAudio(effectConfig.audio); |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | // 创建后的特效会自动隐藏 需要手动调用Play才能播放 |
| | | public static BattleEffectPlayer Create(int effectId, BattleField _battleField, Transform parent, bool isRedCamp) |
| | | public static BattleEffectPlayer Create(int effectId, BattleField _battleField, Transform parent, bool isRedCamp, float _scaleRatio) |
| | | { |
| | | // 直接创建特效播放器,不使用对象池 |
| | | BattleEffectPlayer battleEffectPlayer = null; |
| | |
| | | battleEffectPlayer.rectTrans = newGo.AddMissingComponent<RectTransform>(); |
| | | |
| | | battleEffectPlayer.effectId = effectId; |
| | | |
| | | battleEffectPlayer.scaleFactor = _scaleRatio; |
| | | |
| | | // 设置阵营 |
| | | battleEffectPlayer.isRedCamp = isRedCamp; |
| | |
| | | } |
| | | } |
| | | |
| | | public void BindBone(SkeletonAnimation skeletonAnim, string v) |
| | | public void BindBone(BattleObject battleObject, string v) |
| | | { |
| | | Bone bone = skeletonAnim.skeleton.FindBone(v); |
| | | var skeletonAnim = battleObject?.GetSkeletonAnimation(); |
| | | if (skeletonAnim == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | Bone bone = skeletonAnim.skeleton.FindBone(v); |
| | | isBindBone = false; |
| | | followedBone = null; |
| | | if (null == bone) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | rectTrans.localScale *= scaleFactor; |
| | | |
| | | isBindBone = true; |
| | | followedBone = bone; |
| | | |
| | | ApplySortingOrder(); |
| | | |
| | | BoneFollower boneFollower = gameObject.AddMissingComponent<BoneFollower>(); |
| | | boneFollower.boneName = v; |
| | |
| | | boneFollower.Initialize(); |
| | | boneFollower.LateUpdate(); |
| | | } |
| | | |
| | | private float scaleX = 0f; |
| | | |
| | | public void SetScaleX(float v) |
| | | { |
| | | if (spineComp != null && spineComp.skeleton != null) |
| | | { |
| | | spineComp.skeleton.ScaleX = v; |
| | | } |
| | | else |
| | | { |
| | | scaleX = v; |
| | | } |
| | | } |
| | | } |