示例#1
0
        //* -----------------------------------------------------------------------*
        /// <summary>1フレーム分の更新処理を実行します。</summary>
        ///
        /// <param name="entity">この状態を適用されているオブジェクト。</param>
        /// <param name="privateMembers">
        /// オブジェクトと状態クラスのみがアクセス可能なフィールド。
        /// </param>
        /// <param name="gameTime">前フレームが開始してからの経過時間。</param>
        public override void update(
            CAudio entity, CAudio.CPrivateMembers privateMembers, GameTime gameTime)
        {
            List <Cue>    cueList      = privateMembers.cueList;
            List <string> reservedList = privateMembers.reservedList;

            for (int i = cueList.Count; --i >= 0;)
            {
                Cue cue = cueList[i];
                if (cue.IsStopped)
                {
                    // Cueクラスは使いまわすことができない
                    cue.Dispose();
                    cueList.RemoveAt(i);
                }
            }
            for (int i = reservedList.Count; --i >= 0;)
            {
                string name = reservedList[i];
                Cue    cue  = entity.find(name);
                if (cue == null || cue.GetVariable("AttackTime") >= entity.loopInterval)
                {
                    Cue newCue = entity.soundBank.GetCue(name);
                    newCue.Play();
                    cueList.Add(newCue);
                    reservedList.RemoveAt(i);
                }
            }
            privateMembers.engineUpdate();
        }
示例#2
0
        private static bool Cue_Play_Prefix(Cue __instance, string ____name, ref bool ___played)
        {
            string cueName = ____name;

            try
            {
                SoundEffect effect = GetSoundEffect(cueName);
                if (effect == null)
                {
                    if (Config.VerboseLog)
                    {
                        PMonitor.Log($"No audio entry for {cueName}", LogLevel.Debug);
                    }
                    return(true);
                }

                float oPitch = -1;
                float pitch  = 0f;
                float volume = 1f;
                if (CuePitches.ContainsKey(cueName))
                {
                    oPitch = CuePitches[cueName];
                    pitch  = (float)(oPitch - 1200) / 1200f;
                    ;
                }
                try
                {
                    volume = (__instance.GetVariable("Volume")) / 100f;
                }
                catch
                {
                }

                effect.Play(volume == 0 ? 1f : volume, pitch, 0);
                if (Config.VerboseLog)
                {
                    PMonitor.Log($"played cue audio file {cueName} at volume {volume}, pitch {oPitch}", LogLevel.Debug);
                }
                ___played = true;
                return(false);
            }
            catch (Exception ex)
            {
                PMonitor.Log($"couldn't play cue audio file {cueName} {ex}", LogLevel.Warn);
            }
            return(true);
        }
示例#3
0
        public float this[String variable]
        {
            get { return(mCue.GetVariable(variable)); }
            set
            {
                mCue.SetVariable(variable, value);

                if (mVariableValues.ContainsKey(variable))
                {
                    mVariableValues[variable] = value;
                }
                else
                {
                    mVariableValues.Add(variable, value);
                }
            }
        }
示例#4
0
 public float GetVariable(string var)
 {
     return(cue.GetVariable(var));
 }
示例#5
0
 public float GetVariable(string name)
 {
     return(_cue.GetVariable(name));
 }
示例#6
0
 /// <summary>
 /// Gets the variable created in XACT.
 /// </summary>
 public void GetVariable(string variable)
 {
     _Cue.GetVariable(variable);
 }