コード例 #1
0
    private void Execute(BBMacro macro, out BBLoopAction action)
    {
        action = BBLoopAction.Continue;
        switch (macro.macroType)
        {
        case BBMacroType.If:
            BBIfMacro ifmacro = macro as BBIfMacro;
            BBMacro   future  = null;
            if (ifmacro.Test(out future))
            {
                BBMacroPlayer inserted = new BBMacroPlayer(mConfig, mModuleProxy);
                inserted.Set(future);
                inserted.Play();
                mInterrupts.Add(inserted);
            }
            else
            {
                action = ifmacro.action;
            }
            break;

        case BBMacroType.Series:
            BBSeriesMacro srmacro = macro as BBSeriesMacro;
            foreach (BBMacro item in srmacro.items)
            {
                BBMacroPlayer inserted = new BBMacroPlayer(mConfig, mModuleProxy);
                inserted.Set(item);
                mSeriesQueue.Enqueue(inserted);
            }
            break;

        case BBMacroType.Parallel:
            BBParallelMacro prmacro = macro as BBParallelMacro;
            foreach (BBMacro item in prmacro.items)
            {
                BBMacroPlayer inserted = new BBMacroPlayer(mConfig, mModuleProxy);
                inserted.Set(item);
                inserted.Play();
                mInterrupts.Add(inserted);
            }
            break;

        default:
            mEmulator.Set(Expand(macro));
            break;
        }
    }
コード例 #2
0
 public void Update(float deltaTime)
 {
     if (mIsPlaying && !mIsPaused)
     {
         if (mInterrupts.Count > 0)
         {
             for (int i = mInterrupts.Count - 1; i >= 0; i--)
             {
                 if (!mInterrupts[i].isPlaying)
                 {
                     mInterrupts[i].Dispose();
                     mInterrupts.RemoveAt(i);
                 }
                 else
                 {
                     mInterrupts[i].Update(deltaTime);
                 }
             }
         }
         else if (mSeriesQueue.Count > 0)
         {
             BBMacroPlayer player = mSeriesQueue.Dequeue();
             player.Play();
             mInterrupts.Add(player);
         }
         else if (mCurrent == null)
         {
             mIsPlaying = false;
         }
         else
         {
             if (mCurrentTime > 0)
             {
                 mCurrentTime -= deltaTime;
             }
             else
             {
                 mCurrentDelay -= deltaTime;
             }
             if (mEmulator.isPlaying)
             {
                 mEmulator.Update(deltaTime);
             }
             else
             {
                 while ((mCurrentDelay < 0 || mCurrentTime < 0) &&
                        !mEmulator.isPlaying && mInterrupts.Count == 0)
                 {
                     if (mCurrentTime < 0)
                     {
                         if (mCurrentTimes < mCurrent.times)
                         {
                             mCurrentTimes += 1;
                         }
                         else
                         {
                             mCurrent = mCurrent.next;
                             if (mCurrent == null)
                             {
                                 break;
                             }
                         }
                         mCurrent.RunScript();
                         mCurrentDelay += mCurrent.delay;
                         mCurrentDelay += mCurrentTime;
                         mCurrentTime   = 0;
                     }
                     if (mCurrentDelay < 0)
                     {
                         BBLoopAction action = BBLoopAction.Continue;
                         Execute(mCurrent, out action);
                         if (action == BBLoopAction.Continue)
                         {
                             mCurrentTime += mCurrent.duration;
                             mCurrentTime += mCurrentDelay;
                         }
                         else if (action == BBLoopAction.Break)
                         {
                             mCurrentTimes = mCurrent.times;
                             mCurrentTime  = -float.Epsilon;
                         }
                         mCurrentDelay = 0;
                     }
                 }
             }
         }
     }
 }