| | |
| | | } |
| | | } |
| | | |
| | | public bool isBindBone = false; |
| | | |
| | | public bool isRedCamp = true; |
| | | public EffectConfig effectConfig; |
| | | |
| | | public float speedRate = 1.5f; |
| | | |
| | | private float m_Alpha = 1f; |
| | | |
| | | public float Alpha |
| | | { |
| | | get |
| | | { |
| | | return m_Alpha; |
| | | } |
| | | set |
| | | { |
| | | if (value == m_Alpha) |
| | | return; |
| | | |
| | | m_Alpha = value; |
| | | OnAlphaChanged(); |
| | | } |
| | | } |
| | | |
| | | private void OnAlphaChanged() |
| | | { |
| | | if (spineComp != null) |
| | | { |
| | | var skeleton = spineComp.Skeleton; |
| | | skeleton.A = Alpha; |
| | | spineComp.LateUpdate(); |
| | | } |
| | | |
| | | for (int i = 0; i < rendererList.Count; i++) |
| | | { |
| | | var renderer = rendererList[i]; |
| | | if (renderer != null && renderer.material != null && renderer.material.HasProperty("_Color")) |
| | | { |
| | | Color color = renderer.material.color; |
| | | color.a = Alpha; |
| | | renderer.material.color = color; |
| | | } |
| | | } |
| | | } |
| | | |
| | | [Header("播放完毕立即回收")] |
| | | public bool isReleaseImmediately = false; //界面特效一般不需要自我销毁,跟随界面或者父对象销毁就行 |
| | |
| | | protected SkeletonAnimation spineComp; |
| | | protected Spine.AnimationState spineAnimationState; |
| | | |
| | | protected int heroSetedSortingOrder; |
| | | |
| | | public GameObjectPoolManager.GameObjectPool pool; |
| | | |
| | | public Action onComplete; |
| | |
| | | |
| | | protected virtual void OnEnable() |
| | | { |
| | | if (spineComp != null) |
| | | { |
| | | //隐藏,会有静态显示问题 |
| | | spineComp.enabled = false; |
| | | } |
| | | // if (spineComp != null) |
| | | // { |
| | | // //隐藏,会有静态显示问题 |
| | | // spineComp.enabled = false; |
| | | // } |
| | | |
| | | ApplySortingOrder(); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | rectTrans.localScale *= effectConfig.effectScale; |
| | | } |
| | | |
| | | spineComp.loop = effectConfig.isLoop != 0; |
| | | } |
| | | |
| | | protected virtual void Clear() |
| | |
| | | onComplete?.Invoke(); |
| | | } |
| | | |
| | | public void SetSortingOrder(int _heroSetedSortingOrder) |
| | | public Func<bool> funcIsHeroFront; |
| | | |
| | | public void SetSortingOrder(Func<bool> _isHeroFrontCallback) |
| | | { |
| | | heroSetedSortingOrder = _heroSetedSortingOrder; |
| | | funcIsHeroFront = _isHeroFrontCallback; |
| | | |
| | | int so = heroSetedSortingOrder; |
| | | ApplySortingOrder(); |
| | | } |
| | | |
| | | if (null != blocker && effectConfig != null) |
| | | |
| | | public void ApplySortingOrder() |
| | | { |
| | | if (null != blocker && effectConfig != null && funcIsHeroFront != null) |
| | | { |
| | | if (BattleConst.UnactiveHeroSortingOrder == heroSetedSortingOrder) |
| | | { |
| | | so = effectConfig.frontBack == 1 ? BattleConst.UnactiveHeroFrontSortingOrder : BattleConst.UnactiveHeroBackSortingOrder; |
| | | } |
| | | else |
| | | { |
| | | so = effectConfig.frontBack == 1 ? BattleConst.ActiveHeroFrontSortingOrder : BattleConst.ActiveHeroBackSortingOrder; |
| | | } |
| | | bool isEffectFront = effectConfig.frontBack == 1; |
| | | |
| | | blocker.SetSortingOrder(so); |
| | | bool isHeroFront = funcIsHeroFront(); |
| | | |
| | | int finalSortingOrder = isHeroFront ? |
| | | (isEffectFront ? BattleConst.ActiveHeroActionSortingOrder : BattleConst.ActiveHeroBackSortingOrder) : (isEffectFront ? BattleConst.UnactiveHeroFrontSortingOrder : BattleConst.UnactiveHeroBackSortingOrder); |
| | | |
| | | |
| | | blocker.SetSortingOrder(finalSortingOrder); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | PlayUnityEffect(); |
| | | } |
| | | OnAlphaChanged(); |
| | | } |
| | | |
| | | protected void PlaySpineEffect() |
| | |
| | | spineComp.Initialize(true); |
| | | spineComp.timeScale = speedRate; |
| | | |
| | | spineComp.skeleton.A = Alpha; |
| | | |
| | | spineAnimationState = spineComp.state; |
| | | spineAnimationState.Complete -= OnSpineAnimationComplete; |
| | | spineAnimationState.Complete += OnSpineAnimationComplete; |
| | |
| | | |
| | | blocker.onSortingChanged = OnSortingChanged; |
| | | |
| | | if (0 != heroSetedSortingOrder) |
| | | { |
| | | if (BattleConst.UnactiveHeroSortingOrder == heroSetedSortingOrder) |
| | | { |
| | | heroSetedSortingOrder = effectConfig.frontBack == 1 ? BattleConst.UnactiveHeroFrontSortingOrder : BattleConst.UnactiveHeroBackSortingOrder; |
| | | } |
| | | else |
| | | { |
| | | heroSetedSortingOrder = effectConfig.frontBack == 1 ? BattleConst.ActiveHeroFrontSortingOrder : BattleConst.ActiveHeroBackSortingOrder; |
| | | } |
| | | |
| | | blocker.SetSortingOrder(heroSetedSortingOrder); |
| | | } |
| | | ApplySortingOrder(); |
| | | |
| | | spineComp.enabled = true; |
| | | |
| | |
| | | animator.speed = speedRate; |
| | | } |
| | | } |
| | | |
| | | public void BindBone(SkeletonAnimation skeletonAnim, string v) |
| | | { |
| | | Bone bone = skeletonAnim.skeleton.FindBone(v); |
| | | |
| | | if (null == bone) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | isBindBone = true; |
| | | |
| | | BoneFollower boneFollower = gameObject.AddMissingComponent<BoneFollower>(); |
| | | boneFollower.boneName = v; |
| | | boneFollower.skeletonRenderer = skeletonAnim; |
| | | |
| | | boneFollower.followBoneRotation = false; |
| | | boneFollower.followXYPosition = true; |
| | | boneFollower.followZPosition = false; |
| | | boneFollower.followLocalScale = false; |
| | | boneFollower.followParentWorldScale = false; |
| | | boneFollower.followSkeletonFlip = false; |
| | | |
| | | boneFollower.Initialize(); |
| | | boneFollower.LateUpdate(); |
| | | } |
| | | } |