public static void InitializeData()
    {
        // clear all lists (for new game setup)
        houseDataList.Clear();
        planetTraitDataList.Clear();
        planetAttributeDataList.Clear();
        CharacterTraitList.Clear();
        characterActionList.Clear();
        systemNameList.Clear();
        planetNameList.Clear();
        civNameList.Clear();
        civSurNameList.Clear();
        characterFemaleFirstNameList.Clear();
        characterMaleFirstNameList.Clear();
        Descriptions.Clear();

        // now read all data anew
        ReadEventDescriptions();
        ReadCharacterTraitXMLFiles();
        ReadActionXMLFiles();
        ReadHouseXMLFiles();
        ReadXMLTraitFiles();
        PopulateObjectNameLists();
        PopulatePlanetTraitTables();
        ConversationEngine.ReadConversationData();     // conversation data is kept in a static AI class
    }
        public void AreConditionsMet_DoesntUpdateNodeWhenNotAttempting()
        {
            Conversation testConvo = new Conversation();

            this.LoadConversationFromFile(DialogueFiles.SimpleConversation, ref testConvo);
            testConvo.JumpToNode(DialogueFiles.SimpleNodeNonEligibleNode);

            // Test that conditions are met for the node, should be false.
            ConversationEngine.AreConditionsMet(testConvo.CurrentNode);

            Assert.IsNull(testConvo.CurrentNode.IsEnabled);
        }
        public void AreConditionsMet_FalseConditionsFail()
        {
            // Load the conversation, and jump to a useful node for us to test.
            Conversation testConvo = new Conversation();

            this.LoadConversationFromFile(DialogueFiles.SimpleConversation, ref testConvo);
            testConvo.JumpToNode(DialogueFiles.SimpleNodeNonEligibleNode);

            // Test that conditions are met for the node, should be false.
            bool conditionsMet = ConversationEngine.AreConditionsMet(testConvo.CurrentNode);

            Assert.IsFalse(conditionsMet);
        }
        public void ActivateNode_ActivatesNodesWhenAble()
        {
            var openFile = File.Create(DialogueFiles.WriteValues);

            openFile.Close();

            // Load the conversation, and jump to a useful node for us to test.
            Conversation testConvo = new Conversation();

            this.LoadConversationFromFile(DialogueFiles.SimpleConversation, ref testConvo);
            testConvo.JumpToNode(DialogueFiles.SimpleNodeFileWriter);

            ConversationEngine.ActivateNode(testConvo.CurrentNode);

            // Test that the file was written.
            var fileContents = File.ReadAllText(DialogueFiles.WriteValues).Trim();

            Assert.AreEqual(DialogueFiles.WriteKeyword, fileContents);

            File.Delete(DialogueFiles.WriteValues);
        }
Esempio n. 5
0
        public static string GivePraisingSpeech(Character cData)
        {
            GlobalGameData  gDataRef            = GameObject.Find("GameManager").GetComponent <GlobalGameData>();
            Character       eData               = gDataRef.CivList[0].Leader; // you
            CharacterAction aData               = gDataRef.CharacterActionList.Find(p => p.ID == "A1");
            bool            speechSuccessful    = false;
            float           responseIndex       = 0f;
            int             speechEffectiveness = 0;
            string          speechSuccess       = ""; // debug code

            // make check based on charm + intelligence
            if (eData.Charm >= -30)
            {
                speechEffectiveness = UnityEngine.Random.Range(30, eData.Charm) + UnityEngine.Random.Range(0, eData.Intelligence);
                if (speechEffectiveness > 80)
                {
                    speechSuccessful = true;
                    speechSuccess    = "successful, value of " + speechEffectiveness.ToString("N0"); // debug code
                }
                else
                {
                    speechSuccessful = false;
                    speechSuccess    = "unsuccessful, value of " + speechEffectiveness.ToString("N0"); // debug code
                }
            }
            else
            {
                speechSuccessful = false;
                speechSuccess    = "unsuccessful, minimum check not passed to try"; // debug code
            }

            // now determine effect of character
            responseIndex = speechEffectiveness;
            if (speechSuccessful)
            {
                if (cData.NewRelationships[eData.ID].Trust > 50)
                {
                    cData.NewRelationships[eData.ID].Trust += UnityEngine.Random.Range(0, (speechEffectiveness / 5));
                }
                else
                {
                    cData.NewRelationships[eData.ID].Trust += UnityEngine.Random.Range(0, (speechEffectiveness / 8)); // less effective when more hated
                }

                // now determine effect of characters around them, checking each character individually
                foreach (string cID in cData.NewRelationships.Keys)
                {
                    if (cData.NewRelationships.ContainsKey(cID))
                    {
                        if (cData.NewRelationships[cID].RelationshipState == Relationship.eRelationshipState.Friends || cData.NewRelationships[cID].RelationshipState == Relationship.eRelationshipState.Allies)
                        {
                            cData.NewRelationships[cID].Trust += UnityEngine.Random.Range(0, (speechEffectiveness / 8));
                            HelperFunctions.DataRetrivalFunctions.GetCharacter(cID).NewRelationships[eData.ID].Trust += UnityEngine.Random.Range(0, (speechEffectiveness / 10)); // improve trust slightly with the emperor
                        }

                        if (cData.NewRelationships[cID].RelationshipState == Relationship.eRelationshipState.Rivals || cData.NewRelationships[cID].RelationshipState == Relationship.eRelationshipState.Vendetta)
                        {
                            cData.NewRelationships[cID].Trust -= UnityEngine.Random.Range(0, (speechEffectiveness / 8));
                            HelperFunctions.DataRetrivalFunctions.GetCharacter(cID).NewRelationships[eData.ID].Trust -= UnityEngine.Random.Range(0, (speechEffectiveness / 10)); // distrusts slightly with the emperor
                        }

                        if (cData.NewRelationships[cID].RelationshipState == Relationship.eRelationshipState.Vengeance)
                        {
                            cData.NewRelationships[cID].Trust -= UnityEngine.Random.Range(0, (speechEffectiveness / 6));
                            HelperFunctions.DataRetrivalFunctions.GetCharacter(cID).NewRelationships[eData.ID].Trust -= UnityEngine.Random.Range(0, (speechEffectiveness / 6)); // distrusts a lot with the emperor
                        }
                    }
                }
            }

            // now send to speech engine to create response and return response
            UnityEngine.Debug.Log("Give Praising Speech executed. Speech was " + speechSuccess); // debug code
            string response = ConversationEngine.GenerateResponse(cData, aData, responseIndex, false);

            return(response);
        }