Esempio n. 1
0
        public void Init(ParticleEventProperties properties, Animator animator, float startTime, bool flipped, float stopTime, bool clear)
        {
            _properties = properties;
            //_flipped      = flipped;
            _clear = clear;
            //_animator         = animator;
            _startTime = startTime;
            _stopTime  = stopTime;
            _lastTime  = startTime;
            _played    = false;
            _stopped   = false;

            if (_particleSystem == null)
            {
                _particleSystem = MoveUtils.InstantiateParticle(null, properties, animator, flipped, true);
            }

            if (properties._parent)
            {
                _attachTransform = _particleSystem.GetComponent <AttachTransform>();
                if (_attachTransform != null)
                {
                    _attachTransform.UpdateManually = true;
                }
            }

            Reset();
        }
Esempio n. 2
0
        public void Init(TrailRendererEventProperties properties, Animator animator, float startTime, bool flipped, bool isCrit)
        {
            //_properties   = properties;
            _startTime     = startTime;
            _animClip      = properties._rigAnimClip;
            _trailRenderer = MoveUtils.InstantiateTrailInstance(properties, animator, flipped, isCrit, true).GetComponent <TrailRendererInstance>();
            _animRoot      = EB.Util.GetObjectExactMatch(_trailRenderer.gameObject, "anim_root");
            _played        = false;

            if (properties._parent)
            {
                _attachTransform = _trailRenderer.GetComponent <AttachTransform>();
            }
        }
Esempio n. 3
0
        public void PlayDynamicLight(DynamicLightEventProperties properties)
        {
            // TJ: don't play this light if one with the same event name is already playing
            if (properties._eventName.Length > 0 && _activeDynamicLights.Count(pi => pi._name == properties._eventName) > 0)
            {
                return;
            }

            GameObject light = MoveUtils.InstantiateDynamicLight(properties, GetComponent <Animator>(), false);

            if (light != null)
            {
                RegisterLight(light, properties._eventName, properties._interruptable, properties._stopOnExit);
                light.GetComponent <DynamicPointLightInstance>().Play();
            }
        }
Esempio n. 4
0
        public void Init(DynamicLightEventProperties properties, Animator animator, float startTime, float stopTime)
        {
            //_properties   = properties;
            _startTime    = startTime;
            _stopTime     = stopTime;
            _dynamicLight = MoveUtils.InstantiateDynamicLight(properties, animator, false, true).GetComponent <DynamicPointLightInstance>();
            _played       = false;
            _stopped      = false;

            if (!Application.isPlaying)
            {
                _dynamicLight.EnableSimMode(true);
            }

            _dynamicLight.Stop();
        }
Esempio n. 5
0
        public void PlayTrailRenderer(TrailRendererEventProperties properties)
        {
            bool isCrit = false;

            Hotfix_LT.Combat.Combatant combatant = gameObject.GetComponent <Hotfix_LT.Combat.Combatant>();
            if (combatant != null)
            {
                isCrit = combatant.IsCurrentAttackCritical();
            }
            GameObject trail = MoveUtils.InstantiateTrailInstance(properties, GetComponent <Animator>(), _flipped, isCrit);

            if (trail != null)
            {
                RegisterTrail(trail, properties._eventName, properties._isInterruptible);
                trail.GetComponent <TrailRendererInstance>().Play(Time.time);

                if (!string.IsNullOrEmpty(properties.RigAnimClipName))
                {
                    Animation animRoot = trail.transform.Find("anim_root").GetComponent <Animation>();
                    animRoot.Play(properties.RigAnimClipName);
                }
            }
        }
