示例#1
0
    public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
    {
        var myContext = new TextParentParsingContext();
        await elementParser.ParseAsync(reader, parsingContext, myContext, Settings);

        if (myContext.ParsedText is null)
        {
            return;
        }

        var value = int.Parse(myContext.ParsedText);

        if (value < 1)
        {
            return;
        }

        if (value > 30000)
        {
            parsingContext.LogError(reader, "O limite de tempo não pode ser maior que 30 segundos.");
            return;
        }

        var ctx = (ChoiceParentParsingContext)parentParsingContext;

        ctx.Choice.TimeLimit = TimeSpan.FromMilliseconds(value);
    }
示例#2
0
    public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
    {
        var myContext = new BalloonChildParsingContext();
        await elementParser.ParseAsync(reader, parsingContext, myContext, Settings);

        if (myContext.ParsedText is null)
        {
            return;
        }

        var textSourceParsingResult = textSourceParser.Parse(myContext.ParsedText);

        if (textSourceParsingResult.IsError)
        {
            parsingContext.LogError(reader, textSourceParsingResult.ErrorMessage);
            return;
        }
        var textSource = textSourceParsingResult.TextSource;

        if (reader.ReadState != ReadState.EndOfFile)
        {
            await elementParser.ParseAsync(reader, parsingContext, myContext, AggregationSettings);
        }

        var node = new BalloonTextNode(textSource, BalloonType, myContext.ChoiceNode);

        parentParsingContext.AddNode(node);

        parsingContext.SceneContext.Reset();
    }
示例#3
0
    public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
    {
        var context = new BackgroundContext();
        await elementParser.ParseAsync(reader, parsingContext, context, Settings);

        if (!string.IsNullOrWhiteSpace(context.ParsedText))
        {
            var state = new BackgroundState(context.ParsedText, BackgroundType.Image, BackgroundPosition.Left);
            var block = parsingContext.BlockFactory.Create(
                new BackgroundNode(state, null),
                new ScrollNode(null)
                );
            parentParsingContext.AddNode(new BlockNode(block, context.When));
            parsingContext.RegisterDismissNode(DismissNode);
            return;
        }

        if (context.Nodes.Count == 0)
        {
            parsingContext.LogError(reader, "Nome de imagem ou elemento filho era esperado.");
            return;
        }

        {
            var block = parsingContext.BlockFactory.Create(context.Nodes);
            parentParsingContext.AddNode(new BlockNode(block, context.When));
            parsingContext.RegisterDismissNode(DismissNode);
        }
    }
示例#4
0
    public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
    {
        var myContext = new TextParentParsingContext();
        await elementParser.ParseAsync(reader, parsingContext, myContext, Settings);

        var parsedText = myContext.ParsedText;

        parsingContext.SceneContext.Reset();

        if (string.IsNullOrWhiteSpace(parsedText))
        {
            var node = new PauseNode(myContext.When);
            parentParsingContext.AddNode(node);
            return;
        }

        var value = int.Parse(parsedText);

        if (value <= 0)
        {
            parsingContext.LogError(reader, "O tempo de espera precisa ser maior que zero.");
            return;
        }

        if (value > 5000)
        {
            parsingContext.LogError(reader, "O tempo de espera não pode ser maior que 5000.");
            return;
        }

        var timedPauseNode = new TimedPauseNode(TimeSpan.FromMilliseconds(value), myContext.When);

        parentParsingContext.AddNode(timedPauseNode);
    }
示例#5
0
    public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
    {
        var myContext = new TextParentParsingContext();
        await elementParser.ParseAsync(reader, parsingContext, myContext, Settings);

        var ctx = (ChoiceParentParsingContext)parentParsingContext;

        ctx.Choice.RandomOrder = true;
    }
示例#6
0
    public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
    {
        var myContext = new TextParentParsingContext();
        await elementParser.ParseAsync(reader, parsingContext, myContext, Settings);

        var node = new ScrollNode(myContext.When);

        parentParsingContext.AddNode(node);
    }
示例#7
0
    public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
    {
        var myContext = new TextParentParsingContext();
        await elementParser.ParseAsync(reader, parsingContext, myContext, Settings);

        var ctx = (ChoiceOptionParentParsingContext)parentParsingContext;

        ctx.Option.DisabledText = myContext.ParsedText;
    }
