Ejemplo n.º 1
0
 void engine_OutputReady(object sender, OutputReadyEventArgs e)
 {
     if (OutputReady != null)
     {
         OutputReady(this, e);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Sends the queued output to the <see cref="OutputReady"/> event handler.
 /// </summary>
 private void DeliverOutput()
 {
     if (OutputReady != null)
     {
         OutputReadyEventArgs args = new OutputReadyEventArgs();
         args.Package = outputBuffer.Flush();
         OutputReady(this, args);
     }
 }
Ejemplo n.º 3
0
 void engine_OutputReady(object sender, OutputReadyEventArgs e)
 {
     if (e.Package.Count > 0)
     {
         Dispatcher.BeginInvoke(delegate
         {
             pleaseWait.Visibility = Visibility.Collapsed;
             pleaseWait.Opacity    = 0;
             AddHistory(new StoryHistoryItem(null, e));
         });
     }
 }
Ejemplo n.º 4
0
        void engine_OutputReady(object sender, OutputReadyEventArgs e)
        {
            test.CurrentStep.ActualResults = (Dictionary <string, string>)e.Package;

            // We have our output
            // Tell the test step to compare
            test.CurrentStep.CompareResults();

            // Setup the next step.
            test.NextStep();

            if (test.CurrentStep == null)
            {
                engine.Stop();
            }
        }
Ejemplo n.º 5
0
        private void vm_OutputReady(object sender, OutputReadyEventArgs e)
        {
            // ----------- DECIDE TO STORE OUTPUT --------------

            if (!needLine || wrapperState == VMWrapperState.LoadGame)
            {
                if ((wrapperState == VMWrapperState.LoadGame && requestType == VMRequestType.StartGame) || wrapperState == VMWrapperState.RunCommand)
                {
                    HandleOutput((Dictionary <string, string>)e.Package);
                }

                // ----------- DETERMINE STATE -------------

                if (wrapperState == VMWrapperState.RequestSave)
                {
                    outSaveFile  = saveStream.ToArray();
                    wrapperState = VMWrapperState.Completed;
                    vm.Stop();
                }

                if (wrapperState == VMWrapperState.RunCommand || (wrapperState == VMWrapperState.LoadGame && requestType == VMRequestType.StartGame))
                {
                    wrapperState = VMWrapperState.RequestSave;
                }

                if (wrapperState == VMWrapperState.RequestRestore && requestType == VMRequestType.ExecuteCommand)
                {
                    wrapperState = VMWrapperState.RunCommand;
                }

                if (wrapperState == VMWrapperState.LoadGame && requestType == VMRequestType.ExecuteCommand)
                {
                    wrapperState = VMWrapperState.RequestRestore;
                }

                needLine = true;
            }
        }
Ejemplo n.º 6
0
 public StoryState(OutputReadyEventArgs outputArgs)
 {
     if (outputArgs.Package.ContainsKey(OutputChannel.Location))
     {
         Location = outputArgs.Package[OutputChannel.Location].Trim();
     }
     if (outputArgs.Package.ContainsKey(OutputChannel.Score))
     {
         Score = outputArgs.Package[OutputChannel.Score].Trim();
     }
     if (outputArgs.Package.ContainsKey(OutputChannel.Time))
     {
         Time = outputArgs.Package[OutputChannel.Time].Trim();
     }
     if (outputArgs.Package.ContainsKey(OutputChannel.Prompt))
     {
         Prompt = outputArgs.Package[OutputChannel.Prompt].Trim();
     }
     else
     {
         Prompt = ">";
     }
 }
Ejemplo n.º 7
0
 public StoryHistoryItem(string input, OutputReadyEventArgs output)
 {
     this.Input      = input;
     this.OutputArgs = output;
 }
Ejemplo n.º 8
0
 private void vm_OutputReady(object sender, OutputReadyEventArgs e)
 {
     this.Invoke(
         new Action <Dictionary <string, string> >(HandleOutput),
         e.Package);
 }
Ejemplo n.º 9
0
 protected virtual void OnOutputReady(OutputReadyEventArgs e)
 {
     OutputReady?.Invoke(this, e);
 }
Ejemplo n.º 10
0
            public void FyreOutputReady(object sender, OutputReadyEventArgs e)
            {
                string main;

                if (e.Package.TryGetValue(OutputChannel.Main, out main) == true)
                {
                    if (curTrans != null)
                    {
                        curTrans.Response.Append(main);
                    }
                    else
                    {
                        instance.HandleOutputAsync(main).Wait();
                    }
                }

                string special;

                if (e.Package.TryGetValue(OutputChannel.Conversation, out special) && special.Length > 0)
                {
                    string[] parts = special.Split(new char[] { ' ' }, 3);
                    if (parts.Length > 0)
                    {
                        string name = (parts.Length > 1) ? parts[1] : "";
                        string rest = (parts.Length > 2) ? parts[2] : "";
                        int    word;
                        int    chunkSize;
                        string str;

                        switch (parts[0])
                        {
                        case "getword":
                            if (instance.TryGetWordRegister(name, out word))
                            {
                                specialResponses.Enqueue(word.ToString());
                            }
                            else
                            {
                                specialResponses.Enqueue("-1");
                            }
                            break;

                        case "gettext":
                            str = instance.GetTextRegister(name) ?? "";
                            specialResponses.Enqueue(str.Length.ToString());
                            if (!int.TryParse(rest, out chunkSize))
                            {
                                chunkSize = str.Length;
                            }
                            for (int offset = 0; offset < str.Length; offset += chunkSize)
                            {
                                specialResponses.Enqueue(
                                    str.Substring(offset, Math.Min(chunkSize, str.Length - offset)));
                            }
                            break;

                        case "putword":
                            if (int.TryParse(rest, out word) && instance.TryPutWordRegister(name, word))
                            {
                                specialResponses.Enqueue("1");
                            }
                            else
                            {
                                specialResponses.Enqueue("0");
                            }
                            break;

                        case "puttext":
                            instance.PutTextRegister(name, rest);
                            specialResponses.Enqueue("?");
                            break;
                        }
                    }
                }
            }