コード例 #1
0
 public Storyboard()
 {
     Root    = new StoryboardBlock(null);
     current = Root;
     stack   = new Stack <StoryboardBlock>();
     Context = new StoryContext();
 }
コード例 #2
0
 private StoryboardParser(XmlReader reader, Dictionary <string, Trophy>?trophies)
 {
     this.reader   = reader;
     this.trophies = trophies;
     storyboard    = new Storyboard();
     blocks        = new Stack <StoryboardBlock>();
     currentBlock  = storyboard.Root;
 }
コード例 #3
0
    private async Task <bool> MoveAsync(bool forward)
    {
        var block = current;

        if (block.Current is not null)
        {
            await block.Current.LeaveAsync(Context);
        }

        for (; ;)
        {
            var item = forward ? await block.MoveNextAsync(Context) : await block.MovePreviousAsync(Context);

            if (item == null)
            {
                if (!stack.TryPop(out block))
                {
                    await HandleContextChangingItemsAsync(forward);

                    Context.CurrentItem = null;
                    return(false);
                }

                if (block.Current != null)
                {
                    await block.Current.LeaveAsync(Context);

                    block.Current = null;
                }

                current = block;
            }
            else
            {
                if (item.ChangesContext)
                {
                    StoreContextChangingItem(item);
                }

                if (item.Block == null)
                {
                    if (item.IsPause)
                    {
                        Context.CurrentItem = item;
                        return(true);
                    }

                    await item.LeaveAsync(Context);
                }
                else
                {
                    stack.Push(block);
                    current = item.Block;
                    block   = item.Block;
                }
            }
        }
    }
コード例 #4
0
 private void OpenBlock(IStoryboardItem item)
 {
     blocks.Push(currentBlock);
     if (item.Block == null)
     {
         throw new InvalidOperationException();
     }
     Add(item);
     currentBlock = item.Block;
 }
コード例 #5
0
        private static T Get <T>(StoryboardBlock block, bool single) where T : IStoryboardItem
        {
            var item = block.ForwardQueue.Dequeue();

            item.Should().BeOfType <T>();

            if (single && block.ForwardQueue.Count > 0)
            {
                var type = block.ForwardQueue.Peek().GetType();
                throw new Exception($"Era esperado que '{typeof(T).Name}' fosse o último elemento do bloco, mas existe um elemento '{type.Name}' depois dele.");
            }

            return((T)item);
        }
コード例 #6
0
 private void CloseBlock() => currentBlock = blocks.Pop();
コード例 #7
0
 public InterlocutorMoodItem(string name, ICondition?condition)
 {
     Name      = name;
     Condition = condition;
     Block     = new StoryboardBlock(this);
 }
コード例 #8
0
 public ConditionItem(ICondition?condition)
 {
     Condition = condition;
     Block     = new StoryboardBlock(this);
 }
コード例 #9
0
 public InterlocutorSpeechItem(ICondition?condition)
 {
     Condition = condition;
     Block     = new StoryboardBlock(this);
 }
コード例 #10
0
 public ProtagonistItem(ICondition?condition)
 {
     Condition = condition;
     Block     = new StoryboardBlock(this);
 }
コード例 #11
0
 public PromptItem(Prompt prompt, ICondition?condition)
 {
     Prompt    = prompt;
     Condition = condition;
     Block     = new StoryboardBlock(this);
 }
コード例 #12
0
 public ProtagonistMoodItem(string name, ICondition?condition)
 {
     Name      = name;
     Condition = condition;
     Block     = new StoryboardBlock(this);
 }