示例#8
0
 public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
 {
     while (await reader.ReadAsync())
     {
     }
     if (ret is not null)
     {
         parentParsingContext.AddNode(ret);
     }
 }
示例#9
0
    public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
    {
        var myContext = new TextParentParsingContext();
        await elementParser.ParseAsync(reader, parsingContext, myContext, Settings);

        if (myContext.ParsedText is null)
        {
            return;
        }

        var ctx = (ChoiceParentParsingContext)parentParsingContext;

        ctx.Choice.Default = myContext.ParsedText;
    }
示例#10
0
    public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
    {
        var myContext = new ChoiceParentParsingContext();
        await elementParser.ParseAsync(reader, parsingContext, myContext, Settings);

        if (myContext.Choice.Options.Count == 0)
        {
            parsingContext.LogError(reader, "Nenhuma opção informada.");
            return;
        }

        var ctx = (BalloonChildParsingContext)parentParsingContext;

        ctx.ChoiceNode = myContext.Choice;
    }
示例#11
0
    public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
    {
        var myContext = new BlockParentParsingContext();
        await elementParser.ParseAsync(reader, parsingContext, myContext, Settings);

        if (myContext.Nodes.Count == 0)
        {
            parsingContext.LogError(reader, "Elemento filho era esperado.");
            return;
        }

        var block = parsingContext.BlockFactory.Create(myContext.Nodes, myContext.While);
        var node  = new BlockNode(block, myContext.When);

        parentParsingContext.AddNode(node);
    }
示例#12
0
    public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
    {
        var myContext = new TextParentParsingContext();
        await elementParser.ParseAsync(reader, parsingContext, myContext, Settings);

        var parsedText = myContext.ParsedText;

        if (parsedText is null)
        {
            return;
        }

        var varSet = new VarSet(parsedText, null);

        parentParsingContext.AddNode(new VarSetNode(varSet));
    }
示例#13
0
    public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
    {
        var myContext = new TextParentParsingContext();
        await elementParser.ParseAsync(reader, parsingContext, myContext, Settings);

        var parsedText = myContext.ParsedText;

        if (parsedText is null)
        {
            return;
        }

        var node = new ProtagonistNode(parsedText.Length == 0 ? null : parsedText, myContext.When);

        parentParsingContext.AddNode(node);
        parsingContext.RegisterDismissNode(DismissNode);
    }
示例#14
0
    public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
    {
        var myContext = new ChoiceOptionParentParsingContext();

        myContext.Option.Key = reader.LocalName;

        await elementParser.ParseAsync(reader, parsingContext, myContext, Settings);

        if (string.IsNullOrWhiteSpace(myContext.Option.Text))
        {
            parsingContext.LogError(reader, "O texto da opção não foi informado.");
            return;
        }

        var ctx = (ChoiceParentParsingContext)parentParsingContext;

        ctx.Choice.Options.Add(myContext.Option);
    }
示例#15
0
    public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
    {
        var myContext = new BlockParentParsingContext();
        await elementParser.ParseAsync(reader, parsingContext, myContext, Settings);

        var parsedText = myContext.ParsedText;

        if (parsedText is null)
        {
            return;
        }

        if (parsedText.Length == 0)
        {
            parsingContext.LogError(reader, "Era esperado o nome do personagem.");
            return;
        }

        if (reader.ReadState == ReadState.EndOfFile)
        {
            return;
        }

        await elementParser.ParseAsync(reader, parsingContext, myContext, AggregationSettings);

        if (myContext.Nodes.Count == 0)
        {
            return;
        }

        if (parsingContext.SceneContext.HasMood)
        {
            parsingContext.LogError(reader, "Foi definido humor mas não foi definida uma fala ou pensamento correspondente.");
            return;
        }

        myContext.Nodes.Insert(0, InitializeMoodNode);
        myContext.Nodes.Add(DismissMoodNode);

        var block = parsingContext.BlockFactory.Create(myContext.Nodes);
        var node  = new PersonNode(parsedText, block);

        parentParsingContext.AddNode(node);
    }
