private static void SetAnimation(ref BaseAnimation animation, bool isGeneric, GameObject gameObject) { if (isGeneric) { Animator animator = gameObject.GetComponent <Animator>(); if (animator == null) { Debug.LogError("Prefab's animator is not exit, prefab name " + gameObject.name); } if (animation is SkillAnimator) { animation.Init(animator); } else { animation = new SkillAnimator(animator); } } else { if (animation is SkillClip) { animation.Init(gameObject); } else { animation = new SkillClip(gameObject); } } }
private static void StopEffect() { foreach (var idParticlesPair in m_dicIDEffects) { uint id = idParticlesPair.Key; if (!m_dicIDEffectObject[id].activeSelf) { continue; } ParticleSystem[] particles = idParticlesPair.Value; for (ushort index = 0; index < particles.Length; index++) { particles[index].Simulate(0); } } foreach (var idEffectAnimation in m_dicIDEffectAnimation) { SkillAnimator animation = idEffectAnimation.Value; animation.Stop(); } foreach (var idObjectPair in m_dicIDEffectObject) { if (idObjectPair.Value.activeSelf) { idObjectPair.Value.SetActive(false); } } }
private static void SetPlayEffectTime(float sampleTime) { var listEffect = LuaAnimClipModel.ListEffect; for (ushort pairIndex = 0; pairIndex < listEffect.Count; pairIndex++) { float time = listEffect[pairIndex].Key; if (sampleTime < time) { break; } AnimClipData.EffectData[] datas = listEffect[pairIndex].Value; for (ushort dataIndex = 0; dataIndex < datas.Length; dataIndex++) { AnimClipData.EffectData data = datas[dataIndex]; if (data.type == AnimClipData.EffectType.Hit) { continue; } if (m_dicIDEffectObject.ContainsKey(data.id) && !m_dicIDEffectObject[data.id].activeSelf) { m_dicIDEffectObject[data.id].SetActive(true); } if (m_dicIDEffects.ContainsKey(data.id) && m_dicIDObjectNameDelay.ContainsKey(data.id)) { Dictionary <string, float> dicParticleNameTime = m_dicIDObjectNameDelay[data.id]; ParticleSystem[] particles = m_dicIDEffects[data.id]; for (ushort particleIndex = 0; particleIndex < particles.Length; particleIndex++) { ParticleSystem particle = particles[particleIndex]; if (!dicParticleNameTime.ContainsKey(particle.name)) { continue; } float simulateTime = time + dicParticleNameTime[particle.name] - Config.RuntimeEffectDelay; if (sampleTime >= simulateTime) { particle.Simulate(sampleTime - simulateTime); } else { particle.Simulate(0); } } } if (m_dicIDEffectAnimation.ContainsKey(data.id)) { SkillAnimator animation = m_dicIDEffectAnimation[data.id]; animation.SetStateAnimationPlayTime(sampleTime - time); } } } }
private static void SetEffectParticle(uint id, GameObject effectNode) { ParticleSystem[] particles = effectNode.GetComponentsInChildren <ParticleSystem>(true); if (particles == null || particles.Length == 0) { return; } m_dicIDEffects.Add(id, particles); for (ushort index = 0; index < particles.Length; index++) { ParticleSystem particle = particles[index]; if (!FilterParticleObject(particle)) { continue; } SetUseAutoSeedEffect(effectNode, particle); string name = particle.name; float startDelay = particle.main.startDelayMultiplier; if (!m_dicIDObjectNameDelay.ContainsKey(id)) { m_dicIDObjectNameDelay.Add(id, new Dictionary <string, float>()); } if (m_dicIDObjectNameDelay[id].ContainsKey(name)) { m_dicIDObjectNameDelay[id][name] = startDelay; } else { m_dicIDObjectNameDelay[id].Add(name, startDelay); } #pragma warning disable 0618 particle.startDelay = 0; #pragma warning restore 0618 } Animator animator = effectNode.GetComponent <Animator>(); if (animator == null) { return; } AnimatorState state = AnimatorControllerManager.GetAnimatorControllerFirstStateName(animator, Config.SkillEffectPath); if (state == null || state.motion == null) { return; } SkillAnimator animation = new SkillAnimator(animator); animation.Record(state); m_dicIDEffectAnimation.Add(id, animation); }