private void OnSceneComplete()
    {
        mParticleMng = new SceneParticleManager();
        if (Camera.main != null)
        {
            Camera.main.cullingMask ^= 1 << LayerMask.NameToLayer("3D UI");
            Camera.main.cullingMask ^= 1 << LayerMask.NameToLayer("UI");
            Camera.main.GetComponent <AudioListener>().enabled = false;
        }
        WindowManager.Instance.CloseAllUI();
        WindowManager.Instance.OpenUI("createrole");
        RenderSettings.ambientLight = Color.white;

        //场景中加入一个聚光灯照亮玩家
        GameObject lightObj = new GameObject("playerlight");
        Light      light    = lightObj.AddComponent <Light>();

        light.type      = LightType.Spot;
        light.range     = 10;
        light.spotAngle = 56.6f;
        light.intensity = 1.69f;

        lightObj.transform.localPosition    = new Vector3(-4.65615f, 6.147261f, -3.736148f);
        lightObj.transform.localEulerAngles = new Vector3(78.3259f, 82.48914f, -119.2915f);


        if (mActivePlayer != null)
        {
            mPlayerID = -1;
            mActivePlayer.Destroy();
        }
        ShowPlayer((int)ModuleManager.Instance.FindModule <CreateRoleModule>().GetRoleID());
    }
Beispiel #2
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);
    }
Beispiel #3
0
    virtual public void RemoveEffect(uint instId)
    {
        if (this.Scene == null || instId == uint.MaxValue)
        {
            return;
        }
        SceneParticleManager mng = this.Scene.GetParticleManager();

        mng.RemoveParticle(instId);
    }
Beispiel #4
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));
    }
Beispiel #5
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);
    }
Beispiel #6
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);
            }
        }
    }