示例#16
0
    public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
    {
        var myContext = new BlockParentParsingContext();
        await elementParser.ParseAsync(reader, parsingContext, myContext, Settings);

        if (reader.ReadState != ReadState.EndOfFile)
        {
            await elementParser.ParseAsync(reader, parsingContext, myContext, AggregationSettings);
        }

        var nonPauseNodes = new Stack <INode>();

        for (var n = myContext.Nodes.Count - 1; n >= 0; n--)
        {
            var currentNode = myContext.Nodes[n];
            if (currentNode is IPauseNode)
            {
                break;
            }
            nonPauseNodes.Push(currentNode);
            myContext.Nodes.RemoveAt(n);
        }

        if (myContext.Nodes.Count == 0)
        {
            parsingContext.LogError(reader, "Era esperado um elemento filho.");
            return;
        }

        var block = parsingContext.BlockFactory.Create(myContext.Nodes);
        var node  = new BalloonNode(childParser.BalloonType, block);

        parentParsingContext.AddNode(node);

        while (nonPauseNodes.TryPop(out var nonPauseNode))
        {
            parentParsingContext.AddNode(nonPauseNode);
        }

        return;
    }
示例#17
0
    public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
    {
        var myContext = new TextParentParsingContext();
        await elementParser.ParseAsync(reader, parsingContext, myContext, Settings);

        if (myContext.ParsedText is null)
        {
            return;
        }

        if (myContext.ParsedText.Length == 0)
        {
            parsingContext.LogError(reader, "Era esperado o nome da cor.");
            return;
        }

        var state = new BackgroundState(myContext.ParsedText, BackgroundType.Color, BackgroundPosition.Undefined);
        var node  = new BackgroundNode(state, myContext.When);

        parentParsingContext.AddNode(node);
    }
示例#18
0
    public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
    {
        var myContext = new TextParentParsingContext();
        await elementParser.ParseAsync(reader, parsingContext, myContext, Settings);

        if (myContext.ParsedText is null)
        {
            return;
        }

        var result = conditionParser.Parse(myContext.ParsedText);

        if (result.Condition is null)
        {
            parsingContext.LogError(reader, "Condição EnabledWhen inválida. " + result.Message);
            return;
        }
        var ctx = (IChoiceOptionParentParsingContext)parentParsingContext;

        ctx.Option.EnabledWhen = result.Condition;
    }
示例#19
0
    public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
    {
        var myContext = new TextParentParsingContext();
        await elementParser.ParseAsync(reader, parsingContext, myContext, Settings);

        var parsedText = myContext.ParsedText;

        if (parsedText is null)
        {
            return;
        }

        if (parsingContext.SceneContext.HasMood)
        {
            parsingContext.LogError(reader, "Mais de uma definição de humor para a mesma cena.");
            return;
        }
        parsingContext.SceneContext.HasMood = true;

        var moodType = Enum.Parse <MoodType>(parsedText);

        parentParsingContext.AddNode(new MoodNode(moodType));
    }
示例#20
0
    public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
    {
        var myContext = new TextParentParsingContext();
        await elementParser.ParseAsync(reader, parsingContext, myContext, Settings);

        var parsedText = myContext.ParsedText;

        if (parsedText is null)
        {
            return;
        }

        var varSet = varSetParser.Parse(parsedText);

        if (varSet is null)
        {
            parsingContext.LogError(reader, "Expressão de atribuição de variável inválida.");
        }
        else
        {
            parentParsingContext.AddNode(new VarSetNode(varSet));
        }
    }
示例#21
0
    public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
    {
        var myContext = new TextParentParsingContext();
        await elementParser.ParseAsync(reader, parsingContext, myContext, Settings);

        var parsedText = myContext.ParsedText;

        if (parsedText is null)
        {
            return;
        }

        if (parsingContext.SceneContext.HasMusic)
        {
            parsingContext.LogError(reader, "Mais de uma definição de música para a mesma cena.");
            return;
        }
        parsingContext.SceneContext.HasMusic = true;

        var node = new MusicNode(parsedText.Length == 0 ? null : parsedText, myContext.When);

        parentParsingContext.AddNode(node);
        parsingContext.RegisterDismissNode(DismissNode);
    }
示例#22
0
 public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
 => await elementParser.ParseAsync(reader, parsingContext, parentParsingContext, Settings);
示例#23
0
 public Task ParseAsync(System.Xml.XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
 {
     return(elementParser.ParseAsync(reader, parsingContext, parentParsingContext, settings));
 }