Beispiel #1
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);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        public void PlayEffectSound(int effectId)
        {
            if (GetEnt() == null)
            {
                return;
            }

            // 播放声音
            EffectCsv     effectCsv = CsvManager.Inst.GetCsv <EffectCsv>((int)eAllCSV.eAC_Effect);
            EffectCsvData data      = effectCsv.GetData(effectId);

            if (data != null)
            {
                int soundHid = SoundManager.Inst.PlaySound(data.soundId, GetEnt().GetPos());
                m_soundEnt = EntityManager.Inst.GetEnity(soundHid);
            }
        }
Beispiel #4
0
        private void Create(int csvId, EntityBaseInfo entInfo, Action <Entity> loaded = null)
        {
            EffectCsv effectCsv = CsvManager.Inst.GetCsv <EffectCsv>((int)eAllCSV.eAC_Effect);

            m_effectData = effectCsv.GetData(csvId);
            if (m_effectData == null || m_effectData.resId == 0)
            {
                Debug.LogError("找不到特效id:" + csvId);
                return;
            }
            if (entInfo == null)
            {
                entInfo = new EntityBaseInfo();
            }
            entInfo.m_resID = m_effectData.resId;
            int handldId = EntityManager.Inst.CreateEntity(eEntityType.eEffectEntity, entInfo, loaded);

            m_ent = EntityManager.Inst.GetEnity(handldId);

            m_maxTime = m_effectData.lifeTime;
            if (m_maxTime.Equals(0.0f))
            {
                m_bAutoDel = false;
            }

            //if (GameManager.Instance.m_speedUpInLoading)
            //    return;
            if (m_effectData == null || m_ent == null)
            {
                return;
            }
            int soundHid = SoundManager.Inst.PlaySound(m_effectData.soundId, m_ent.GetPos());

            m_soundEnt = EntityManager.Inst.GetEnity(soundHid);
            if (m_effectData.shakeCamera == 1)
            {
                CameraMgr.Inst.OnShake();
            }
        }
Beispiel #5
0
        public void LoadPre(UIHeroShowEffectCsvData data, Action loaded)
        {
            List <int> loadPre = new List <int>();
            int        resId   = data.resId;

            loadPre.Add(resId);

            EffectCsv effectCsv = CsvManager.Inst.GetCsv <EffectCsv>((int)eAllCSV.eAC_Effect);

            // 入场特效和声音
            string[] effectList = m_showEffectData.enterEffectId.Split('|');
            for (int i = 0; i < effectList.Length; i++)
            {
                int effectId;
                int.TryParse(effectList[i], out effectId);
                EffectCsvData enterEffect = effectCsv.GetData(effectId);
                if (enterEffect == null)
                {
                    Debug.LogWarning("英雄展示表配了特效id,但是特效表没有:" + effectId);
                }
                else
                {
                    if (enterEffect.resId != 0)
                    {
                        loadPre.Add(enterEffect.resId);
                    }
                    if (enterEffect.soundId != 0)
                    {
                        loadPre.Add(enterEffect.soundId);
                    }
                }
            }
            // 点击特效和声音
            int           clickEffect = m_showEffectData.clickEffectId;
            EffectCsvData eData       = effectCsv.GetData(clickEffect);

            if (eData == null)
            {
                Debug.LogWarning("英雄展示表配了特效id,但是特效表没有:" + clickEffect);
            }
            else
            {
                if (eData.resId != 0)
                {
                    loadPre.Add(eData.resId);
                }
                if (eData.soundId != 0)
                {
                    loadPre.Add(eData.soundId);
                }
            }

            m_preRes = new Resource[loadPre.Count];
            //Debug.Log("预加载数量:" + loadPre.Count);
            int curPreNum = 0;

            for (int i = 0; i < loadPre.Count; i++)
            {
                Resource tRes = ResourceFactory.Inst.LoadResource(loadPre[i], (res) =>
                {
                    curPreNum++;
                    if (curPreNum == loadPre.Count)
                    {
                        if (loaded != null)
                        {
                            loaded();
                        }
                    }
                });
                m_preRes[i] = tRes;
            }
        }