Example #1
0
 /// <summary>
 /// Plays a sound when a certain condition is set from false to true.
 /// </summary>
 /// <param name="sfxobj">The sound object to play.</param>
 /// <param name="condition">The condition that should trigger the sound effect when set from false to true.</param>
 /// <param name="volume">The volume at which the sound is played.</param>
 public void PlayOnSetTrue(SoundObject sfxobj, bool condition, float volume = 1f)
 {
     if (condition)
     {
         Play(sfxobj, volume);
         sfxobj.Playable = false;
     }
     else
         sfxobj.Playable = true;
 }
Example #2
0
 public void Play(SoundObject sfxobj, float volume = 1f)
 {
     if (sfxobj.Playable && sfxobj.SFX != null)
     {
         SoundEffectInstance sfxi = sfxobj.SFX.CreateInstance();
         sfxQueue.AddLast(sfxi);
         sfxi.Volume = MathHelper.Min(Math.Abs(volume), 1);
         sfxi.Play();
     }
 }
Example #3
0
 public virtual void Initialize(List<Option> options, AssetManager assets, string themeName)
 {
     TextDictionary assetDictionary = new TextDictionary(assets.GetText("cursor"));
     this.options = options;
     try { cycleDelay = assetDictionary.LookupInt32(themeName, "cycleDelay"); }
     catch { cycleDelay = 1; }
     try { cycleInterval = assetDictionary.LookupInt32(themeName, "cycleInterval"); }
     catch { cycleInterval = 1; }
     spacing = assetDictionary.LookupSingle(themeName, "spacing");
     if (assetDictionary.CheckPropertyExists(themeName, "cycleSound"))
         cycleSound = new SoundObject(assets.GetSFX(assetDictionary.LookupString(themeName, "cycleSound")));
     if (assetDictionary.CheckPropertyExists(themeName, "selectSound"))
         selectSound = new SoundObject(assets.GetSFX(assetDictionary.LookupString(themeName, "selectSound")));
     selected = false;
 }
Example #4
0
        public SingularSelector(AssetManager assets, string themeName, Vector2 position, Anchor anchor, Option option)
            : base(themeName, position, 0)
        {
            TextDictionary assetDictionary = new TextDictionary(assets.GetText("selector"));
            string optionTheme = assetDictionary.LookupString(themeName, "optionTheme");
            blinkRate = assetDictionary.LookupInt32(themeName, "blinkRate");
            if (assetDictionary.CheckPropertyExists(themeName, "sound"))
                sound = new SoundObject(assets.GetSFX(assetDictionary.LookupString(themeName, "sound")));
            option.Initialize(assets, optionTheme);

            //this.position *= GraphicsConstants.VIEWPORT_DIMENSIONS / GraphicsConstants.DEFAULT_DIMENSIONS;
            this.Position -= GraphicsHelper.ComputeAnchorOrigin(anchor, option.Dimensions / GraphicsConstants.VIEWPORT_DIMENSIONS);
            this.option = option;
            IntValue = 0;
            timer = 0;
            selected = false;
        }
Example #5
0
 /*public static SoundCollection Build(AudioPlayer audio, string moduleName)
 {
     SoundCollection s = new SoundCollection();
     string[] properties = audio.AssetDictionary.GetProperties(moduleName);
     foreach (string prop in properties)
         s.sounds.Add(new SoundObject(audio.Assets.GetSFX(audio.AssetDictionary.LookupString(moduleName, prop))));
     return s;
 }*/
 /// <summary>
 /// Adds a sound to this collection.
 /// </summary>
 /// <param name="sfxobj">The sound object to add.</param>
 public void Add(SoundObject sfxobj)
 {
     sounds.Add(sfxobj);
 }
Example #6
0
 /// <summary>
 /// Plays a sound repeatedly when a certain condition is true.
 /// </summary>
 /// <param name="sfxobj">The sound object to play.</param>
 /// <param name="condition">The condition that should trigger the sound effect when true.</param>
 /// <param name="ticksPerPlay">The frequency at which the sound is played.</param>
 /// <param name="volume">The volume at which the sound is played.</param>
 public void RepeatOnTrue(SoundObject sfxobj, bool condition, int ticksPerPlay, float volume = 1f)
 {
     if (ticksPerPlay == 0) return;
     if (condition && framesElapsed % ticksPerPlay == 0)
     {
         Play(sfxobj, volume);
     }
 }