override public void Destroy() { //清除挂接的特效的关联,特效就不会随着物体的删除而删除 foreach (ParticleAttachMent attach in mAttachParticles) { if (attach != null) { attach.parent = null; ParticleItem item = SceneManager.Instance.GetCurScene().GetParticleManager().GetParticle(attach.particleid); if (item != null && item.visual != null && item.visual.Visual != null) { item.visual.VisualTransform.parent = null; ParticleVisual.DestroyParticle(item.visual); } } } DestroyVisual(); mStateController = null; mVisualTasks = null; // if(mVisual != null) // { // mVisual.Destroy(); // mVisual = null; // } base.Destroy(); }
private void PreloadResource(ResourceLoader resLoader, ParticleItem particle) { string path = $@"Effect\particle.img\{particle.ParticleName}"; var particleNode = PluginManager.FindWz(path); if (particleNode == null) { return; } var desc = resLoader.LoadParticleDesc(particleNode); var pSystem = new ParticleSystem(this.random); pSystem.LoadDescription(desc); for (int i = 0; i < particle.SubItems.Length; i++) { var subItem = particle.SubItems[i]; var pGroup = pSystem.CreateGroup(i.ToString()); pGroup.Position = new Vector2(subItem.X, subItem.Y); pGroup.Active(); pSystem.Groups.Add(pGroup); } particle.View = new ParticleItem.ItemView() { ParticleSystem = pSystem }; }
public void OnWingSuccess() { AttachMent attachment = mAttachMents[(int)AttachMountType.Wing]; if (attachment == null) { return; } WingCommonTableItem commonRes = DataManager.WingCommonTable[mWingID] as WingCommonTableItem; if (commonRes == null) { return; } int effectid = WingModule.GetEffectId(mWingID, (int)mWingLv); if (effectid == -1) { return; } uint instid = ParticleUtility.AddEffect2MV(attachment.visual as MeshVisual, effectid, commonRes.modelSlot, SceneManager.Instance.GetCurScene().GetParticleManager()); ParticleItem pitem = SceneManager.Instance.GetCurScene().GetParticleManager().GetParticle(instid); if (pitem != null) { pitem.Layer = layermask; } }
public void DestroyParticle(int particleID, bool immediately) { bool hasParticle = false; int count = particlesList.Count; for (int i = count - 1; i >= 0; i--) { ParticleItem item = particlesList[i]; if (item.particleID == particleID) { if (immediately) { particlesList.Remove(item); } else { item.toBeRemoved = true; } hasParticle = true; } } if (!hasParticle) { CLog.Info("Particle is not in the list"); } }
private void ProcessWeaponShow(ShowWeaponItem item) { //播放人物动作 if (!string.IsNullOrEmpty(item.roleanim)) { WeaponTableItem mWeaopnRes = DataManager.WeaponTable[mWeaponID] as WeaponTableItem; string animname = AnimationNameDef.GetAnimNameByStatename(mWeaopnRes.ani_pre, item.roleanim); PlayAnimaton(animname); } //播放武器动作 if (!string.IsNullOrEmpty(item.weaponanim)) { WeaponTableItem mWeaopnRes = DataManager.WeaponTable[mWeaponID] as WeaponTableItem; string animname = AnimationNameDef.WeaponPrefix + item.weaponanim; PlayWeaponAnimation(animname); } mShowEffect.Add(AttachEffect(item.effectid0, item.mountpoint0)); mShowEffect.Add(AttachEffect(item.effectid1, item.mountpoint1)); mShowEffect.Add(AttachEffect(item.effectid2, item.mountpoint2)); foreach (uint id in mShowEffect) { ParticleItem pitem = SceneManager.Instance.GetCurScene().GetParticleManager().GetParticle(id); if (pitem == null) { continue; } pitem.Layer = layermask; } }
public CentreOfGravity() { // Add initial particles for (int i = 0; i < 3; i++) { AddParticle(); } _selectedParticle = _particles[0]; // Add centre of grav point Vector centre = _particles.Select(p => p.Particle).ToList().CentreOfMass(); _centreOfGrav = new ParticleItem { Particle = new Particle(1, centre), GraphicalPoint = new CCPoint((float)centre.X, (float)centre.Y), DrawNode = new CCDrawNode() }; InitializeComponent(); UpdateLabels(); GameView.ViewCreated += HandleViewCreated; }
public void RemoveParticleByAlias(string alias) { IDictionaryEnumerator itr = mEffects.GetEnumerator(); while (itr.MoveNext()) { ParticleItem item = itr.Value as ParticleItem; if (item == null || string.Equals(item.Alias, alias)) { mDestroys.Add((uint)itr.Key); } } // for( int i = 0 ; i < mEffects.Keys.Count ; ++i ) // { // uint key = mEffects.Keys.ElementAt(i); // if( !mEffects.ContainsKey(key) ) // { // continue; // } // ParticleItem item = mEffects[key]; // if (item == null || string.Equals(item.Alias, alias)) // { // mDestroys.Add(key); // } // } }
/// <summary> /// 播放一个特效 /// </summary> /// <param name="fxname"></param> /// <param name="loop"></param> /// <param name="fxtype"></param> /// <param name="parent"></param> /// <param name="trans"></param> /// <param name="lifetime"></param> /// <param name="alias"></param> /// <param name="limitry"></param> /// <returns></returns> public uint PlayFx(string fxname, bool loop, Transform parent = null, TransformData trans = null, float lifetime = -1, string alias = null, bool limitry = false) { ParticleData data = ParticleConfigManager.Instance.GetParticleData(fxname); if (data == null) { GameDebug.LogError("没有找到特效: " + fxname); return(uint.MaxValue); } uint instID = mLastEffectID++; ParticleItem item = new ParticleItem(); item.localTrans = trans; item.parent = parent; item.Alias = alias; item.LimitRy = limitry; item.Loop = loop; if (mEffects.ContainsKey(instID)) { mEffects.Remove(instID); } mEffects.Add(instID, item); BehaviourUtil.StartCoroutine(GenerateVisual(instID, fxname, item)); return(instID); }
public int CreateParticleForPlayer(string particleName, EffectAttachType particleAttach, BaseEntity owningEntity, BaseEntity owningPlayer) { ParticleItem item = new ParticleItem(particleName, owningEntity); particlesList.Add(item); return(item.particleID); }
protected override void DestroyVisual() { //清除挂接的特效的关联,特效就不会随着物体的删除而删除 foreach (ParticleAttachMent attach in mAttachParticles) { if (attach != null) { attach.parent = null; ParticleItem item = SceneManager.Instance.GetCurScene().GetParticleManager().GetParticle(attach.particleid); if (item != null && item.visual != null && item.visual.Visual != null) { item.visual.VisualTransform.parent = null; item.visual.Visual.SetActive(false); } } } ///挂接的物体也摘除下来 foreach (AttachMent attach in mAttachMents) { if (attach != null) { attach.parent = null; if (attach.visual != null && attach.visual.Visual != null) { attach.visual.VisualTransform.parent = null; attach.visual.Visual.SetActive(false); } } } base.DestroyVisual(); }
public override void Destroy() { if (item != null && item.visual != null) { ParticleVisual.DestroyParticle(item.visual); } item = null; base.Destroy(); }
private void LoadParticle(Wz_Node node) { foreach (var particleNode in node.Nodes) { var item = ParticleItem.LoadFromNode(particleNode); item.Name = node.Text; Scene.Effect.Slots.Add(item); } }
private void AddButton_Clicked(object sender, EventArgs e) { if (_particles.Count < 10) { AddParticle(); _selectedParticle = _particles.Last(); RedrawParticles(); } }
public void RemoveParticle(uint instID) { if (!mEffects.ContainsKey(instID)) { return; } ParticleItem item = mEffects[instID] as ParticleItem; mDestroys.Add(instID); }
public bool SetupParticle(string effectName) { item = new ParticleItem(); item.localTrans = null; item.parent = null; item.Alias = null; item.LimitRy = false; item.Loop = false; BehaviourUtil.StartCoroutine(GenerateVisual(effectName, item)); return(true); }
private void RemoveButton_Clicked(object sender, EventArgs e) { if (_particles.Count > 1) { ParticleItem toRemove = _particles[_particles.Count - 1]; _particles.Remove(_selectedParticle); _selectedParticle = _particles[0]; RedrawParticles(); } }
private bool OnTouchBegan(CCTouch touch, CCEvent arg) { //Get nearest particle _selectedParticle = _particles.OrderBy(p => p.Particle.Position.DistanceTo(new Vector(touch.Location.X, touch.Location.Y))).First(); if (_selectedParticle != null) { MassSlider.Value = _selectedParticle.Particle.Mass.Kilograms; } UpdateLabels(); return(true); }
public void Update() { // for (int i = 0; i < mEffects.Keys.Count; ++i) // { // uint key = mEffects.Keys.ElementAt(i); // if (!mEffects.ContainsKey(key)) // { // continue; // } // // } IDictionaryEnumerator itr = mEffects.GetEnumerator(); while (itr.MoveNext()) { ParticleItem item = itr.Value as ParticleItem; if (item != null) { //检测特效是否播放完成 if (item == null || item.IsDead()) { //自然消失的特效放在这里,管理器将其销毁 if (item != null) { mDestroys.Add((uint)itr.Key); } } else { item.OnUpdate(); } } } for (int i = 0; i < mDestroys.Count; ++i) { uint key = (uint)mDestroys[i]; if (mEffects.ContainsKey(key)) { ParticleItem item = mEffects[key] as ParticleItem; if (item.visual != null) { ParticleVisual.DestroyParticle(item.visual); } mEffects.Remove(key); } } mDestroys.Clear(); }
public ProjectileItem(BaseEntity source, BaseAbility ability, ProjectileItemParams infoParams, EntityTarget target) { this.source = source; this.ability = ability; this.infoParams = infoParams; this.target = target; this.projectileID = ProjectileManager.Instance.GernerateProjectileID(); this.velocity = infoParams.velocity; this.position = infoParams.spawnOrigin; this.expireTime = infoParams.expireTime; this.particleItem = new ParticleItem(this.infoParams.effectName, this.source); var obj = new GameObject("projectile"+projectileID); obj.AddComponent<BoxCollider>(); shellObj = obj.transform; CObjectsPool.Instance.Instantiate("", infoParams.effectName, (_obj,uid)=>{ var tmp = _obj as Transform; if(tmp != null) tmp.parent = shellObj; } ,ObjectType.Effect); }
public static void AttachParticleTo(ParticleItem item, Transform parent) { if (item.visual == null || item.visual.Visual == null) { return; } Transform visualTrans = item.visual.VisualTransform; item.parent = parent; if (item.parent != null) { //判定effect.txt 里是否设置 不跟随 if (item.localTrans == null || (item.localTrans != null && !item.localTrans.notFollow)) { visualTrans.parent = item.parent; visualTrans.localPosition = Vector3.zero; visualTrans.localEulerAngles = Vector3.zero; visualTrans.localScale = Vector3.one; } } if (item.localTrans != null) { if (item.localTrans.notFollow && item.parent != null) { if (!item.localTrans.IsModified(TransformData.ModifyFlag.Position)) { item.localTrans.Pos = item.parent.position; } if (!item.localTrans.IsModified(TransformData.ModifyFlag.Rotation)) { item.localTrans.Rot = item.parent.eulerAngles; } } item.localTrans.Apply(visualTrans); item.visual.Scale = item.localTrans.Scale.x;//缩放只有个值 } }
private MeshItem GetMeshParticle(ParticleItem particle) { var pSystem = particle.View?.ParticleSystem; if (pSystem == null) { return(null); } Vector2 position; position.X = renderEnv.Camera.Center.X * (100 + particle.Rx) / 100; position.Y = renderEnv.Camera.Center.Y * (100 + particle.Ry) / 100; var mesh = batcher.MeshPop(); mesh.RenderObject = pSystem; mesh.Position = position; mesh.Z0 = particle.Z; return(mesh); }
public ProjectileItem(BaseEntity source, BaseAbility ability, ProjectileItemParams infoParams) { this.source = source; this.ability = ability; this.infoParams = infoParams; this.projectileID = ProjectileManager.Instance.GernerateProjectileID(); this.velocity = infoParams.velocity; this.position = infoParams.spawnOrigin; this.expireTime = infoParams.expireTime; this.particleItem = new ParticleItem(this.infoParams.effectName, this.source); //碰撞的部分还需要特别写,为了服务器验证计算。 var obj = new GameObject("projectile"+projectileID); collider = obj.AddComponent<CapsuleCollider>(); collider.radius = this.infoParams.startRadius; shellObj = obj.transform; CObjectsPool.Instance.Instantiate("", infoParams.effectName, (_obj,uid)=>{ var tmp = _obj as Transform; if(tmp != null) tmp.parent = shellObj; } ,ObjectType.Effect); }
public override void Awake() { base.Awake(); playItem = new List <DivinationItemView>(); allItem = new List <DivinationItemView>(); playImage = hexagon_trf.GetComponentsInChildren <Image>(); for (int i = 1; i < playImage.Length; i++) { Image image = playImage[i]; int index = i; EventListener.Get(image.gameObject).OnClick = e => { if (index <= playItem.Count) { playItem[index - 1].SetAlpha(0); for (int j = 1; j < playItem[index - 1].data.Level; j++) { playExp -= playItem[index - 1].data.LevelUpExp(j); } playExp -= playItem[index - 1].data.Exp; playExp -= playItem[index - 1].data.TotemConfig.Exp; playItem.RemoveAt(index - 1); SetPlayView(); ExpValue(); } }; } playText = hexagon_trf.GetComponentsInChildren <Text>(); particle = particlemain_trf.GetComponentInChildren <ParticleItem>(); particle.Stop(); childparticle = particle_trf.GetComponentsInChildren <ParticleItem>(); for (int i = 0; i < childparticle.Length; i++) { childparticle[i].Stop(); } }
private IEnumerator GenerateVisual(string effectName, ParticleItem item) { item.visual = ParticleVisual.CreateParticle(effectName, null); item.Layer = item.Layer; if (item.localTrans != null) { if (item.visual == null) { yield break; } item.visual.Scale = item.localTrans.Scale.x; } while (!item.visual.IsCompleteOrDestroy) { yield return(2); } if (item.visual.IsDestroy) { item = null; yield break; } item.init = true; //特效创建完毕之后 Transform visualTrans = item.visual.VisualTransform; if (item.parent != null) { //判定effect.txt 里是否设置 不跟随 if (item.localTrans == null || (item.localTrans != null && !item.localTrans.notFollow)) { visualTrans.parent = item.parent; visualTrans.localPosition = Vector3.zero; visualTrans.localEulerAngles = Vector3.zero; visualTrans.localScale = Vector3.one; } } if (item.localTrans != null) { if (item.localTrans.notFollow && item.parent != null) { if (!item.localTrans.IsModified(TransformData.ModifyFlag.Position)) { item.localTrans.Pos = item.parent.position; } if (!item.localTrans.IsModified(TransformData.ModifyFlag.Rotation)) { item.localTrans.Rot = item.parent.eulerAngles; } } item.localTrans.Apply(visualTrans); item.visual.Scale = item.localTrans.Scale.x;//缩放只有个值 } item.visual.LimitRotate = item.LimitRy; OnParticleSucess(item.visual); }
private IEnumerator GenerateVisual(uint instId, string effectName, ParticleItem item) { item.visual = ParticleVisual.CreateParticle(effectName, null); item.Layer = item.Layer; if (item.localTrans != null) { if (item.visual == null) { yield break; } item.visual.Scale = item.localTrans.Scale.x; } //5s钟加载不出来的特效放弃 float timeElapsed = 0; while (!item.visual.IsCompleteOrDestroy && timeElapsed < 5) { timeElapsed += Time.fixedDeltaTime; yield return(2); } if (!item.visual.IsCompleteOrDestroy) { //Debug.Log("就是加载不出来" + effectName); mDestroys.Add(instId); yield break; } item.init = true; //特效创建完毕之后 Transform visualTrans = item.visual.VisualTransform; if (item.parent != null) { //判定effect.txt 里是否设置 不跟随 if (item.localTrans == null || (item.localTrans != null && !item.localTrans.notFollow)) { visualTrans.parent = item.parent; visualTrans.localPosition = Vector3.zero; visualTrans.localEulerAngles = Vector3.zero; visualTrans.localScale = Vector3.one; } } if (item.localTrans != null) { if (item.localTrans.notFollow && item.parent != null) { if (!item.localTrans.IsModified(TransformData.ModifyFlag.Position)) { item.localTrans.Pos = item.parent.position; } if (!item.localTrans.IsModified(TransformData.ModifyFlag.Rotation)) { item.localTrans.Rot = item.parent.eulerAngles; } } item.localTrans.Apply(visualTrans); item.visual.Scale = item.localTrans.Scale.x;//缩放只有个值 } item.visual.LimitRotate = item.LimitRy; }
/// <summary> /// 更新挂接特效 /// </summary> public void UpdateAttachParticle() { SceneParticleManager particlemng = SceneManager.Instance.GetCurScene().GetParticleManager(); int nCount = mAttachParticles.Count; List <ParticleAttachMent> toDel = null; for (int i = 0; i < nCount; ++i) { ParticleAttachMent attach = mAttachParticles[i]; ParticleItem item = particlemng.GetParticle(attach.particleid); if (attach == null || item == null || item.IsDead()) { if (toDel == null) { toDel = new List <ParticleAttachMent>(); } toDel.Add(attach); continue; } //将特效更新到对应位置上 if (attach.parent == null || item.parent == null) { PrimitiveVisual aVisual = null; if (attach.atype != AttachMountType.AttachCount) { AttachMent buildinAttach = mAttachMents[(int)attach.atype]; if (buildinAttach != null) { aVisual = buildinAttach.visual; } } else { aVisual = mVisual; } if (aVisual != null && aVisual is MeshVisual && aVisual.Visual != null) { Transform tr = null; if (string.IsNullOrEmpty(attach.socketname)) { tr = aVisual.VisualTransform; } else { tr = (aVisual as MeshVisual).GetBoneByName(attach.socketname); if (tr == null) { tr = aVisual.VisualTransform; } } attach.parent = tr.gameObject; EffectTableItem effectitem = DataManager.EffectTable[attach.resid] as EffectTableItem; //不跟随释放者的特效,取挂点的方向 if (effectitem.notFollow && tr != null && attach.transform != null) { if (tr != null) { attach.transform.Rot = tr.rotation.eulerAngles; } else { attach.transform.Rot = Vector3.zero; } } } if (attach.parent != null) { if (item.visual != null && item.visual.Visual != null) { item.visual.Visual.SetActive(true); } DressingRoom.AttachParticleTo(item, attach.parent.transform); } } } if (toDel != null) { foreach (ParticleAttachMent at in toDel) { mAttachParticles.Remove(at); } } }