Пример #1
0
        public async void UseInput()
        {
            await MessageService.ProcessAsync(Message <float> .Create(0.3F, DialoguePlugin.MessageIntegration.Mask,
                                                                      DialoguePlugin.MessageIntegration.HideDialogueBox));

            var title = new StringValue {
                Value = "输入姓和名(空格隔开)"
            };
            var defaultText = new StringValue {
                Value = "诹访部 翔平"
            };
            var confirmText = new StringValue {
                Value = "继续"
            };
            var context = PluginExecuteContext.Create(new ScriptRuntime("Utilities"));
            var message = await MessageService.ProcessAsync(ContextMessage <InputPlugin.MessageIntegration.Content> .Create(context,
                                                                                                                            new InputPlugin.MessageIntegration.Content {
                Title = title, Default = defaultText, ButtonText = confirmText
            },
                                                                                                                            InputPlugin.MessageIntegration.Mask,
                                                                                                                            InputPlugin.MessageIntegration.CreateInput));

            if (message is Message <string> stringMessage)
            {
                Debug.Log(stringMessage.Content);
            }
            await MessageService.ProcessAsync(Message <float> .Create(0.3F, DialoguePlugin.MessageIntegration.Mask,
                                                                      DialoguePlugin.MessageIntegration.ShowDialogueBox));
        }
Пример #2
0
        public async Task <SerializableValue> Execute(PluginExecuteContext context)
        {
            var description = new MessageIntegration.Content();

            foreach (var(name, value) in context.StringParameters)
            {
                switch (name.ConvertToString(context.Language))
                {
                case "Title":
                    if (value is IStringConverter stringTitle)
                    {
                        description.Title = stringTitle;
                    }
                    else
                    {
                        throw new NotSupportedException($"Unable to create input: title {value} is not string value");
                    }
                    break;

                case "Default":
                    if (value is IStringConverter stringDefault)
                    {
                        description.Default = stringDefault;
                    }
                    else
                    {
                        throw new NotSupportedException($"Unable to create input: default {value} is not string value");
                    }
                    break;

                case "ButtonText":
                    if (value is IStringConverter stringButton)
                    {
                        description.ButtonText = stringButton;
                    }
                    else
                    {
                        throw new NotSupportedException($"Unable to create input: button text {value} is not string value");
                    }
                    break;

                default:
                    Debug.LogWarning($"Input plugin: unknown parameter {name}");
                    break;
                }
            }
            var message = await MessageService.ProcessAsync(ContextMessage <MessageIntegration.Content> .Create(MessageIntegration.Mask, MessageIntegration.CreateInput, description, context));

            return(message is Message <string> stringMessage ? new StringValue {
                value = stringMessage.Content
            } : null);
        }
Пример #3
0
        public async Task <SerializableValue> Execute(PluginExecuteContext context)
        {
            var dialogue = new MessageIntegration.Content();

            foreach (var(name, value) in context.StringParameters)
            {
                switch (name.ConvertToString(context.Language))
                {
                case "Show":
                    await ShowWindow(value, context.Language);

                    return(new NullValue());

                case "Hide":
                    await HideWindow(value, context.Language);

                    return(new NullValue());

                case "Character":
                    dialogue.Character = value;
                    break;

                case "Content":
                    if (value is IStringConverter stringContent)
                    {
                        dialogue.Text = stringContent;
                    }
                    else
                    {
                        throw new ArgumentException($"Unable to create dialogue: unsupported content type {value}");
                    }
                    break;
                }
            }
            await MessageService.ProcessAsync(ContextMessage <MessageIntegration.Content> .Create(MessageIntegration.Mask, MessageIntegration.NewDialogue, dialogue, context));

            return(new NullValue());
        }