Esempio n. 6
0
        public ParticleSystem PlayParticle(ParticleEventProperties properties, float time = 0, bool forcePlay = false, bool target = false, Vector3 tarPos = new Vector3(), Animator tarAimator = null, Vector3 tarOrgPos = new Vector3(), Vector3 tarHitPos = new Vector3())
        {
            if (!m_CanPlayParticle)
            {
                return(null);
            }

            //判断是否被禁止播放特效
            if (DisableFX)
            {
                return(null);
            }

            if (properties._applyOnTargetList)
            {
                ParticleEventProperties clone = ParticleEventProperties.Deserialize(properties.Serialize());
                PlayParticleOnTargetList(clone);
                return(null);
            }
            //ToDo:改调热更
            //if (LTInstanceMapModel.Instance.IsInsatnceViewAction() && properties._flippedParticleReference.Name.Contains("paobu"))
            if (GameFlowControlManager.IsInView("InstanceView") && properties._flippedParticleReference.Name.Contains("paobu"))
            {
                return(null);
            }

            //如果是世界boss的封印特效,则必须要在主场景才会出现
            //ToDo:改调热更
            //if (properties._flippedParticleReference.Name.Contains("fx_f_M00") && (!_animator.name.Contains("-Variant-Normal-M") || LTWorldBossDataManager.Instance.IsOpenWorldBoss()))
            if (properties._flippedParticleReference.Name.Contains("fx_f_M00") && (!_animator.name.Contains("-Variant-Normal-M") || (bool)GlobalUtils.CallStaticHotfix("Hotfix_LT.UI.LTWorldBossDataManager", "IsOpenWorldBossFromILR")))
            {
                return(null);
            }

            //世界boss某个出场特效播放之后需要特殊处理场景状态
            if (properties._flippedParticleReference.Name.Equals("fx_m_m001_specialappear03") || properties._flippedParticleReference.Name.Equals("fx_m_m002_specialappear03") || properties._flippedParticleReference.Name.Equals("fx_m_m003_specialappear03"))
            {
                if (WorldBossCombatScene.Instance != null)
                {
                    WorldBossCombatScene.Instance.SetSceneStatus(2);//世界boss播放出场镜头的时候需要特殊设置场景状态
                }
            }

            if (!string.IsNullOrEmpty(properties._partition))
            {
                //AvatarComponent avatar = _player != null ? _player.GetComponent<AvatarComponent>() : GetComponent<AvatarComponent>();
                AvatarComponent avatar = GetComponent <AvatarComponent>();
                if (avatar == null)
                {
                    return(null);
                }

                if (!avatar.Partitions.ContainsKey(properties._partition))
                {
                    return(null);
                }

                /*string fxName = avatar.Partitions[properties._partition].AssetName;
                 * if (properties._particleReference.Valiad && !properties._particleReference.Name.EndsWith(fxName))
                 * {
                 *      return null;
                 * }
                 * if (properties._flippedParticleReference.Valiad && !properties._flippedParticleReference.Name.EndsWith(fxName))
                 * {
                 *      return null;
                 * }
                 * if (!string.IsNullOrEmpty(properties.ParticleName) && !properties.ParticleName.EndsWith(fxName))
                 * {
                 *      return null;
                 * }
                 * if (!string.IsNullOrEmpty(properties.FlippedParticleName) && !properties.FlippedParticleName.EndsWith(fxName))
                 * {
                 *      return null;
                 * }*/
            }

            bool canPlay = true;

            // TJ: Test conditions that would prevent the particle from playing
            if (!forcePlay)
            {
                // check if there are any particles playing using this event name
                if (properties._eventName.Length > 0 && _activeParticles.Count(pi => pi._name == properties._eventName) > 0)
                {
                    ParticleInfo info = _activeParticles.Find(pi => pi._name == properties._eventName);
                    if (!info._stopOnOverride)
                    {
                        canPlay = false;
                    }
                }
                // check if we need to wait for attacks to be resolved
                else if (properties._killIfBlocked || properties._cancelIfMissed || properties._cancelIfHit)
                {
                    _cachedConditionalParticles.Add(properties);
                    canPlay = false;
                }
            }

            if (!canPlay)
            {
                return(null);
            }

            ParticleInfo last = null;

            if (properties._eventName.Length > 0 && _activeParticles.Count(pi => pi._name == properties._eventName) > 0)
            {
                foreach (ParticleInfo info in _activeParticles.FindAll(pi => pi._name == properties._eventName))
                {
                    if (info._stopOnOverride)
                    {
                        if (!info._particleSystem.loop || last != null)
                        {
                            StopParticle(info._name);
                        }
                        else
                        {
                            last = info;
                        }
                    }
                }
            }

            //EB.Debug.Log("PlayParticle: play {0} _activeParticles = {1}", properties._eventName, _activeParticles.Count);

            ParticleInfo   new_pi = last;
            ParticleSystem ps     = last != null ? last._particleSystem : null;

            if (new_pi == null)
            {
                ps = InstantiateParticle(properties, _flipped, target, tarPos, tarAimator, tarOrgPos, tarHitPos);
                if (ps == null)
                {
                    //如果是开场动画,如果还没播放开场动画,还需要隔一段时间播放
                    //if (CombatUtil.IsHeroStartEffect(MoveUtils.GetParticleName(properties, true)))
                    if (IsHeroStartEffect(MoveUtils.GetParticleName(properties, true)))
                    {
                        mCurrentReplayTime++;
                        if (mCurrentReplayTime >= mReplayTime)
                        {
                            TimerManager.instance.RemoveTimer(mTimer);
                            mCurrentReplayTime = 0;
                            return(null);
                        }
                        mTimer = TimerManager.instance.AddTimer(100, 1, delegate(int seq)
                        {
                            TimerManager.instance.RemoveTimer(mTimer);
                            PlayParticle(properties, time, forcePlay);
                        });
                    }
                    return(null);
                }

                new_pi = RegisterParticle(ps, properties._eventName, properties._interruptable, properties._stopOnExit, properties._stopOnDuration, properties._duration);
            }

            new_pi._stopOnOverride = properties._stopOnOverride;
            new_pi._stopOnEndTurn  = properties._stopOnEndTurn;
            new_pi._stopAfterTurns = properties._stopAfterTurns;
            new_pi._turns          = properties._turns;
            new_pi.properties      = properties;
            new_pi._activeTurn     = Mathf.Max(1, GetCurrentTurn());

            if (last == null)
            {
                ps.EnableEmission(true);

                if (time < 0.01f)
                {
                    ps.Simulate(0.0001f, true, true);
                }
                else
                {
                    ps.Simulate(time, true, true);
                }
                ps.gameObject.layer = gameObject.layer;
                ps.transform.SetChildLayer(gameObject.layer);

                ps.Play(true);
            }
            //EB.Debug.LogPSPoolAsset(string.Format(">>播放指定的特效:<color=#00ff00>{0}</color>", ps.name));
            if (PlayParticleAction != null)
            {
                PlayParticleAction(ps);
            }

            return(ps);
        }
