Ejemplo n.º 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);
    }
Ejemplo n.º 2
0
    public static uint AddEffect2MV(MeshVisual visual, int effectid, string mount, SceneParticleManager mng)
    {
        if (!DataManager.EffectTable.ContainsKey(effectid))
        {
            return(uint.MaxValue);
        }
        if (!string.IsNullOrEmpty(mount))
        {
            mount = mount.Replace("%", "");
        }
        EffectTableItem item = DataManager.EffectTable[effectid] as EffectTableItem;

        if (item == null)
        {
            return(uint.MaxValue);
        }

        Transform trans = visual.GetBoneByName(mount);

        if (trans == null)
        {
            trans = visual.VisualTransform;
        }
        TransformData data = new TransformData();

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

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

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

        return(mng.AddParticle(item.effect_name, item.loop, trans, data, item.limitry));
    }