Ejemplo n.º 1
0
    public void Assign()
    {
        layer = gameObject.layer;
        //SpriteRenderer spriteRenderer = GetComponent<SpriteRenderer>();
        //gameObject.name = spriteRenderer.sprite.name;
        characterName = gameObject.name;
        CharacterManager characterManager = CharacterManager.Instance;

        SetStoryStages();
        ConversationLoader.LoadConversationXml(this);
        for (int i = 0; i < characterManager.SpokenTo.Count; i++)
        {
            if (characterManager.SpokenTo[i].characterName == characterName)
            {
                if (characterManager.SpokenTo[i].storyStage <= UsedStoryThreads[0].StageNumber)
                {
                    Debug.Log(characterName + " has found story stage: " + UsedStoryThreads[0].StoryThreadName);
                    StageCounter = characterManager.SpokenTo[i].stageCounter;
                    break;
                }
                else
                {
                    StageCounter = 0;
                    break;
                }
            }
        }
    }
    // Use this for initialization
    void Start()
    {
        //textLoader = GetComponent<TextLoader>();
        conversationLoader = GetComponent <ConversationLoader>();

        /*
         * if (textLoader.dictionary.ContainsKey(leftCharacterKey))
         * {
         *  leftCharacter = textLoader.dictionary[leftCharacterKey];
         * }
         * else
         * {
         *  Debug.LogError("Left Character is missing");
         * }
         * if (textLoader.dictionary.ContainsKey(rightCharacterKey))
         * {
         *  rightCharacter = textLoader.dictionary[rightCharacterKey];
         * }
         * else
         * {
         *  Debug.LogError("Right Character is missing");
         * }
         * if (textLoader.dictionary.ContainsKey(choicesKey))
         * {
         *  choices = textLoader.dictionary[choicesKey];
         * }
         * else
         * {
         *  Debug.LogError("Choices are missing");
         * }
         */

        choices = conversationLoader.choice;
        script  = conversationLoader.script;

        if (conversationLoader.music.Count > 0)
        {
            Debug.Log("found music! song=" + conversationLoader.music[0]);

            audioManager = FindObjectOfType <MusicManager> ();
            if (audioManager != null)
            {
                audioManager.ChangeMusic(conversationLoader.music[0]);
            }
        }

        currentNode = script [nodeId];

        if (currentNode.stats != null)
        {
            gameController = FindObjectOfType <GameController> ();
            if (gameController != null)
            {
                gameController.gameProgress.UpdateStats(currentNode.stats);
            }
        }
    }
 public void initConversationWarehouse(byte numberOfPatronsInTheGame)
 {
     charactersConversations = new List <Conversation> [numberOfPatronsInTheGame];
     conversationLoader      = new ConversationLoader();
     conversationLoader.init();
     for (byte i = 0; i < numberOfPatronsInTheGame; i++)
     {
         charactersConversations[i] = conversationLoader.loadPatronConversationsBasedOnId(i);
     }
 }
        public void TranslateAndAudio(string languageName, string isoCode)
        {
            var conversation = ConversationLoader.Load(conversationName, conversationGroup);
            var language     = new Language()
            {
                Name = languageName, Code = isoCode
            };

            new TranslatorCoordinator().TranslateAndAudio(conversation, language);
        }
Ejemplo n.º 5
0
    void Start()
    {
        //TODO: Initialize all the prefabs here!
        playerControlsUI = Instantiate(playerUIprefab);
        playerControlsUI.gameController = this;
        playerControlsUI.transform.SetParent(gameCanvas.transform, false);

        convLoader = ChatController.Instance.ConvLoader;
        ChatController.Instance.AddConversation(convLoader.StartingConvo);
    }
Ejemplo n.º 6
0
    void Awake()
    {
        Instance = this;

        IDToConversation = new Hashtable();

        foreach (string conversation in conversations)
        {
            ConversationLoader.LoadConversation(conversation);
        }
    }
    public void Run(String tome, Action postExecution = null)
    {
        conv  = ConversationLoader.CreateConversation(tome);
        state = State.Update;

        // activate itself so it can start running
        gameObject.SetActive(true);

        if (postExecution != null)
        {
            this.postExecution = postExecution;
        }
    }
