예제 #1
0
        private void CheckParticleList()
        {
            ParticleSystem[] pchild = AffectedObject.GetComponentsInChildren <ParticleSystem>(true);
            int newcount            = pchild.Length;

            particleList = new List <ParticleSystem>();
            List <ParticleSystem> rootlist = new List <ParticleSystem>();

            if (pchild != null && pchild.Length > 0)
            {
                particleList.AddRange(pchild);
            }
            int len = particleList.Count;

            particleDict = new Dictionary <string, List <string> >();

            for (int i = 0; i < len; i++)
            {
                if (ParticleSystemUtility.IsRoot(particleList[i]))
                {
                    string key = particleList[i].transform.parent.name;
                    if (particleDict.ContainsKey(key))
                    {
                        particleDict[key].Add(particleList[i].name);
                    }
                    else
                    {
                        particleDict.Add(key, new List <string>()
                        {
                            particleList[i].name
                        });
                    }
                    rootlist.Add(particleList[i]);
                }
            }
            rootParticleList = rootlist;
        }
예제 #2
0
        public override void Begin()
        {
            base.Begin();
            if (effecrObj.Count >= 1)
            {
                foreach (var e in effecrObj)
                {
                    GameObject.DestroyImmediate(e);
                }
            }
            effecrObj.Clear();
            effecrObj.Add(GameObject.Instantiate(effectunit.artEffect.effectObj));
            particleSys.Clear();
            ParticleSystem[] particleSys0 = effecrObj[0].GetComponentsInChildren <ParticleSystem>();
            for (int i = 0; i < particleSys0.Length; i++)
            {
                particleSys0[i].Stop();
                particleSys0[i].Simulate(0);
                particleSys0[i].Clear();
                if (ParticleSystemUtility.IsRoot(particleSys0[i]))
                {
                    particleSys.Add(particleSys0[i]);
                }
            }
            effecrObj[0].SetActive(false);
            SetState(TRAJSTATE.STATE_BEGIN);
            float offsetY = 0;

            effecrObj[0].transform.SetParent(TargetObject.transform);
            if (effectunit.configure.posType == CySkillEditor.EffectConfigure.PosType.FEET)
            {
                offsetY = 0;
            }
            else if (effectunit.configure.posType == CySkillEditor.EffectConfigure.PosType.BODY)
            {
                offsetY = effectunit.configure.bodyHeight;
            }
            else if (effectunit.configure.posType == CySkillEditor.EffectConfigure.PosType.HEAD)
            {
                offsetY = effectunit.configure.headHeight;
            }
            else if (effectunit.configure.posType == CySkillEditor.EffectConfigure.PosType.BONE)
            {
                Transform bone = TargetObject.transform.Find(effectunit.configure.boneName);
                if (bone)
                {
                    effecrObj[0].transform.SetParent(bone);
                }
            }

            effecrObj[0].transform.localPosition = new Vector3(0, offsetY, 0);
            Vector3 offset = effectunit.configure.position;

            effecrObj[0].transform.localPosition += offset;
            _originPos  = effecrObj[0].transform.position;
            _originPos += _originPosOffset;
            if (effectunit.configure.posType == CySkillEditor.EffectConfigure.PosType.WORLD)
            {
                effecrObj[0].transform.position = offset;
            }
            if (Target != null)
            {
                _originDir = (Target.position - _originPos).normalized;
            }
            else
            {
                //_originDir =  TargetObject.transform.forward;
            }
            _originDir += _originDirOffset;
        }
        public override void Init()
        {
            if (active)
            {
                return;
            }
            if (EffectUnit == null)
            {
                return;
            }
            if (EffectUnit.artEffect.effectObj == null)
            {
                return;
            }
            if (EffectObj)
            {
                GameObject.DestroyImmediate(EffectObj);
            }
            particleSys.Clear();
            EffectObj = GameObject.Instantiate(EffectUnit.artEffect.effectObj);
            ParticleSystem[] particleSys0 = EffectObj.GetComponentsInChildren <ParticleSystem>();
            for (int i = 0; i < particleSys0.Length; i++)
            {
                particleSys0[i].Stop();
                particleSys0[i].Simulate(0);
                particleSys0[i].Clear();
                if (ParticleSystemUtility.IsRoot(particleSys0[i]))
                {
                    particleSys.Add(particleSys0[i]);
                }
            }
            float   offsetY = 0;
            Vector3 offset  = EffectUnit.configure.position;

            //世界坐标
            if (EffectUnit.configure.posType == CySkillEditor.EffectConfigure.PosType.WORLD)
            {
                EffectObj.transform.position = offset;
            }
            else //世界坐标 相对于主角
            if (EffectUnit.configure.posType == CySkillEditor.EffectConfigure.PosType.RELATIVE)
            {
                EffectObj.transform.position = TargetObject.transform.position + offset;
            }
            else
            {
                //附着于主角身上
                EffectObj.transform.SetParent(TargetObject.transform);
                if (EffectUnit.configure.posType == CySkillEditor.EffectConfigure.PosType.FEET)
                {
                    offsetY = 0;
                }
                else if (EffectUnit.configure.posType == CySkillEditor.EffectConfigure.PosType.BODY)
                {
                    offsetY = EffectUnit.configure.bodyHeight;
                }
                else if (EffectUnit.configure.posType == CySkillEditor.EffectConfigure.PosType.HEAD)
                {
                    offsetY = EffectUnit.configure.headHeight;
                }
                else if (EffectUnit.configure.posType == CySkillEditor.EffectConfigure.PosType.BONE)
                {
                    Transform bone = TargetObject.transform.Find(EffectUnit.configure.boneName);
                    if (bone)
                    {
                        EffectObj.transform.SetParent(bone);
                    }
                }
                EffectObj.transform.localPosition  = new Vector3(0, offsetY, 0);
                EffectObj.transform.localPosition += offset;
            }
            EffectObj.transform.rotation = Quaternion.Euler(EffectUnit.configure.rotation);

            active = true;
        }