Exemple #1
0
    virtual public uint AddEffect(uint resId, string boneName, float dir = float.NaN, AttachMountType atype = AttachMountType.AttachCount)
    {
        if (this.Scene == null)
        {
            return(uint.MaxValue);
        }
        if (!DataManager.EffectTable.ContainsKey(resId))
        {
            return(uint.MaxValue);
        }

        EffectTableItem      item = DataManager.EffectTable[resId] as EffectTableItem;
        SceneParticleManager mng  = this.Scene.GetParticleManager();

        Transform trans = null;

        if (atype != AttachMountType.Wing)
        {
            if (!string.IsNullOrEmpty(boneName) && boneName.StartsWith("%"))
            {
                atype    = AttachMountType.Weapon;
                boneName = boneName.Replace("%", "");
            }
        }
        TransformData data = new TransformData();

        data.notFollow = item.notFollow;
        data.Scale     = new Vector3(item.scale, item.scale, item.scale);

        if (!float.IsNaN(dir))
        {
            data.Rot = new Vector3(0f, dir * Mathf.Rad2Deg, 0f);
        }

        if (!string.IsNullOrEmpty(item.soundId))
        {
            string[] array = item.soundId.Split('|');
            SoundManager.Instance.Play(
                int.Parse(array[UnityEngine.Random.Range(0, array.Length)]),
                item.soundDelay
                );
        }

        uint instID = mng.AddParticle(item.effect_name, item.loop, trans, data, item.limitry);
        ParticleAttachMent attach = new ParticleAttachMent();

        attach.parent     = trans == null ? null : trans.gameObject;
        attach.particleid = instID;
        attach.transform  = data;
        attach.socketname = boneName;
        attach.atype      = atype;
        attach.resid      = resId;

        AttachParticle(attach);

        return(instID);
    }
Exemple #2
0
    virtual public uint AddEffect(uint resId, Vector3 pos, float dir = float.NaN)
    {
        if (this.Scene == null)
        {
            return(uint.MaxValue);
        }
        if (!DataManager.EffectTable.ContainsKey(resId))
        {
            return(uint.MaxValue);
        }
        EffectTableItem      item = DataManager.EffectTable[resId] as EffectTableItem;
        SceneParticleManager mng  = this.Scene.GetParticleManager();

        TransformData data = new TransformData();

        data.Scale     = new Vector3(item.scale, item.scale, item.scale);
        data.notFollow = item.notFollow;
        data.Pos       = pos;
        if (!float.IsNaN(dir))
        {
            data.Rot = new Vector3(0f, dir * Mathf.Rad2Deg, 0f);
        }

        if (!string.IsNullOrEmpty(item.soundId))
        {
            string[] array = item.soundId.Split('|');
            SoundManager.Instance.Play(
                int.Parse(array[UnityEngine.Random.Range(0, array.Length)]),
                item.soundDelay
                );
        }

        uint instID = mng.PlayFx(item.effect_name, item.loop, null, data, -1, null, item.limitry);
        ParticleAttachMent attach = new ParticleAttachMent();

        attach.parent     = null;
        attach.atype      = AttachMountType.AttachCount;
        attach.particleid = instID;
        attach.resid      = resId;

        AttachParticle(attach);

        return(instID);
    }
Exemple #3
0
    /// <summary>
    /// 更新挂接特效
    /// </summary>
    public void UpdateAttachParticle()
    {
        SceneParticleManager particlemng = SceneManager.Instance.GetCurScene().GetParticleManager();
        int nCount = mAttachParticles.Count;
        List <ParticleAttachMent> toDel = null;

        for (int i = 0; i < nCount; ++i)
        {
            ParticleAttachMent attach = mAttachParticles[i];
            ParticleItem       item   = particlemng.GetParticle(attach.particleid);

            if (attach == null || item == null || item.IsDead())
            {
                if (toDel == null)
                {
                    toDel = new List <ParticleAttachMent>();
                }
                toDel.Add(attach);
                continue;
            }
            //将特效更新到对应位置上
            if (attach.parent == null || item.parent == null)
            {
                PrimitiveVisual aVisual = null;
                if (attach.atype != AttachMountType.AttachCount)
                {
                    AttachMent buildinAttach = mAttachMents[(int)attach.atype];
                    if (buildinAttach != null)
                    {
                        aVisual = buildinAttach.visual;
                    }
                }
                else
                {
                    aVisual = mVisual;
                }
                if (aVisual != null && aVisual is MeshVisual && aVisual.Visual != null)
                {
                    Transform tr = null;
                    if (string.IsNullOrEmpty(attach.socketname))
                    {
                        tr = aVisual.VisualTransform;
                    }
                    else
                    {
                        tr = (aVisual as MeshVisual).GetBoneByName(attach.socketname);
                        if (tr == null)
                        {
                            tr = aVisual.VisualTransform;
                        }
                    }

                    attach.parent = tr.gameObject;


                    EffectTableItem effectitem = DataManager.EffectTable[attach.resid] as EffectTableItem;

                    //不跟随释放者的特效,取挂点的方向
                    if (effectitem.notFollow && tr != null && attach.transform != null)
                    {
                        if (tr != null)
                        {
                            attach.transform.Rot = tr.rotation.eulerAngles;
                        }
                        else
                        {
                            attach.transform.Rot = Vector3.zero;
                        }
                    }
                }

                if (attach.parent != null)
                {
                    if (item.visual != null && item.visual.Visual != null)
                    {
                        item.visual.Visual.SetActive(true);
                    }
                    DressingRoom.AttachParticleTo(item, attach.parent.transform);
                }
            }
        }

        if (toDel != null)
        {
            foreach (ParticleAttachMent at in toDel)
            {
                mAttachParticles.Remove(at);
            }
        }
    }
Exemple #4
0
    //-----------------------------特效---------------------------------------

    public virtual void AttachParticle(ParticleAttachMent attach)
    {
        mAttachParticles.Add(attach);
    }