Ejemplo n.º 8
0
        public void Traverse_TomeTest3_WithChoice2_UsingBakedInBranches()
        {
            int[] choices = new int[] { 2 };
            var   conv    = ConversationLoader.CreateConversation(Path.Combine(Config.TomePath, "TomeTest_3.yml"));

            string result   = TraverseGraph(conv, choices);
            string expected = "Diana: I didn't want to be the one to forget\n" +
                              "Diego: I thought of everything I'd never regret\n" +
                              "2: I don't believe in him - his lips on the ground\n" +
                              "Diana: But no one gives us time anymore\n" +
                              "Diego: Will you be my light?\n";

            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 9
0
        public void Traverse_TomeTest6_Choice2_CheckingPassingSelection()
        {
            //avegers assemble
            int[] choices = new int[] { 2 };
            var   conv    = ConversationLoader.CreateConversation(Path.Combine(Config.TomePath, "TomeTest_6.yml"));

            //act
            string result   = TraverseGraph(conv, choices);
            string expected = "Spongebob: I'm ready\n" +
                              "2: Path 3\n" +
                              "Sandy: Karate chop\n";

            //assert
            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 10
0
        public void Traverse_TomeTest5_Choice1_CheckingForBlockSkipping()
        {
            int[] choices = new int[] { 1 };
            var   conv    = ConversationLoader.CreateConversation(Path.Combine(Config.TomePath, "TomeTest_5.yml"));

            // action
            string result   = TraverseGraph(conv, choices);
            string expected = "1: choice 2\n" +
                              "Other: Another one\n" +
                              "Other: something\n" +
                              "Other: done\n" +
                              "Last: Hey\n";

            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 11
0
        public void Traverse_TomeTest4_Choice1_CheckingForFlagRequirements()
        {
            // assemble
            int[] choices = new int[] { 1 };
            var   conv    = ConversationLoader.CreateConversation(Path.Combine(Config.TomePath, "TomeTest_4.yml"));

            // action
            string result   = TraverseGraph(conv, choices);
            string expected = "Diego: Hey what's happening\n" +
                              "1: This sets two to true\n" +
                              "Person: Hey\n" +
                              "Person: Blah\n";

            // assert
            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 12
0
        public void Traverse_TomeTest6_Choice1_CheckingBakedInBranchSelection()
        {
            //assemble
            int[] choices = new int[] { 1 };
            var   conv    = ConversationLoader.CreateConversation(Path.Combine(Config.TomePath, "TomeTest_6.yml"));

            //act
            string result   = TraverseGraph(conv, choices);
            string expected = "Spongebob: I'm ready\n" +
                              "1: Path 2\n" +
                              "Squidward: Arghhh\n" +
                              "Patrick: SPONGEBOB\n" +
                              "Sandy: Karate chop\n";

            //assert
            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 13
0
        public void Traverse_TomeTest6_Choice0_CheckingBranchNameSelection()
        {
            //assemble
            int[] choices = new int[] { 0 };
            var   conv    = ConversationLoader.CreateConversation(Path.Combine(Config.TomePath, "TomeTest_6.yml"));

            //act
            string result   = TraverseGraph(conv, choices);
            string expected = "Spongebob: I'm ready\n" +
                              "0: Path 1\n" +
                              "Pearl: Daddy!\n" +
                              "Sandy: Karate chop\n" +
                              "Mr.Krabs: I like money\n";

            //assert
            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 14
0
        public void Traverse_TomeTest2_WithChoice0()
        {
            // arrange
            int[] choices = new int[] { 0 };
            var   conv    = ConversationLoader.CreateConversation(Path.Combine(Config.TomePath, "TomeTest_2.yml"));

            // act
            string result   = TraverseGraph(conv, choices);
            string expected = "Yulia: What the f**k is this\n" +
                              "Yulia: What are you doing?\n" +
                              "0: Nothing\n" +
                              "Yulia: You're lying\n" +
                              "Diego: Yeah she is\n" +
                              "Diego: There's a lot of yelling going on right now\n";

            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 15
0
        public void Traverse_TomeTest5_Choice0_CheckingForMixedFlagRequirements()
        {
            int[] choices = new int[] { 0 };
            var   conv    = ConversationLoader.CreateConversation(Path.Combine(Config.TomePath, "TomeTest_5.yml"));

            //action
            string result   = TraverseGraph(conv, choices);
            string expected = "0: choice 1\n" +
                              "Person: hello\n" +
                              "Person: how\n" +
                              "Person: are you\n" +
                              "Other: Another one\n" +
                              "Other: done\n" +
                              "More: Blah\n" +
                              "Last: Hey\n";

            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 16
0
        public override int Run(string[] remainingArguments)
        {
            try
            {
                var pathToFile = Path.Combine(Directory.GetCurrentDirectory(), FileName);
                // does not need to save anything just needs to parse it
                ConversationLoader.CreateConversation(pathToFile);
                Console.Out.WriteLine(FileName + " parsed correctly.");
                return(0);
            }
            catch (Exception ex)
            {
                // change this with some better exception handling
                Console.Error.WriteLine(ex.Message);
                Console.Error.WriteLine(ex.StackTrace);

                return(1);
            }
        }
Ejemplo n.º 17
0
        public override int Run(string[] remainingArguments)
        {
            try
            {
                string pathToFile = Path.Combine(Directory.GetCurrentDirectory(), FileName);
                var    graph      = ConversationLoader.CreateConversation(pathToFile);
                var    runner     = new Traverser(graph);
                runner.Traverse();

                // success
                return(0);
            }
            catch (Exception e)
            {
                Console.Error.Write(e.Message);
                Console.Error.Write(e.StackTrace);

                // errorrrr
                return(1);
            }
        }
Ejemplo n.º 18
0
        public void Traverse_TomeTest3_WithChoice0_UsingBranchName()
        {
            // These are inputs, for the traversal
            // for descisions these correspond to the chosen choice not the branch
            // assemble
            int[] choices = new int[] { 0 };
            var   conv    = ConversationLoader.CreateConversation(Path.Combine(Config.TomePath, "TomeTest_3.yml"));

            // action
            string result   = TraverseGraph(conv, choices);
            string expected = "Diana: I didn't want to be the one to forget\n" +
                              "Diego: I thought of everything I'd never regret\n" +
                              "0: A little time with you is all that I get\n" +
                              "Diego: I gotta be in your arms baby\n" +
                              "Diego: But far away I seek for your light\n" +
                              "Diego: I hold on because for you my heart keeps beating\n" +
                              "Diana: But no one gives us time anymore\n" +
                              "Diego: Will you be my light?\n";

            // assert
            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 19
0
    public ConversationDependancy(JSONNode dependancyJSON)
    {
        var jsonType = dependancyJSON["type"];

        switch (jsonType)
        {
        case "player-has":
            type = DependancyType.PlayerHasItem;
            break;

        case "player-does-not-have":
            type = DependancyType.PlayerDoesNotHaveItem;
            break;

        default:
            Debug.LogError("Unknown dependancy type");
            return;
        }

        var actionsJSON = dependancyJSON["actions"];

        if (actionsJSON == null)
        {
            actions = null;
        }
        else
        {
            actions = new ConversationAction[actionsJSON.Count];
            for (int i = 0; i < actionsJSON.Count; i++)
            {
                actions[i] = new ConversationAction(actionsJSON[i]);
            }
        }

        objects = ConversationLoader.JSONToStringArray(dependancyJSON, "objects");
    }
Ejemplo n.º 20
0
    public ConversationAction(JSONNode actionJSON)
    {
        string JSONtype = actionJSON["action"];

        switch (JSONtype)
        {
        case "remove-item":
            type = ActionType.RemoveItem;
            break;

        case "add-item":
            type = ActionType.AddItem;
            break;

        case "replace-responses":
            type = ActionType.ReplaceResponses;
            break;

        case "walk-to":
            type = ActionType.WalkTo;
            break;

        case "run-conversation":
            type = ActionType.RunConversation;
            break;

        case "set-flag":
            type = ActionType.SetFlag;
            break;

        case "say":
            type = ActionType.Say;
            break;

        default:
            type = ActionType.AddItem;
            break;
        }

        objects = ConversationLoader.JSONToStringArray(actionJSON, "objects");

        var requirementsJSON = actionJSON["requirements"];

        if (requirementsJSON == null)
        {
            requirements = null;
        }
        else
        {
            requirements = new ActionRequirement[requirementsJSON.Count];
            for (int i = 0; i < requirementsJSON.Count; i++)
            {
                requirements[i] = new ActionRequirement(requirementsJSON[i]);
            }
        }

        var actionsJSON = actionJSON["actions"];

        if (actionsJSON == null)
        {
            nextActions = null;
        }
        else
        {
            nextActions = new ConversationAction[actionsJSON.Count];
            for (int i = 0; i < actionsJSON.Count; i++)
            {
                nextActions[i] = new ConversationAction(actionsJSON[i]);
            }
        }
    }