IEnumerator DynamicStoryExample()
    {
        NovelController.instance.LoadChapterFile("story_1"); yield return(new WaitForEndOfFrame());

        while (NovelController.instance.isHandlingChapterFile)
        {
            yield return(new WaitForEndOfFrame());
        }

        ChoiceScreen.Show("What will you do?", "Go with Terrance", "Stay where you are");
        while (ChoiceScreen.isWaitingForChoiceToBeMade)
        {
            yield return(new WaitForEndOfFrame());
        }

        //you chose to go with Terrance
        if (ChoiceScreen.lastChoiceMade.index == 0)
        {
            NovelController.instance.LoadChapterFile("story_a1");
        }
        //you chose to stay where you are
        else
        {
            NovelController.instance.LoadChapterFile("story_b1");
        }

        yield return(new WaitForEndOfFrame());

        NovelController.instance.Next();

        while (NovelController.instance.isHandlingChapterFile)
        {
            yield return(new WaitForEndOfFrame());
        }
    }
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Alpha1))
     {
         ChoiceScreen.Show(title, "Dogs", "Cats");
     }
 }
 public ChoiceClientHandler(Game game, Pawn pawn, ChoiceScreen screen)
 {
     this.game   = game;
     this.pawn   = pawn;
     this.screen = screen;
     AddHandler(GameMsg.StartBattle, OnBattleStart);
     AddHandler(GameMsg.ShopList, OnShopList);
     AddHandler(GameMsg.OpenVendor, OnOpenVendor);
 }
Exemple #4
0
    IEnumerator HandlingChoiceLine(string line)
    {
        string        title   = line.Split('"')[1];
        List <string> choices = new List <string>();
        List <string> actions = new List <string>();

        bool gatheringChoices = true;

        while (gatheringChoices)
        {
            chapterProgress++;
            line = data[chapterProgress];

            if (line == "{")
            {
                continue;
            }

            line = line.Replace("\t", "");//remove the tabs that have become quad spaces.

            if (line != "}")
            {
                choices.Add(line.Split('"')[1]);
                actions.Add(data[chapterProgress + 1].Replace("\t", ""));
                chapterProgress++;
            }
            else
            {
                gatheringChoices = false;
            }
        }

        //display choices if
        if (choices.Count > 0)
        {
            ChoiceScreen.Show(title, choices.ToArray()); yield return(new WaitForEndOfFrame());

            while (ChoiceScreen.isWaitingForChoiceToBeMade)
            {
                yield return(new WaitForEndOfFrame());
            }

            //choice is made
            string action = actions[ChoiceScreen.lastChoiceMade.index];
            HandleLine(action);

            while (isHandlingLine)
            {
                yield return(new WaitForEndOfFrame());
            }
        }
        else
        {
            Debug.LogError("Invalid choice operation. No choices were found.");
        }
    }
Exemple #5
0
    /// <summary>
    /// Handling choice command
    /// </summary>
    /// <param name="choice"></param>
    /// <returns></returns>
    IEnumerator HandlingChoiceLine(string line)
    {
        string        title   = line.Split('"')[1];
        List <string> choices = new List <string>();
        List <string> actions = new List <string>();

        while (true)
        {
            chapterProgress++;
            line = data[chapterProgress];

            if (line == "{")
            {
                continue;
            }

            line = line.Replace("\t", "");
            if (line != "}")
            {
                choices.Add(line.Split('"')[1]);
                string act = data[chapterProgress + 1].Replace("\t", "");
                print(act);
                actions.Add(act);
                chapterProgress++;
            }
            else
            {
                break;
            }
        }
        if (choices.Count > 0)
        {
            ChoiceScreen.Show(title, choices.ToArray());
            yield return(new WaitForEndOfFrame());

            while (ChoiceScreen.isWaitingChoiceToBeMade)
            {
                yield return(new WaitForEndOfFrame());
            }

            // choice is made. execute the paired actions
            string action = actions[ChoiceScreen.lastChoiceMade.index];
            handleLine(action);

            while (isHandlingLine)
            {
                yield return(new WaitForEndOfFrame());
            }
        }
        else
        {
            Debug.LogError("invalid Choice operation");
        }
    }
