Exemple #1
0
        public void SetBind(int bindHandleId, string bingPoint)
        {
            if (m_parentEnt != null)
            {
                m_parentEnt.RemoveBindObject(m_ent);  // 移除之前的绑定
            }
            BoneEntity bindEnt = (BoneEntity)EntityManager.Inst.GetEnity(bindHandleId);

            if (bindEnt == null || bindEnt.GetObject() == null)
            {
                return;
            }

            Transform bindTransform = bindEnt.GetBone(bingPoint);

            if (bindTransform == null)
            {
                //m_ent.SetPos(bindEnt.GetPos());
                bindTransform = bindEnt.GetObject().transform;
            }
            //else
            //{
            m_ent.SetParent(bindTransform);
            m_parentEnt = bindEnt;
            bindEnt.AddBindObject(m_ent);
            //}
        }
Exemple #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);
        }