Exemple #1
0
        public void UnLoadScene()
        {
            // 销毁场景模型
            if (m_ent != null)
            {
                EntityManager.Inst.RemoveEntity(m_ent.m_hid);
            }
            if (m_colliderEnt != null)
            {
                EntityManager.Inst.RemoveEntity(m_colliderEnt.m_hid);
            }
            // 销毁地图动态障碍数据
            if (m_staticDynamic != null)
            {
                ResourceFactory.Inst.UnLoadResource(m_staticDynamic);
                m_staticDynamic = null;
            }
            // 销毁声音
            if (m_soundEnt != null)
            {
                EntityManager.Inst.RemoveEntity(m_soundEnt.m_hid);
                m_soundEnt = null;
            }

            m_sceneInfo        = null;
            m_bModelLoaded     = false;
            m_bSceneDataLoaded = false;

            SceneManager.Inst.GetMapLoadProcess().fPercent = 0f;

            // 清除实体缓存
            EntityManager.Inst.ClearCache();
        }
Exemple #2
0
        public override void Update(float fTime, float fDTime)
        {
            Dictionary <int, SoundEntity> .Enumerator map = m_dicSoundEntity.GetEnumerator();
            while (map.MoveNext())
            {
                if (map.Current.Value.IsInited())
                {
                    m_tempListEffect.Add(map.Current.Value);
                }
            }

            for (int i = 0; i < m_tempListEffect.Count; i++)
            {
                SoundEntity item = m_tempListEffect[i];
                if (!item.IsLoop() && !item.IsPlaying())
                {
                    if (item.m_playEnd != null)
                    {
                        item.m_playEnd();
                        item.m_playEnd = null;
                    }
                    Remove(item.m_hid);
                }
            }
            m_tempListEffect.Clear();
        }
Exemple #3
0
        /// <summary>
        /// 根据handle设置静音
        /// </summary>
        public void SetStop(int uEntityID, bool stop)
        {
            SoundEntity entity = (SoundEntity)EntityManager.Inst.GetEnity(uEntityID);

            if (null != entity)
            {
                entity.Stop(stop);
            }
        }
Exemple #4
0
 public void StopMoveSound()
 {
     if (!m_bMaster)
     {
         return;
     }
     if (m_moveSoundEnt != null)
     {
         SoundEntity sEnt = m_moveSoundEnt as SoundEntity;
         sEnt.Stop(true);
     }
 }
Exemple #5
0
        public int CreateEntity(eEntityType eType, EntityBaseInfo baseInfo, Action <Entity> initEnd)
        {
            // 在这里可以让各种Entity继承EntityManager单独做个管理类
            // 然后通过管理类去new实体对象,暂时先用switch了
            // tips:这种静态的公共变量,如果在多个异步调用时,它的值会被最新值替换掉,在下面add时,就不能使用这个变量
            ++s_entityHandleId;
            // 如果缓存中有,就取缓存,如果没有就创建
            Entity entity = TryGetEntityFromCache(s_entityHandleId, initEnd, baseInfo);

            if (entity == null)
            {
                switch (eType)
                {
                case eEntityType.eNone:
                    entity = new Entity(s_entityHandleId, initEnd, eType, baseInfo);
                    break;

                case eEntityType.eSceneEntity:
                    entity = new SceneEntity(s_entityHandleId, initEnd, eType, baseInfo);
                    break;

                case eEntityType.eBoneEntity:
                    entity = new BoneEntity(s_entityHandleId, initEnd, eType, baseInfo);
                    break;

                case eEntityType.eEffectEntity:
                    entity = new EffectEntity(s_entityHandleId, initEnd, eType, baseInfo);
                    break;

                case eEntityType.eSoundEntity:
                    entity = new SoundEntity(s_entityHandleId, initEnd, eType, baseInfo);
                    break;

                case eEntityType.eBattleEntity:
                    entity = new BattleEntity(s_entityHandleId, initEnd, eType, baseInfo);
                    break;
                }
                if (null == entity)
                {
                    Debug.LogError("error eType:" + eType);
                    return(0);
                }
            }
            m_entityMap.Add(entity.m_hid, entity);
            return(entity.m_hid);
        }
Exemple #6
0
 /// <summary>
 /// 销毁
 /// </summary>
 public void Remove(int hid)
 {
     if (m_dicSoundEntity.ContainsKey(hid))
     {
         SoundEntity entity = (SoundEntity)EntityManager.Inst.GetEnity(hid);
         if (null != entity)
         {
             if (entity.m_entityInfo.m_soundType == (int)SoundType.eBG)
             {
                 // 延迟2秒结束
                 entity.m_bBgmRemove = true;
             }
             else
             {
                 RemoveLast(hid);
             }
         }
     }
 }
Exemple #7
0
        private void OnLoadBgm()
        {
            m_bSceneDataLoaded = true;
            if (m_sceneInfo.bgm == 0)
            {
                m_bBgmLoaded = true;
                OnLoadEnd();
                return;
            }
            int sHid = SoundManager.Inst.PlaySound(m_sceneInfo.bgm, (ent) =>
            {
                //SoundEntity sEnt = ent as SoundEntity;
                //sEnt.Stop(true);

                m_bBgmLoaded = true;
                OnLoadEnd();
            });

            m_soundEnt = EntityManager.Inst.GetEnity(sHid) as SoundEntity;
        }
Exemple #8
0
        public int Play(int resId, Vector3 pos, SoundCsvData data, Action <Entity> initEnd = null, Action playEnd = null)
        {
            if (resId == 0)
            {
                return(0);
            }
            EntityBaseInfo bInfo = new EntityBaseInfo();

            bInfo.m_resID     = resId;
            bInfo.m_soundMute = m_dicTypeMute[(int)data.type];
            bInfo.m_soundType = (int)data.type;
            bInfo.m_soundLoop = data.Loop;
            bInfo.m_vPos      = pos;
            bInfo.m_ilayer    = (int)LusuoLayer.eEL_Sound;
            int         handle = EntityManager.Inst.CreateEntity(eEntityType.eSoundEntity, bInfo, initEnd);
            SoundEntity entity = (SoundEntity)EntityManager.Inst.GetEnity(handle);

            m_dicSoundEntity.Add(entity.m_hid, entity);
            entity.m_playEnd = playEnd;
            return(handle);
        }