public static void CallSuccess()
        {
            var rumor = new Rumor(
                new Dictionary<string, List<Node>>
                {
                    { Rumor.MainIdentifier, new List<Node>()
                        { new CallNode("foobar")
                        , new WaitNode()
                        }
                    },
                    { "foobar", new List<Node>()
                        { new WaitNode()
                        }
                    }
                }
            );

            rumor.Start();
            Assert.IsTrue(rumor.Executing);

            rumor.Advance();
            Assert.IsTrue(rumor.Executing);

            rumor.Advance();
            Assert.IsFalse(rumor.Executing);
            Assert.AreEqual(1, rumor.FinishCount);
            Assert.AreEqual(0, rumor.CancelCount);
        }
示例#2
0
        public static void ClearDialogSuccess()
        {
            var rumor = new Rumor(
                new Dictionary <string, List <Node> >
            {
                { Rumor.MainIdentifier, new List <Node>()
                  {
                      new SetDialogNode("Alice", "Hello world!")
                      , new ClearNode(ClearType.Dialog)
                  } }
            }
                );

            rumor.Start();
            Assert.IsTrue(rumor.Executing);
            Assert.AreEqual(
                new Dictionary <string, string>()
            {
                { "Alice", "Hello world!" }
            },
                rumor.State.GetDialog()
                );

            rumor.Advance();
            Assert.IsFalse(rumor.Executing);
            Assert.AreEqual(1, rumor.FinishCount);
            Assert.AreEqual(0, rumor.CancelCount);
            Assert.AreEqual(
                new Dictionary <string, string>()
            {
            },
                rumor.State.GetDialog()
                );
        }
示例#3
0
        public static void ChoiceTimeoutSuccess()
        {
            var rumor = new Rumor(
                new Dictionary <string, List <Node> >
            {
                { Rumor.MainIdentifier, new List <Node>()
                  {
                      new AddChoiceNode("choice1", "Hello?")
                      , new AddChoiceNode("choice2", "World?")
                      , new ChooseNode(
                          new NumberLiteral(2),
                          MoveType.Jump,
                          "choice2"
                          )
                  } },
                { "choice1", new List <Node>()
                  {
                      new SetDialogNode("Alice", "Choice 1!")
                  } },
                { "choice2", new List <Node>()
                  {
                      new SetDialogNode("Eve", "Choice 2!")
                  } }
            }
                );

            rumor.Start();
            Assert.IsTrue(rumor.Executing);
            Assert.AreEqual(
                new Dictionary <string, string>()
            {
                { "choice1", "Hello?" },
                { "choice2", "World?" },
            },
                rumor.State.GetChoices()
                );

            rumor.Update(2);
            Assert.IsTrue(rumor.Executing);
            Assert.AreEqual(
                new Dictionary <string, string>()
            {
            },
                rumor.State.GetChoices()
                );
            Assert.AreEqual(
                new Dictionary <string, string>()
            {
                { "Eve", "Choice 2!" }
            },
                rumor.State.GetDialog()
                );

            rumor.Advance();
            Assert.IsFalse(rumor.Executing);
            Assert.AreEqual(1, rumor.FinishCount);
            Assert.AreEqual(0, rumor.CancelCount);
        }
示例#4
0
        public static void ChoiceSuccess()
        {
            var rumor = new Rumor(
                new Dictionary <string, List <Node> >
            {
                { Rumor.MainIdentifier, new List <Node>()
                  {
                      new AddChoiceNode("choice1", "Hello?")
                      , new ChooseNode()
                  } },
                { "choice1", new List <Node>()
                  {
                      new SetDialogNode("Alice", "Choice 1!")
                  } }
            }
                );

            rumor.Start();
            Assert.IsTrue(rumor.Executing);
            Assert.AreEqual(
                new Dictionary <string, string>()
            {
                { "choice1", "Hello?" },
            },
                rumor.State.GetChoices()
                );

            rumor.Choose("choice1");
            Assert.IsTrue(rumor.Executing);
            Assert.AreEqual(
                new Dictionary <string, string>()
            {
                { "Alice", "Choice 1!" }
            },
                rumor.State.GetDialog()
                );

            rumor.Advance();
            Assert.IsFalse(rumor.Executing);
            Assert.AreEqual(1, rumor.FinishCount);
            Assert.AreEqual(0, rumor.CancelCount);
        }
示例#5
0
        void Update()
        {
            if (rumor == null)
            {
                text.text = "";
                return;
            }

            if (rumor.Choosing)
            {
                int num = 1;
                text.text = "";

                foreach (var choice in rumor.State.Choices)
                {
                    text.text += num + ") " + choice + "\n";
                    num++;
                }
            }
            else
            {
                text.text = rumor.State.Dialog["Narrator"];
            }

            rumor.Update(Time.deltaTime);

            if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Space))
            {
                rumor.Advance();
            }

            if (Input.GetKeyDown(KeyCode.Alpha1))
            {
                rumor.Choose(0);
            }

            if (Input.GetKeyDown(KeyCode.Alpha2))
            {
                rumor.Choose(1);
            }
        }
 public void AdvanceDialog()
 {
     rumor.Advance();
 }