Esempio n. 1
0
        public void InitWindow()
        {
            hobbiesWindow.effectUponReaching = container.UpdateImageAction(3);
            StoryNode sawSomethingInteresting = new StoryNode("There was a time... I saw something very interesting.", container.UpdateImageAction(ONE));

            sawSomethingInteresting.GraftStep(new StoryNode(string.Format("<--{0} has a faraway look in his eyes -->", catName), container.UpdateImageAction(FIVE)));
            hobbiesWindow.GraftStep(sawSomethingInteresting);

            hobbiesWindow.AddHint(new StoryNode("No one ever wants to hear about the most interesting thing I've seen.", container.UpdateImageAction(TWO)));

            StoryNode sawAnotherCat  = new StoryNode("I saw another cat.", container.UpdateImageAction(ZERO));
            StoryNode sawAnotherCat1 = new StoryNode("It was long and black.", container.UpdateImageAction(ONE));
            StoryNode sawAnotherCat2 = new StoryNode("He was interesting because he didn't have a colllar. That's pretty unusual around here.", container.UpdateImageAction(FIVE));

            sawAnotherCat.AddFreeTransition(sawAnotherCat1);
            sawAnotherCat1.AddFreeTransition(sawAnotherCat2);

            hobbiesWindow.AddInputBasedTransition("(see|saw|what was|look)".MatchSomewhere(), sawAnotherCat);

            StoryNode catLooksAwkward = new StoryNode(string.Format("<-- {0} looks very uncomfortable -->", catName), container.UpdateImageAction(TWO));

            sawAnotherCat2.AddFreeTransition(catLooksAwkward);

            catLooksAwkward.GraftStep(new StoryNode("Maybe I shouldn't have brought this up. I don't know why I did.", container.UpdateImageAction(6)));
            catLooksAwkward.GraftStep(new StoryNode("I feel odd talking about him.", container.UpdateImageAction(9)));

            StoryNode catKnowsHim = new StoryNode("Well... I knew him.", container.UpdateImageAction(NINE));

            catLooksAwkward.AddInputBasedTransition("(wrong?|okay?|uncomfortable|what's up?)".MatchSomewhere(), catKnowsHim);

            StoryNode hisNameWasRiddle = new StoryNode("He was a childhood friend. His name is Riddle.", container.UpdateImageAction(ELEVEN));

            catKnowsHim.AddInputBasedTransition("(name|who|how|from where|from when|how long|other cat|the cat|tell me)".MatchSomewhere(), hisNameWasRiddle);
            catKnowsHim.AddHint(new StoryNode(string.Format("{0} looks as though he's remembering something from long ago", catName), container.UpdateImageAction(ZERO)));
            catKnowsHim.AddHint(new StoryNode(string.Format("<--{0} looks as though he wants to talk about the other cat-->", catName)));
            catKnowsHim.AddHint(new StoryNode(string.Format("<--{0} just needs an excuse to explain how he knows the other cat-->", catName)));


            //leaf for the window branch
            StoryNode catWantsToStopTalkingAboutRiddle = new StoryNode("Let's discuss something else.", () =>
            {
                //can't talk about window anymore, finished with that branch.
                catHobbies.text = "My other hobbies are eating and sleeping.";
                catHobbies.RemoveInputBasedTransition("window");
                //go back to hobbies
                container.View.SetStory(catHobbies);

                //update the text after a time
                Timer timer    = TimerFactory.Instance.NewTimer();
                timer.onTimeUp = () => {
                    container.View.DisplayTextOfCurrentStoryNode();
                    container.View.UpdateImage(catImages[ZERO]);
                };
                timer.secondsDuration = 3f;
                timer.Begin();

                //add a new branch, from any other.
                root.AddInputBasedTransition("riddle".MatchSomewhere(), riddle);


                //player completed this branch, so give the player an item...
                MyEvents.PlayerGivenItem.Fire(new Item(string.Format("{0} knew a cat called Riddle", catName), string.Format("{0} seemed uncomfortable thinking about Riddle", catName)));
            });

            hisNameWasRiddle.AddFreeTransition(catWantsToStopTalkingAboutRiddle);
        }
Esempio n. 2
0
    /*
     * a recent replacement for loop back to this via... the idea is that I don't think it makes much sense to loop back to the exact same text.
     * what we want to loop back to is a node with different text then the original, but the same subgraph. so instead of looping back to the original node
     * we loop back to a new node which is basically a graft.
     *
     * */

    public void GraftLoop(StoryNode intermediary, StoryNode loopTo)
    {
        loopTo.TakeEntireSubgraphOf(this);
        intermediary.AddFreeTransition(loopTo);
        AddFreeTransition(intermediary);
    }