public override IEnumerator SetParticles(ParticleSystem.Particle[] particles) { centroid = ParticleSystemHelper.GetParticleSystemCentroid(particles); yield return(null); CalculateVectorsToCentroid(particles); IsReady = true; }
public override IEnumerator SetParticles(ParticleSystem.Particle[] particles) { isGrowing = true; lastPulseTime = 0.0f; centroid = ParticleSystemHelper.GetParticleSystemCentroid(particles); yield return(null); CalculateVectorsToCentroid(particles); IsReady = true; yield break; }
public override IEnumerator SetParticles(ParticleSystem.Particle[] particles) { centroid = ParticleSystemHelper.GetParticleSystemCentroid(particles); targetPositions = new Vector3[particles.Length]; originalPositions = new Vector3[particles.Length]; for (int i = 0; i < particles.Length; ++i) { targetPositions[i] = (particles[i].position - centroid) + TargetPoint; originalPositions[i] = particles[i].position; } if (particles.Length > 0) { originalSize = particles[0].size; } else { originalSize = 1.0f; } IsReady = true; yield break; }
public void ComputeAnim(float curTime, int index) { #if UNITY_EDITOR SetObjectParent(index); #endif //初始化. role.ResetTransformData(); for (int i = 0, c0 = subDatas[index].objs.Count; i < c0; i++) { var o0 = subDatas[index].objs[i]; o0.ResetTransformData(); } //计算位置变换. for (int i = 0, c0 = _skillData.subSkills[index].channels.Count; i < c0; i++) { var channel = _skillData.subSkills[index].channels[i]; var contain = GetObjectContainById(channel.objId, index); LCHChannelType t = (LCHChannelType)channel.type; #if UNITY_EDITOR if (channel.times.Count == 0 || channel.times[0] != 0) { channel.AddKey(0, 0); if (t == LCHChannelType.PosX || t == LCHChannelType.PosY || t == LCHChannelType.PosZ) { channel.values[0] = 0f; } else if (t == LCHChannelType.ScaleX || t == LCHChannelType.ScaleY || t == LCHChannelType.ScaleZ) { channel.values[0] = 1f; } else if (t == LCHChannelType.RotY) { channel.values[0] = 0f; } } #endif switch (t) { case LCHChannelType.PosX: { float v = channel.GetLerpValue(curTime); contain.pos += new Vector3(v, 0f, 0f); break; } case LCHChannelType.PosY: { float v = channel.GetLerpValue(curTime); contain.pos += new Vector3(0f, v, 0f); break; } case LCHChannelType.PosZ: { float v = channel.GetLerpValue(curTime); contain.pos += new Vector3(0f, 0f, v); break; } case LCHChannelType.RotY: { contain.rot = channel.GetSlerpYValue(curTime); break; } case LCHChannelType.ScaleX: { float v = channel.GetLerpValue(curTime); contain.scale = new Vector3(v, contain.scale.y, contain.scale.z); break; } case LCHChannelType.ScaleY: { float v = channel.GetLerpValue(curTime); contain.scale = new Vector3(contain.scale.x, v, contain.scale.z); break; } case LCHChannelType.ScaleZ: { float v = channel.GetLerpValue(curTime); contain.scale = new Vector3(contain.scale.x, contain.scale.y, v); break; } } } //赋值。 { if (null != role.gameobject) { role.gameobject.transform.localPosition = role.pos; role.gameobject.transform.localRotation = role.rot; role.gameobject.transform.localScale = role.scale; } } for (int i = 0, c0 = subDatas[index].objs.Count; i < c0; i++) { var o0 = subDatas[index].objs[i]; if (null == o0.gameobject) { continue; } o0.gameobject.transform.localPosition = o0.pos; o0.gameobject.transform.localRotation = o0.rot; o0.gameobject.transform.localScale = o0.scale; } //计算物体事件,比如播放动作,声音等。 for (int i = 0, c0 = _skillData.subSkills[index].events.Count; i < c0; i++) { var _e = _skillData.subSkills[index].events[i]; var contain = GetObjectContainById(_e.objId, index); LCHChannelType t = (LCHChannelType)_e.type; ObjDictionary value; float _time; if (t == LCHChannelType.Object) { if (_e.TryGetKeyFrame(curTime, out value, out _time)) { if (null != contain.gameobject) { bool enable = value.GetValue <bool>("enable", true); contain.gameobject.SetActive(enable); if (enable) { string anim_name = value.GetValue <string>("anim", ""); if (anim_name.Length > 0) { if (null == contain.animaction) { contain.animaction = contain.gameobject.GetComponent <Animation>(); } if (null != contain.animaction) { contain.animaction[anim_name].time = _time; //animation[anim_name].speed = 0.0; contain.animaction.Play(anim_name); contain.animaction.Sample(); contain.animaction.Stop(); } } if (_e.objId != -1) { ParticleSystemHelper.Simulate(contain.gameobject, _time); } } } } else { if (null != contain.gameobject) { if (contain.objId != -1) { contain.gameobject.SetActive(false); } } } } if (t == LCHChannelType.Event) { if (_e.TryGetKeyFrame(curTime, out value, out _time)) { if (null != contain.gameobject) { bool enable = value.GetValue <bool>("enable", true); contain.gameobject.SetActive(enable); } } else { if (null != contain.gameobject) { contain.gameobject.SetActive(false); } } } } }
public override IEnumerator SetParticles(ParticleSystem.Particle[] particles) { randomOrdering = ParticleSystemHelper.GenerateRandomOrdering(particles); IsReady = true; yield break; }