Esempio n. 7
0
        private ParticleSystem InstantiateParticle(ParticleEventProperties properties, bool flipped, bool target = false, Vector3 tarPos = new Vector3(), Animator tarAimator = null, Vector3 tarOrgPos = new Vector3(), Vector3 tarHitPos = new Vector3())
        {
            ParticleSystem ps = null;

            if (properties._spawnAtOpponent && _player != null)
            {
                // calculate world position of the particle
                //Vector3 position = _player.transform.position;
                //Combatant target = _player.GetAttackTarget();

                Vector3 position = this.gameObject.transform.position;

                if (!target)
                {
                    ps = MoveUtils.InstantiateParticle(this, properties, position, flipped);
                }
                else
                {
                    //position = target.transform.position;
                    position = tarPos;
                    if (properties._attachToOpponent)
                    {
                        flipped = !flipped;                             // since this is now attached to the other player we need to reverse the flip

                        if (tarAimator == null)
                        {
                            ps = MoveUtils.InstantiateParticle(this, properties, position, flipped);
                        }
                        else
                        {
                            ps = MoveUtils.InstantiateParticle(this, properties, tarAimator, flipped);
                        }
                    }
                    else
                    {
                        if (properties._spawnAtTargetBase)
                        {
                            position = tarOrgPos;
                        }
                        else if (properties._spawnAtHitPoint)
                        {
                            position = tarHitPos;
                        }

                        ps = MoveUtils.InstantiateParticle(this, properties, position, flipped);
                    }
                }
            }
            else
            {
                if (_animator == null)
                {
                    ps = MoveUtils.InstantiateParticle(this, properties, transform.position, flipped);
                }
                else
                {
                    ps = MoveUtils.InstantiateParticle(this, properties, _animator, flipped);
                }
            }

            return(ps);
        }