Ejemplo n.º 1
0
        public override void OnFinished()
        {
            PlayEffectBuffData playEffectBuffData = this.BuffData as PlayEffectBuffData;
            string             targetEffectName   = playEffectBuffData.EffectName;

            if (playEffectBuffData.CanChangeNameByCurrentOverlay)
            {
                targetEffectName = $"{playEffectBuffData.EffectName}{this.CurrentOverlay}";
            }

            this.TheUnitBelongto.GetComponent <EffectComponent>()
            .Remove(targetEffectName);
        }
        void PlayEffect()
        {
            PlayEffectBuffData playEffectBuffData = this.BuffData as PlayEffectBuffData;
            string             targetEffectName   = playEffectBuffData.EffectName;

            if (playEffectBuffData.CanChangeNameByCurrentOverlay)
            {
                targetEffectName = $"{playEffectBuffData.EffectName}{this.CurrentOverlay}";
                //Log.Info($"播放{targetEffectName}");
            }

            //如果想要播放的特效正在播放,就返回
            if (this.TheUnitBelongto.GetComponent <EffectComponent>().CheckState(targetEffectName))
            {
                return;
            }

            GameObjectPool gameObjectPool = Game.Scene.GetComponent <GameObjectPool>();

            if (!gameObjectPool.HasRegisteredPrefab(targetEffectName))
            {
                gameObjectPool.Add(targetEffectName,
                                   this.TheUnitFrom.GameObject.GetComponent <ReferenceCollector>()
                                   .Get <GameObject>(targetEffectName));
            }

            Unit effectUnit = gameObjectPool.FetchEntity(targetEffectName);

            if (playEffectBuffData.FollowUnit)
            {
                if (playEffectBuffData.BuffTargetTypes == BuffTargetTypes.Self)
                {
                    effectUnit.GameObject.transform.SetParent(this.TheUnitFrom.GetComponent <HeroTransformComponent>()
                                                              .GetTranform(playEffectBuffData.PosType));
                }
                else
                {
                    effectUnit.GameObject.transform.SetParent(this.TheUnitBelongto.GetComponent <HeroTransformComponent>()
                                                              .GetTranform(playEffectBuffData.PosType));
                }

                effectUnit.GameObject.transform.localPosition = Vector3.zero;
            }

            this.TheUnitBelongto.GetComponent <EffectComponent>()
            .Play(targetEffectName, effectUnit);
        }