/// <summary> /// 在指定播放源上播放声音 /// </summary> /// <param name="data"></param> public void PlaySoundListener(EventData data) { if (data == null) { Debug.LogError("PlaySound error null EventData."); } SoundParam param = data.Param as SoundParam; if (param == null) { Debug.LogError("EventData convert SoundParam error"); } string soundType = param.type; AudioSource source = param.source; bool isBreak = param.isBreak; bool isLoop = param.isLoop; bool isCustomVolume = param.isCustomVolume; float customVolumeScale = param.customVolumeScale; if (source == null) { Debug.LogError("No audioSource get"); } MusicManager.Instance.Play(source, soundType, isBreak, isLoop, isCustomVolume, customVolumeScale); }
/// <summary> /// 攻击动作声音播放 /// </summary> protected void AttackSound(string param) { string[] ps = param.Split('|'); string type = ps[0]; float volumeScale = float.Parse(ps[1]); SoundParam p = new SoundParam(this.AudioSource, type, false, false, true, volumeScale); EventCenter.Instance.SendEvent(SGEventType.SoundPlay, new EventData(p, null)); }
// 测试音效 protected void testAudio() { SoundParam param = Ctx.m_instance.m_poolSys.newObject <SoundParam>(); //param.m_path = "TestSound.prefab"; param.m_path = Path.Combine(Ctx.m_instance.m_cfg.m_pathLst[(int)ResPathType.ePathAudio], "ZuiZhenDeMeng.mp3"); Ctx.m_instance.m_soundMgr.play(param); Ctx.m_instance.m_poolSys.deleteObj(param); }
public void EnumerateUsedAssets(Action <UUID> action) { using (var conn = new NpgsqlConnection(m_ConnectionString)) { conn.Open(); using (var cmd = new NpgsqlCommand("SELECT DISTINCT \"AssetId\" FROM primitems", conn)) { using (NpgsqlDataReader dbReader = cmd.ExecuteReader()) { while (dbReader.Read()) { action(dbReader.GetUUID("AssetId")); } } } using (var cmd = new NpgsqlCommand("SELECT \"EnvironmentSettings\" FROM environmentsettings", conn)) { using (NpgsqlDataReader dbReader = cmd.ExecuteReader()) { while (dbReader.Read()) { WindLightSettings settings; using (MemoryStream ms = new MemoryStream(dbReader.GetBytes("EnvironmentSettings"))) { settings = WindLightSettings.Deserialize(ms); } if (settings.WaterSettings.NormalMap != UUID.Zero) { action(settings.WaterSettings.NormalMap); } } } } using (var cmd = new NpgsqlCommand("SELECT DISTINCT \"NormalMapTexture\" FROM lightshare", conn)) { using (NpgsqlDataReader dbReader = cmd.ExecuteReader()) { while (dbReader.Read()) { UUID id = dbReader.GetUUID("NormalMapTexture"); if (id != UUID.Zero) { action(id); } } } } using (var cmd = new NpgsqlCommand("SELECT DISTINCT \"TerrainTexture1\", \"TerrainTexture2\", \"TerrainTexture3\", \"TerrainTexture4\" FROM regionsettings", conn)) { using (NpgsqlDataReader dbReader = cmd.ExecuteReader()) { while (dbReader.Read()) { UUID id; id = dbReader.GetUUID("TerrainTexture1"); if (id != UUID.Zero) { action(id); } id = dbReader.GetUUID("TerrainTexture2"); if (id != UUID.Zero) { action(id); } id = dbReader.GetUUID("TerrainTexture3"); if (id != UUID.Zero) { action(id); } id = dbReader.GetUUID("TerrainTexture4"); if (id != UUID.Zero) { action(id); } } } } using (var cmd = new NpgsqlCommand("SELECT \"PrimitiveShapeData\", \"ParticleSystem\", \"TextureEntryBytes\", \"ProjectionData\", \"LoopedSoundData\", \"ImpactSoundData\" FROM prims", conn)) { using (NpgsqlDataReader dbReader = cmd.ExecuteReader()) { while (dbReader.Read()) { var shape = new ObjectPart.PrimitiveShape { Serialization = dbReader.GetBytes("PrimitiveShapeData") }; var particleSystem = new ParticleSystem(dbReader.GetBytes("ParticleSystem"), 0); var te = new TextureEntry(dbReader.GetBytes("TextureEntryBytes")); var proj = new ProjectionParam { DbSerialization = dbReader.GetBytes("ProjectionData") }; var sound = new SoundParam { Serialization = dbReader.GetBytes("LoopedSoundData") }; var colsound = new CollisionSoundParam { Serialization = dbReader.GetBytes("ImpactSoundData") }; if (shape.SculptMap != UUID.Zero) { action(shape.SculptMap); } foreach (UUID refid in particleSystem.References) { if (refid != UUID.Zero) { action(refid); } } foreach (UUID refid in te.References) { if (refid != UUID.Zero) { action(refid); } } if (proj.ProjectionTextureID != UUID.Zero) { action(proj.ProjectionTextureID); } if (sound.SoundID != UUID.Zero) { action(sound.SoundID); } if (colsound.ImpactSound != UUID.Zero) { action(colsound.ImpactSound); } } } } } }