/// <summary> /// 直接克隆特效 /// </summary> /// <param name="properties">特效信息</param> /// <param name="flipped">是否翻转粒子系统</param> /// <returns></returns> private static ParticleSystem LoadParticleWithoutPool(ParticleEventProperties properties, bool flipped) { ParticleSystem ps = null; if (flipped) { if (properties._flippedParticleReference.Value != null) { ps = (ParticleSystem)GameObject.Instantiate(properties._flippedParticleReference.Value); } else { if (properties._particleReference.Value != null) { ps = (ParticleSystem)GameObject.Instantiate(properties._particleReference.Value); } } } else { if (properties._particleReference.Value != null) { ps = (ParticleSystem)GameObject.Instantiate(properties._particleReference.Value); } } if (ps != null) { ps.name = GetParticleName(properties, flipped); } return(ps); }
/// <summary> /// 从特效缓存池里获取特效粒子 /// </summary> /// <param name="properties">特效信息</param> /// <param name="flipped">是否翻转</param> /// <returns></returns> private static ParticleSystem LoadParticleWithPool(Object obj, ParticleEventProperties properties, bool flipped) { if (PSPoolManager.Instance != null) { string name = string.Empty; if (flipped) { if (properties._flippedParticleReference.Valiad) { name = properties._flippedParticleReference.Name; } else { name = properties.FlippedParticleName; } } if (string.IsNullOrEmpty(name)) { if (properties._particleReference.Valiad) { name = properties._particleReference.Name; } else { name = properties.ParticleName; } } return(PSPoolManager.Instance.Use(obj, name)); } return(null); }
public static string GetParticleName(ParticleEventProperties properties, bool flipped) { if (flipped) { if (properties._flippedParticleReference.Value != null) { return(properties._flippedParticleReference.Value.name); } else { if (properties._particleReference.Value != null) { return(properties._particleReference.Value.name); } } } else { if (properties._particleReference.Value != null) { return(properties._particleReference.Value.name); } } return(properties.ParticleName); }
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(); }
//单独放特效 public void OnInflictHitEx(MoveAnimationEvent ee) { HitEventInfo event_info = ee.EventRef as MoveEditor.HitEventInfo; ParticleEventProperties particle_info = event_info._particleProperties; SpawnParitcle(particle_info, false, 0); }
public void PlayParticleOnTargetList(ParticleEventProperties properties) { if (!properties._applyOnTargetList) { return; } if (_player == null) { return; } // calculate world position of the particle Hotfix_LT.Combat.Combatant[] targets = _player.GetCurrentTargets(); if (targets == null) { return; } properties._applyOnTargetList = false; foreach (Hotfix_LT.Combat.Combatant target in targets) { if (target != null && target.FXHelper != null) { target.FXHelper.PlayParticle(properties, false); } } }
public void SpawnParticleOnTargetList(ParticleEventProperties properties, bool applyOnTargetList, float startTime) { if (!applyOnTargetList) { return; } if (Application.isPlaying) //运行模式是combatant里取targets { //if (_combatant == null) //{ // _combatant = GetComponent<Combatant>(); //} //if (_combatant.LTTargets == null) return; //Combatant[] tcs = new Combatant[_combatant.LTTargets.Count]; //if(tcs==null) //{ // return; //} //for(int i=0;i<tcs.Length;i++) //{ // tcs[i] = LTCombatEventReceiver.Instance.GetCombatant(_combatant.LTTargets[i]); //} //if (targets == null || targets.Length !=tcs.Length) //{ // targets = new Transform[tcs.Length]; //} //for(int i =0;i< targets.Length;i++) //{ // if (tcs[i] != null) // { // targets[i] = tcs[i].transform; // } //} } if (targets == null) { return; } for (int i = 0; i < targets.Length; i++) { Transform target = targets[i]; if (target != null) { HitMono hitMono = target.GetComponent <HitMono>(); if (hitMono == null) { hitMono = target.gameObject.AddComponent <HitMono>(); } hitMono.SpawnParitcle(properties, !applyOnTargetList, startTime); } } }
public void OnInflictHit(MoveAnimationEvent ee) { HitEventInfo event_info = ee.EventRef as MoveEditor.HitEventInfo; //PlayHitReactionProperties reaction_info = event_info._hitRxnProps; ParticleEventProperties particle_info = event_info._particleProperties; AudioEventProperties audio_info = event_info._audioProperties; if (particle_info._cancelIfMissed) { } SpawnHit(particle_info, audio_info, 0); }
/// <summary> /// /// </summary> /// <param name="particle_info"></param> /// <param name="audio_info"></param> /// <param name="startTime">这个时间主要是给编辑器用 因为编辑器时钟是一致 但是运行时态脚本初始化不一致所以无视这个时间</param> public void SpawnHit(ParticleEventProperties particle_info, AudioEventProperties audio_info, float startTime) { //ParticleEventProperties particle_info = ParticleEventProperties.Deserialize(particle_info_primal.Serialize()); //particle_info._particleReference = particle_info_primal._particleReference; //particle_info._flippedParticleReference = particle_info_primal._flippedParticleReference; //AudioEventProperties audio_info = AudioEventProperties.Deserialize(audio_info_primal.Serialize()); SpawnParitcle(particle_info, particle_info._applyOnTargetList, startTime); SpawnAudioClass arg = new SpawnAudioClass(); arg.audio_info = audio_info; arg.startTime = startTime; TimerManager.instance.AddFramer(2, 1, OnFrameUpSpawnAudioHandler, arg); }
public static ParticleSystem InstantiateParticle(Object obj, ParticleEventProperties properties, Vector3 worldPosition, bool flipped = false, bool bypassPools = false) { ParticleSystem ps = GetParticleInstance(obj, properties, flipped, bypassPools); if (ps != null) { ps.transform.position = worldPosition; ps.transform.eulerAngles = properties._angles; Vector3 offset = properties._offset; if (flipped) { offset.x = -offset.x; // flip the x FlipWorldRotationByXYPlane(ps.transform); } ps.transform.position += offset; } return(ps); }
/// <summary> /// 获取特效实体 /// </summary> /// <param name="properties">特效信息</param> /// <param name="flipped">是否翻转粒子系统</param> /// <param name="bypassPools">是否直接克隆特效</param> /// <returns></returns> private static ParticleSystem GetParticleInstance(Object obj, ParticleEventProperties properties, bool flipped = false, bool bypassPools = false) { // //EB.Debug.LogPSPoolAsset("<color=#00ff00>获取特效实体:" + properties + "</color>,是否翻转:" + flipped + ",是否直接克隆特效:" + bypassPools+",(false:从特效缓存池拿里)"); ParticleSystem ps = null; if (Application.isPlaying) { if (!bypassPools) { ps = LoadParticleWithPool(obj, properties, flipped); } else { ps = LoadParticleWithoutPool(properties, flipped); } } else { ps = LoadParticleWithoutPool(properties, flipped); } return(ps); }
public void SpawnParitcle(ParticleEventProperties properties, bool applyOnTargetList, float startTime) { if (properties == null) { return; } if (applyOnTargetList) { SpawnParticleOnTargetList(properties, applyOnTargetList, startTime); return; } ParticleSystem ps = MoveUtils.InstantiateParticle(this, properties, animator); if (ps == null) { EB.Debug.LogWarning("ps==null ", properties.ParticleName); return; } ParticleCell pc = new ParticleCell(startTime, ps, properties._duration <= 0 ? ps.duration : properties._duration); listPC.Add(pc); lastTime = new float[listPC.Count]; if (!Application.isPlaying) //不需要加载 { ps.EnableEmission(false); ps.Stop(true); } else { pc.startTime = _time; pc.isPlayed = true; PlayParticle(pc.ps, 0); } }
public static ParticleSystem InstantiateParticle(Object obj, ParticleEventProperties properties, Animator animator, bool flipped = false, bool bypassPools = false) { ParticleSystem ps = GetParticleInstance(obj, properties, flipped, bypassPools); if (ps != null) { Transform parent = GetBodyPartTransform(animator, properties._bodyPart, properties._attachmentPath); if (properties._parent) { ps.transform.SetParent(parent); if (properties._bodyPart == BodyPart.HeadNubNotRot) { ps.transform.position = animator.GetComponent <FXHelper>().HeadNubTransform.position; ps.transform.localEulerAngles = Vector3.zero; } else { ps.transform.localPosition = properties._offset; } } else { ps.transform.SetParent(null); ps.transform.position = parent.TransformPoint(properties._offset); } if (properties._lockXOffset || properties._lockYOffset != HeightLock.Unlocked || properties._lockZOffset) { AttachTransform.LockPosition(ps.gameObject, properties._lockXOffset, properties._lockYOffset, properties._lockZOffset); } if (properties._worldSpace) { ps.transform.eulerAngles = properties._angles; if (flipped) { // rotate this by 180 ps.transform.RotateAround(ps.transform.position, Vector3.up, 180.0f); } } else { if (properties._parent) { ps.transform.localEulerAngles = properties._angles; //感觉不好 没看明白 因为我们现在的粒子不挂角色身上 } else { ps.transform.eulerAngles = parent.TransformDirection(properties._angles);//解决无父节点的旋转问题 } } // mirror the effect, for parented effects, this is done inside the attach transform if (flipped && !properties._parent) { FlipWorldRotationByXYPlane(ps.transform); } ps.transform.localScale = properties._scale; } return(ps); }
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); }
public ParticleSystem PlayParticle(ParticleEventProperties properties, bool forcePlay) { return(PlayParticle(properties, 0, forcePlay)); }
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); }