Exemple #1
0
        /// <summary>
        /// 创建基于实体位置跟随的特效,followType一般就2种
        /// 1.脚底
        /// 2.头顶
        /// </summary>
        public static int CreateByCreaturePos(int effectId, Entity newEnt, int followType, Action <Entity> loaded = null)
        {
            if (effectId == 0)
            {
                return(0);
            }
            //BoneEntity bindEnt = (BoneEntity)EntityManager.Inst.GetEnity(bindHandleId);
            // 获取绑定点
            BoneEntity     bindEnt  = newEnt as BoneEntity;
            EntityBaseInfo baseInfo = new EntityBaseInfo();

            baseInfo.m_vPos = bindEnt.GetPos();
            CEffect effect = new CEffect(effectId, baseInfo, loaded);
            Entity  ent    = effect.GetEntity();

            if (ent == null)
            {
                return(0);
            }
            ent.SetLayer((int)LusuoLayer.eEL_Dynamic);

            effect.m_parentEnt  = bindEnt;
            effect.m_followType = followType;
            bindEnt.AddBindObject(ent);

            m_mapEffect.Add(ent.m_hid, effect);

            m_followPos.Add(effect, bindEnt);
            return(ent.m_hid);
        }
Exemple #2
0
        public static int Create(int effectId, Vector3 pos, Vector3 rota, Action <Entity> loaded = null)
        {
            if (effectId == 0)
            {
                return(0);
            }
            EffectCsv     effectCsv    = CsvManager.Inst.GetCsv <EffectCsv>((int)eAllCSV.eAC_Effect);
            EffectCsvData m_effectData = effectCsv.GetData(effectId);

            if (m_effectData == null)
            {
                Debug.LogError("特效为空:" + effectId);
                return(0);
            }
            EntityBaseInfo entInfo = new EntityBaseInfo();

            entInfo.m_resID   = m_effectData.resId;
            entInfo.m_vPos    = pos;
            entInfo.m_vRotate = rota;
            CEffect effect = new CEffect(effectId, entInfo, loaded);
            Entity  ent    = effect.GetEntity();

            ent.SetLayer((int)LusuoLayer.eEL_Dynamic);
            ent.SetPos(pos);
            ent.SetDirection(rota);
            m_mapEffect.Add(ent.m_hid, effect);
            return(ent.m_hid);
        }
Exemple #3
0
        /// <summary>
        /// 创建基于绑定实体身上的特效,和角色一起显隐,无绑定点的在角色位置,不和角色一起显隐,比如刺客的施法特效
        /// 挂载特效可能需要缩放,在设置挂载之后
        /// </summary>
        public static int Create(int effectId, Entity newEnt, string bingPoint, Action <Entity> loaded = null, float scale = 1.0f)
        {
            if (effectId == 0)
            {
                return(0);
            }
            EffectCsv     effectCsv    = CsvManager.Inst.GetCsv <EffectCsv>((int)eAllCSV.eAC_Effect);
            EffectCsvData m_effectData = effectCsv.GetData(effectId);

            if (m_effectData == null)
            {
                return(0);
            }
            EntityBaseInfo baseInfo = new EntityBaseInfo();

            baseInfo.m_resID  = m_effectData.resId;
            baseInfo.m_ilayer = (int)LusuoLayer.eEL_Dynamic;
            baseInfo.m_vScale = Vector3.one * scale;
            // 获取绑定点
            BoneEntity boneEnt       = newEnt as BoneEntity;
            Transform  bindTransform = boneEnt.GetBone(bingPoint);

            CEffect effect;
            Entity  ent;

            if (bindTransform == null)
            {
                //baseInfo.m_vPos = boneEnt.GetPos();
                //baseInfo.m_vRotate = boneEnt.GetRotate();
                //effect = new CEffect(effectId, baseInfo, loaded);
                //ent = effect.GetEntity();
                GameObject obj = boneEnt.GetObject();
                if (obj == null)
                {
                    return(0);
                }
                bindTransform = obj.transform;
            }
            //else
            //{
            baseInfo.m_parent = bindTransform;
            effect            = new CEffect(effectId, baseInfo, loaded);
            ent = effect.GetEntity();
            effect.m_parentEnt = boneEnt;
            boneEnt.AddBindObject(ent);
            //}

            if (ent == null)
            {
                return(0);
            }
            m_mapEffect.Add(ent.m_hid, effect);
            return(ent.m_hid);
        }
Exemple #4
0
        public static int Create(int effectId, Transform uiBindPoint)
        {
            if (effectId == 0)
            {
                return(0);
            }
            EntityBaseInfo baseInfo = new EntityBaseInfo();

            baseInfo.m_parent = uiBindPoint;
            baseInfo.m_vScale = Vector3.one;

            CEffect effect = new CEffect(effectId, baseInfo, null);
            Entity  ent    = effect.GetEntity();

            ent.SetLayer((int)LusuoLayer.eEL_Dynamic);
            ent.SetParent(uiBindPoint);
            m_mapEffect.Add(ent.m_hid, effect);
            return(ent.m_hid);
        }
Exemple #5
0
        public static void Update(float fTime, float fDTime)
        {
            Dictionary <int, CEffect> .Enumerator ms = m_mapEffect.GetEnumerator();
            while (ms.MoveNext())
            {
                m_tempListEffect.Add(ms.Current.Value);
            }

            for (int i = 0; i < m_tempListEffect.Count; i++)
            {
                CEffect ef = m_tempListEffect[i];
                if (!ef.IsFinish())
                {
                    ef.Update(fTime, fDTime);
                }
                else
                {
                    //m_mapEffect.Remove(ef.GetEntity().m_hid);
                    //ef.Destory();
                    Destroy(ef.GetEntity().m_hid);
                }
            }
            m_tempListEffect.Clear();

            foreach (KeyValuePair <CEffect, Entity> item in m_followPos)
            {
                CEffect effect = item.Key;
                Entity  ent    = effect.GetEntity();
                if (ent.IsInited())
                {
                    if (effect.m_followType == 1)
                    {
                        Vector3 targetPos = item.Value.GetPos();
                        ent.SetPos(new Vector3(targetPos.x, 0, targetPos.z));
                    }
                    else
                    {
                        ent.SetPos(item.Value.GetPos() + Vector3.up * item.Value.m_headPos);
                    }
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// 创建基于UI的特效绑定
        /// </summary>
        public static int CreateUI(int effectId, Transform uiBindPoint, int order = 0, Action <CEffect> playend = null, Action <Entity> loaded = null, float scale = 1.0f)
        {
            if (effectId == 0)
            {
                return(0);
            }
            EntityBaseInfo baseInfo = new EntityBaseInfo();

            baseInfo.m_parent = uiBindPoint;
            baseInfo.m_vScale = new Vector3(scale, scale, scale);

            CEffect effect = new CEffect(effectId, baseInfo, loaded);
            Entity  ent    = effect.GetEntity();

            ent.SetLayer((int)LusuoLayer.eEL_UI);
            ent.SetOrder(order);
            ent.SetParent(uiBindPoint);
            m_mapEffect.Add(ent.m_hid, effect);
            effect.AddPlayEnd(playend);
            return(ent.m_hid);
        }