public static int?PlayMusic(this SoundComponent soundComponent, int musicId, object userData = null) { soundComponent.StopMusic(); s_MusicSerialId = soundComponent.PlaySound(musicId, null, userData); return(s_MusicSerialId); }
public static int?PlayMusic(this SoundComponent soundComponent, int musicId, object userData = null) { soundComponent.StopMusic(); IDataTable <DRMusic> dtMusic = GameEntry.DataTable.GetDataTable <DRMusic>(); if (dtMusic == null) { Log.Warning("Music data is null", musicId.ToString()); return(null); } DRMusic drMusic = dtMusic.GetDataRow(musicId); if (drMusic == null) { Log.Warning("Can not load music '{0}' from data table.", musicId.ToString()); return(null); } PlaySoundParams playSoundParams = new PlaySoundParams { Priority = 64, Loop = true, VolumeInSoundGroup = 1f, FadeInSeconds = FadeVolumeDuration, SpatialBlend = 0f, }; s_MusicSerialId = soundComponent.PlaySound(AssetUtility.GetMusicAsset(drMusic.AssetName), "Music", playSoundParams, null, userData); return(s_MusicSerialId); }
public static int?PlaySound(this SoundComponent soundComponent, EnumSound enumSound, Entity bindingEntity = null, object userData = null) { if (enumSound == EnumSound.None) { return(null); } return(soundComponent.PlaySound((int)enumSound, bindingEntity, userData)); }
public static int?PlayMusic(this SoundComponent soundComponent, EnumSound enumSound, object userData = null) { if (enumSound == EnumSound.None) { return(null); } soundComponent.StopMusic(); s_MusicSerialId = soundComponent.PlaySound((int)enumSound, null, userData); return(s_MusicSerialId); }
public static int?PlaySound(this SoundComponent soundComponent, string assetName, StarForce.Entity bindingEntity = null, object userData = null) { //IDataTable<DRSound> dtSound = GameEntry.DataTable.GetDataTable<DRSound>(); //DRSound drSound = dtSound.GetDataRow(soundId); //if (drSound == null) { // Log.Warning("Can not load sound '{0}' from data table.", soundId.ToString()); // return null; //} PlaySoundParams playSoundParams = PlaySoundParams.Create(); playSoundParams.Priority = 0; playSoundParams.Loop = false; playSoundParams.VolumeInSoundGroup = 1; playSoundParams.SpatialBlend = 1; return(soundComponent.PlaySound(AssetUtility.GetSoundAsset(assetName), "Sound", Constant.AssetPriority.SoundAsset, playSoundParams, bindingEntity != null ? bindingEntity.Entity : null, userData)); }
/// <summary> /// 播放界面音效 /// </summary> /// <param name="soundComponent"></param> /// <param name="soundId"></param> /// <param name="userData"></param> public static void PlayUISound(this SoundComponent soundComponent, int soundId, object userData) { //TODO:通过id从音效配置中找到对应的资源,播放 string assetName = "TestUISound"; PlaySoundParams playSoundParams = new PlaySoundParams { //这些参数,可以填在音效配置中 Priority = 0, Loop = true, VolumeInSoundGroup = 1f, FadeInSeconds = FadeVolumeDuration, SpatialBlend = 0f, }; soundComponent.PlaySound(AssetUtility.GetUISoundAsset(assetName), "UISound", playSoundParams.Priority, playSoundParams, userData); }
public static int?PlayUISound(this SoundComponent soundComponent, string soundAssetName, object userData = null) { //IDataTable<DRUISound> dtUISound = GameEntry.DataTable.GetDataTable<DRUISound>(); //DRUISound drUISound = dtUISound.GetDataRow(uiSoundId); //if (drUISound == null) { // Log.Warning("Can not load UI sound '{0}' from data table.", uiSoundId.ToString()); // return null; //} PlaySoundParams playSoundParams = PlaySoundParams.Create(); playSoundParams.Priority = 0; playSoundParams.Loop = false; playSoundParams.VolumeInSoundGroup = 1; playSoundParams.SpatialBlend = 0f; return(soundComponent.PlaySound(AssetUtility.GetUISoundAsset(soundAssetName), "UISound", Constant.AssetPriority.UISoundAsset, playSoundParams, userData)); }
public static int?PlaySound(this SoundComponent soundComponent, int soundId, Entity bindingEntity = null, object userData = null) { IDataTable <DRSound> dtSound = GameEntry.DataTable.GetDataTable <DRSound>(); DRSound drSound = dtSound.GetDataRow(soundId); if (drSound == null) { Log.Warning("Can not load sound '{0}' from data table.", soundId.ToString()); return(null); } PlaySoundParams playSoundParams = PlaySoundParams.Create(); playSoundParams.Priority = drSound.Priority; playSoundParams.Loop = drSound.Loop; playSoundParams.VolumeInSoundGroup = drSound.Volume; playSoundParams.SpatialBlend = drSound.SpatialBlend; return(soundComponent.PlaySound(AssetUtility.GetSoundAsset(drSound.AssetName), "Sound", Constant.AssetPriority.SoundAsset, playSoundParams, bindingEntity != null ? bindingEntity.Entity : null, userData)); }
public static int?PlaySound(this SoundComponent soundComponent, int soundId, Entity bindingEntity = null, object userData = null) { SoundData soundData = GameEntry.Data.GetData <DataSound>().GetSoundDataBySoundId(soundId); PlaySoundParams playSoundParams = PlaySoundParams.Create(); playSoundParams.Time = soundData.SoundPlayParam.Time; playSoundParams.MuteInSoundGroup = soundData.SoundPlayParam.Mute; playSoundParams.Loop = soundData.SoundPlayParam.Loop; playSoundParams.Priority = soundData.SoundPlayParam.Priority; playSoundParams.VolumeInSoundGroup = soundData.SoundPlayParam.Volume; playSoundParams.FadeInSeconds = soundData.SoundPlayParam.FadeInSeconds; playSoundParams.Pitch = soundData.SoundPlayParam.Pitch; playSoundParams.PanStereo = soundData.SoundPlayParam.PanStereo; playSoundParams.SpatialBlend = soundData.SoundPlayParam.SpatialBlend; playSoundParams.MaxDistance = soundData.SoundPlayParam.MaxDistance; playSoundParams.DopplerLevel = soundData.SoundPlayParam.DopplerLevel; return(soundComponent.PlaySound(soundData.AssetPath, soundData.SoundGroupData.Name, Constant.AssetPriority.MusicAsset, playSoundParams, bindingEntity, userData)); }
public static int?PlayUISound(this SoundComponent soundComponent, int uiSoundId, object userData = null) { var dtUISound = GameEntry.DataTable.GetDataTable <DRUISound>(); var drUISound = dtUISound.GetDataRow(uiSoundId); if (drUISound == null) { Log.Warning("Can not load UI sound '{0}' from data table.", uiSoundId.ToString()); return(null); } PlaySoundParams playSoundParams = new PlaySoundParams(); playSoundParams.Priority = drUISound.Priority; playSoundParams.Loop = false; playSoundParams.VolumeInSoundGroup = drUISound.Volume; playSoundParams.SpatialBlend = 0f; return(soundComponent.PlaySound(AssetUtility.GetUISoundAsset(drUISound.AssetName), "UISound", Constant.AssetPriority.UISoundAsset, playSoundParams, userData)); }
public int PlayUISound(int uiSoundId, object userData = null) { DataTableComponent dataTableComponent = UnityGameFramework.Runtime.GameEntry.GetComponent <DataTableComponent>(); IDataTable <DRUISound> dtUISound = dataTableComponent.GetDataTable <DRUISound>(); DRUISound drUISound = dtUISound.GetDataRow(uiSoundId); if (drUISound == null) { Log.Warning("Can not load UI sound '{0}' from data table.", uiSoundId.ToString()); return(-1); } PlaySoundParams playSoundParams = PlaySoundParams.Create(); playSoundParams.Priority = drUISound.Priority; playSoundParams.Loop = false; playSoundParams.VolumeInSoundGroup = drUISound.Volume; playSoundParams.SpatialBlend = 0f; return(soundComponent.PlaySound(AssetUtility.GetUISoundAsset(drUISound.AssetName), "UISound", Demo15.Constant.AssetPriority.UISoundAsset, playSoundParams, userData)); }
public static int PlayMusic(this SoundComponent soundComponent, int musicId, object userData = null) { IDataTable <DRMusic> dtMusic = GameEntry.DataTable.GetDataTable <DRMusic>(); DRMusic drMusic = dtMusic.GetDataRow(musicId); if (drMusic == null) { Log.Warning("Can not load music '{0}' from data table.", musicId.ToString()); return(-1); } PlaySoundParams playSoundParams = new PlaySoundParams { Priority = 64, Loop = true, VolumeInSoundGroup = 1f, SpatialBlend = 0f, }; return(soundComponent.PlaySound(AssetUtility.GetMusicAsset(drMusic.AssetName), "Music", playSoundParams, null, userData)); }
public static int PlayUISound(this SoundComponent soundComponent, int uiSoundId, object userData = null) { IDataTable <DRUISound> dtUISound = GameEntry.DataTable.GetDataTable <DRUISound>(); DRUISound drUISound = dtUISound.GetDataRow(uiSoundId); if (drUISound == null) { Log.Warning("Can not load UI sound '{0}' from data table.", uiSoundId.ToString()); return(-1); } PlaySoundParams playSoundParams = new PlaySoundParams { Priority = drUISound.Priority, Loop = false, VolumeInSoundGroup = drUISound.Volume, SpatialBlend = 0f, }; return(soundComponent.PlaySound(AssetUtility.GetUISoundAsset(drUISound.AssetName), "UISound", playSoundParams, userData)); }
public static int?PlayMusic(this SoundComponent soundComponent, string assetName, object userData = null) { soundComponent.StopMusic(); //IDataTable<DRMusic> dtMusic = GameEntry.DataTable.GetDataTable<DRMusic>(); //DRMusic drMusic = dtMusic.GetDataRow(musicId); //if (drMusic == null) //{ // Log.Warning("Can not load music '{0}' from data table.", musicId.ToString()); // return null; //} PlaySoundParams playSoundParams = PlaySoundParams.Create(); playSoundParams.Priority = 64; playSoundParams.Loop = true; playSoundParams.VolumeInSoundGroup = 1f; playSoundParams.FadeInSeconds = FadeVolumeDuration; playSoundParams.SpatialBlend = 0f; s_MusicSerialId = soundComponent.PlaySound(AssetUtility.GetMusicAsset(assetName), "Music", Constant.AssetPriority.MusicAsset, playSoundParams, null, userData); return(s_MusicSerialId); }
/// <summary> /// 返回音频长度 /// </summary> /// <param name="soundComponent"></param> /// <param name="soundId"></param> /// <returns>返回音频长度</returns> public static int?PlaySoundAndLength(this SoundComponent soundComponent, int soundId, ref int length) { IDataTable <DRSound> dtSound = GameEntry.DataTable.GetDataTable <DRSound>(); DRSound drSound = dtSound.GetDataRow(soundId); if (drSound == null) { Log.Warning("Can not load sound '{0}' from data table.", soundId.ToString()); return(0); } PlaySoundParams playSoundParams = new PlaySoundParams { Priority = drSound.Priority, Loop = drSound.Loop, VolumeInSoundGroup = drSound.Volume, SpatialBlend = drSound.SpatialBlend, }; length = drSound.Length; return(soundComponent.PlaySound(AssetUtility.GetSoundAsset(drSound.AssetName), "Sound", Constant.AssetPriority.SoundAsset, playSoundParams, null, null)); }
private void Form1_MouseClick(object sender, MouseEventArgs e) { MClick.PlaySound(); }
private void Form1_Load(object sender, EventArgs e) { this.Text = "Test_Game.exe"; Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; Console.Clear(); Console.WriteLine("Debug Console Initialized"); localEngine = new Game(this); localEngine.GameResolutionWidth = 1280; localEngine.GameResolutionHeight = 720; //localEngine.Gravity = 1; GameObject BackgroundObj = new GameObject("BackgroundObj", localEngine); SpriteComponent bgspriteComponent = new SpriteComponent(localEngine, BackgroundObj, 0, 0, 1920, 1080, Image.FromFile("city.jpg")); BackgroundObj.AddComponent(bgspriteComponent); BackgroundObj.isUI = true; localEngine.CreateObject(BackgroundObj); Player Player = new Player("Player", localEngine); GameObject Ground = new GameObject("Ground", localEngine); BoxComponent b = new BoxComponent(localEngine, Ground, Color.Brown, new Rectangle(0, 0, localEngine.GameResolutionWidth, 50)); Ground.AddComponent(b); Ground.SetX(0); Ground.SetY(localEngine.GameResolutionHeight - 100); Ground.GravityScale = 0; Console.WriteLine(Ground.GetY()); localEngine.CreateObject(Ground); //Player.CanTick = false; Player.GravityScale = 1; GameObject GameRenderTextObj = new GameObject("GameRenderTextObj", localEngine); GameObject WindowSizeTextObj = new GameObject("WindowSizeTextObj", localEngine); localEngine.AddFPSCounter(); TextComponent tc = new TextComponent(localEngine, GameRenderTextObj, 1, 20, Color.White, "Resolution Width", new FontFamily("Arial"), 12); GameRenderTextObj.AddComponent(tc); TextComponent tc2 = new TextComponent(localEngine, WindowSizeTextObj, 1, 50, Color.White, "Resolution Width", new FontFamily("Arial"), 12); WindowSizeTextObj.AddComponent(tc2); GameRenderTextObj.isUI = true; WindowSizeTextObj.isUI = true; localEngine.CreateUIObject(GameRenderTextObj); localEngine.CreateUIObject(WindowSizeTextObj); localEngine.PrintText(debugType.Debug, "'localEngine' Defined!"); localEngine.PrintText(debugType.Debug, "'player' Defined!"); //localEngine.SetBackgroundColour(255/2, 255/5, 255/2); //localEngine.printText(EngineClass.debugType.Debug, "player.Index = " + player.index); localEngine.GraphicsSettings.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; localEngine.GraphicsSettings.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; // engine reference obj ref //BoxComponent c = new BoxComponent(localEngine, Player, 20 , 0, Color.Blue, 50, 50); //Player.AddComponent(c); //BoxComponent b = new BoxComponent(localEngine, Player, 0, 0, Color.Blue, 20, 20); //Player.AddComponent(b); Player.SetX(localEngine.GameResolutionWidth / 2 - Player.GetWidth() / 2); Player.SetY(localEngine.GameResolutionHeight / 2 - Player.GetHeight() / 2); SpriteComponent spr = new SpriteComponent(localEngine, Player, 0, 0, 50, 50, Image.FromFile("Mario.png")); //spr.resizeImage(50, 50); //spr.MakeTransparent(); Player.AddComponent(spr); localEngine.CreateObject(Player); localEngine.PrintText(debugType.Debug, "Starting Engine"); localEngine.startGame(); GMusic.PlaySound(); localEngine.FPS = 60; // set fps of the game }
/// <summary> /// 播放声音。 /// </summary> /// <param name="soundAssetName">声音资源名称。</param> /// <param name="soundGroupName">声音组名称。</param> /// <param name="priority">加载声音资源的优先级。</param> /// <param name="playSoundParams">播放声音参数。</param> /// <param name="worldPosition">声音所在的世界坐标。</param> /// <param name="userData">用户自定义数据。</param> /// <returns>声音的序列编号。</returns> public CFTask <int> PlaySound(string soundAssetName, string soundGroupName, int priority, PlaySoundParams playSoundParams, Vector3 worldPosition, object userData) { return(m_SoundMethods.PlaySound(soundAssetName, soundGroupName, priority, playSoundParams, PlaySoundEntityInfo.Create(null, worldPosition, userData))); }