Exemple #1
0
            public override GameObject Create()
            {
                if (m_EffectData == null)
                {
                    return(null);
                }

                //GameObject proto = AssetsLoader.Instance.LoadPrefabImm(data.m_path) as GameObject;
                GameObject proto = Instance.GetEffect(m_EffectData.m_path);

                if (proto != null)
                {
                    GameObject effect = Instantiate(proto, position, rotation) as GameObject;
                    //effect.AddComponent<DestroyTimer>().m_LifeTime = data.m_liveTime;
                    if (m_EffectData.m_liveTime > -PETools.PEMath.Epsilon)
                    {
                        GameObject.DestroyObject(effect, m_EffectData.m_liveTime);
                    }

                    if (m_Data != null)
                    {
                        MonoBehaviour[] behaviours = effect.GetComponentsInChildren <MonoBehaviour>();

                        foreach (MonoBehaviour behaviour in behaviours)
                        {
                            SkInst          inst     = m_Data as SkInst;
                            ISkEffectEntity skEffect = behaviour as ISkEffectEntity;
                            if (inst != null && skEffect != null && !skEffect.Equals(null))
                            {
                                skEffect.Inst = inst;
                            }
                        }
                    }

                    if (null != parent)
                    {
                        effect.transform.parent = parent;
                    }

                    OnSpawned(effect);
                    return(effect);
                }

                return(null);
            }
Exemple #2
0
            public override GameObject Create()
            {
                if (m_EffectData == null || _bone == null)
                {
                    return(null);
                }

                //GameObject proto = AssetsLoader.Instance.LoadPrefabImm(data.m_path) as GameObject;
                GameObject proto = Instance.GetEffect(m_EffectData.m_path);

                if (proto != null)
                {
                    //StartCoroutine(InstantiateCoroutine(proto, bone, data.m_Axis, data.m_liveTime, data.m_bind));
                    Quaternion rot = Quaternion.identity;
                    if (m_EffectData.m_Rot)
                    {
                        rot = _bone.rotation;
                    }

                    GameObject effect = Instantiate(proto, _bone.position, rot) as GameObject;
                    //effect.AddComponent<DestroyTimer>().m_LifeTime = data.m_liveTime;
                    if (m_EffectData.m_liveTime > -PETools.PEMath.Epsilon)
                    {
                        GameObject.DestroyObject(effect, m_EffectData.m_liveTime);
                    }

                    if (m_EffectData.m_bind)
                    {
                        EffectLateupdateHelper lateU = effect.GetComponent <EffectLateupdateHelper>();
                        if (null != lateU)
                        {
                            lateU.Init(_bone);

                            if (m_EffectData.m_posStr == "CenterPos")
                            {
                                PeEntity entity = _rootTrans.GetComponentInParent <PeEntity>();
                                if (entity != null)
                                {
                                    lateU.local = entity.bounds.center;

                                    HitEffectScale scaleEffect = effect.GetComponent <HitEffectScale>();
                                    if (scaleEffect != null)
                                    {
                                        scaleEffect.Scale = entity.maxRadius * 2.0f;

                                        if (entity.peTrans != null)
                                        {
                                            scaleEffect.EmissionScale = entity.peTrans.bound.size;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (m_Data != null)
                    {
                        Profiler.BeginSample("GetMono");
                        MonoBehaviour[] behaviours = effect.GetComponentsInChildren <MonoBehaviour>();
                        Profiler.EndSample();

                        foreach (MonoBehaviour behaviour in behaviours)
                        {
                            SkInst          inst     = m_Data as SkInst;
                            ISkEffectEntity skEffect = behaviour as ISkEffectEntity;
                            if (inst != null && skEffect != null && !skEffect.Equals(null))
                            {
                                skEffect.Inst = inst;
                            }
                        }
                    }

                    OnSpawned(effect);
                    return(effect);
                }

                return(null);
            }