Exemple #6
0
 private void Awake()
 {
     if (_instance == null)
     {
         _instance = this;
     }
     else
     {
         Debug.LogError("AN INSTANCE ALREADY EXISTS");
     }
 }
    public void OnOpenChoice(NetworkMessage msg)
    {
        PlayerPawn   pawn   = msg.ReadMessage <GameMsg.MsgPawn>().pawn as PlayerPawn;
        ChoiceScreen screen = new ChoiceScreen(game, RB.DisplaySize, pawn);
        MessageBox   msgBox = new MessageBox("Congratulations! This area is cleared");

        game.OpenClientHandler(new ChoiceClientHandler(game, pawn, screen));
        msgBox.AddButton("Continue", () => {
            game.OpenScreen(screen);
        });
        game.GetOpenScreen().ShowMessageBox(msgBox);
    }
    public IEnumerator HandleLine(string line)
    {
        string title = line.Split('"')[1];

        List <string> choices = new List <string>();
        Dictionary <string /*choice*/, List <string> > /*line / action list*/ actions = new Dictionary <string, List <string> >();
        bool gatheringChoices = true;
        bool gatheringActions = false;

        int cProgress = dialogueController.chapterProgress;

        while (gatheringChoices || gatheringActions)
        {
            cProgress++;
            line = dialogueController.data[cProgress];

            if (line == "{")
            {
                continue;
            }
            if (line == "}")
            {
                gatheringChoices = false;
                gatheringActions = false;
                continue;
            }

            line = line.Trim();

            if (gatheringChoices)
            {
                if (line.ToLower().StartsWith("["))
                {
                    gatheringChoices = false;
                    gatheringActions = true;
                    continue;
                }

                choices.Add(line.Split('"')[1]);
                actions.Add(line.Split('"')[1], new List <string>());
            }
            else
            {
                if (line.ToLower().StartsWith("]"))
                {
                    gatheringChoices = true;
                    gatheringActions = false;
                    continue;
                }

                actions[choices.Last()].Add(line);
            }
        }

        if (choices.Count > 0)
        {
            ChoiceScreen.Show(title, choices.ToArray());


            ///TODO:
            ///BLOCK OFF CHOICES THAT ARE NOT SELECTED if this is the past.

            yield return(new WaitForEndOfFrame());

            Debug.Log("BEGIN WAITING FOR CHOICE");

            while (ChoiceScreen.isWaitingForChoiceToBeMade)
            {
                yield return(new WaitForEndOfFrame());
            }

            Debug.Log("DONE WAITING FOR CHOICE");

            List <string> actionList = actions[choices[ChoiceScreen.lastChoiceMade.index]];

            foreach (Tuple <int, string> addedData in actionList.Select(s => new Tuple <int, string>(actionList.IndexOf(s) + 1 + cProgress, s)))
            {
                if (dialogueController.data[addedData.Item1] != addedData.Item2)
                {
                    dialogueController.data.Insert(addedData.Item1, addedData.Item2);
                }
            }
        }
        else
        {
            Debug.LogError("Invalid choice operation, no choices are found");
        }

        dialogueController.chapterProgress = cProgress;
        dialogueController.chapterProgress++;
        //Debug.Log("cProgress at: " + cProgress + " chaoterProgessAt: " + dialogueController.chapterProgress);

        dialogueController._next = true;
        dialogueController.StopHandlingLine();
    }
Exemple #9
0
 void Awake()
 {
     instance = this;
     Hide();
 }
Exemple #10
0
 private void Awake()
 {
     instance = this;
     _header  = GetComponent <TitleHeader>();
     Hide();
 }