Exemplo n.º 1
0
        public void DisplayDialogueNode(string[] nodeArray_)
        {
            currentNodeID = nodeArray_[0];
            string charName = GetSpeakersName(currentNodeID);

            InsertCharName(charName);
            //check if node character override is there and use the override name if so.
            GameObject speakerScrollObj = currentCharSpeaking.gameObject;

            SetCurrentPortraitFromName(charName);
            bool isDialogueNodeVocabTest = (DbCommands.GetCountFromTable("DialogueNodesVocabTests", "NodeIDs = " + currentNodeID) != 0);

            if (isDialogueNodeVocabTest)
            {
                string[] nodeVocabTestArray = DbCommands.GetTupleFromTable("DialogueNodesVocabTests", "NodeIDs = " + currentNodeID);
                string[] vocabArray         = new string[2];
                vocabArray[0] = nodeVocabTestArray[1];
                vocabArray[1] = nodeVocabTestArray[2];
                ProcessDialogueNodeTest(vocabArray);
            }
            else
            {
                InsertDialogueNode(nodeArray_);
                DisplayNodeChoices(currentNodeID);
            }
            ScrollToDialogueElement(speakerScrollObj);
        }
Exemplo n.º 2
0
            public void UpdateTranslation()
            {
                string newEn = englishText.GetComponent <InputField>().text;
                string newCy = welshText.GetComponent <InputField>().text;

                /* We need to check if we are updating a value with more than one entry in translations. If so, a new value needs to be inserted
                 * to English / Welsh tables to avoid changing all of the translation entry values to the same value. This results in the translation
                 * needing to be updated rather than the English / Welsh as would otherwise be updated and the update cascaded.*/
                if (DbCommands.GetCountFromTable("VocabTranslations",
                                                 "EnglishText = " + DbCommands.GetParameterNameFromValue(CurrentEnglish),
                                                 CurrentEnglish)
                    > 1)
                {
                    DbCommands.InsertTupleToTable("EnglishVocab", newEn);
                    DbCommands.UpdateTableField("VocabTranslations",
                                                "EnglishText",
                                                newEn,
                                                "EnglishText = " + DbCommands.GetParameterNameFromValue(CurrentEnglish) +
                                                " AND " +
                                                "WelshText = " + DbCommands.GetParameterNameFromValue(CurrentWelsh),
                                                CurrentEnglish, CurrentWelsh);
                }
                else
                {
                    print("Updating English tbl");
                    DbCommands.UpdateTableField("EnglishVocab",
                                                "EnglishText",
                                                newEn,
                                                "EnglishText = " + DbCommands.GetParameterNameFromValue(CurrentEnglish),
                                                CurrentEnglish);
                    print("success");
                }
                if (DbCommands.GetCountFromTable("VocabTranslations",
                                                 "WelshText = " + DbCommands.GetParameterNameFromValue(CurrentWelsh), CurrentWelsh)
                    > 1)
                {
                    DbCommands.InsertTupleToTable("Welsh", newCy);
                    DbCommands.UpdateTableField("VocabTranslations",
                                                "WelshText",
                                                newCy,
                                                "EnglishText = " + DbCommands.GetParameterNameFromValue(newEn) +
                                                " AND " + //newEn must be used since it will have been update before, rather than simultaneously.
                                                "WelshText = " + DbCommands.GetParameterNameFromValue(CurrentWelsh),
                                                CurrentEnglish, CurrentWelsh);
                }
                else
                {
                    DbCommands.UpdateTableField("WelshVocab",
                                                "WelshText",
                                                newCy,
                                                "WelshText =  " + DbCommands.GetParameterNameFromValue(CurrentWelsh),
                                                CurrentWelsh);
                }
                CurrentEnglish = newEn;
                CurrentWelsh   = newCy;
                grammarListUI.FillRulesNotSelected();
            }
Exemplo n.º 3
0
        private void SetPartCompleted(string partID, GameObject partTransform)
        {
            bool completed = Convert.ToBoolean(DbCommands.GetCountFromTable("CompletedQuestTaskParts", "PartIDs = " + partID + " AND SaveIDs = 0"));

            if (completed)
            {
                print("part complete!");
                partTransform.GetComponent <Text>().color = Colours.colorCompletedQuestTaskPart;
            }
        }
Exemplo n.º 4
0
        public void MarkDialogueComplete(string choiceID)
        {
            bool isDialogueComplete = Convert.ToBoolean(DbCommands.GetCountFromTable("PlayerChoices", "ChoiceIDs = " + choiceID + " AND MarkDialogueCompleted = 1"));

            if (isDialogueComplete)
            {
                int activatedDialogueCount = DbCommands.GetCountFromTable("ActivatedDialogues", "SaveIDs = 0 AND Completed = 0 AND DialogueIDs = " + currentDialogueID);
                if (activatedDialogueCount > 0)
                {
                    DbCommands.UpdateTableField("ActivatedDialogues", "Completed", "1", "SaveIDs = 0 AND DialogueIDs = " + currentDialogueID);
                }
            }
        }
Exemplo n.º 5
0
        private Transform BuildTask(string[] strArray)
        {
            string idStr             = strArray[0];
            string descStr           = strArray[1];
            bool   taskActiveAtStart = Convert.ToBoolean(DbCommands.GetCountFromTable("QuestTasksActivated", "TaskIDs = " + idStr + " AND SaveIDs = -1"));
            Task   task = (Instantiate(TaskPrefab, new Vector2(0f, 0f), Quaternion.identity) as GameObject).GetComponent <Task>();

            task.SetInputText(descStr);
            task.SetActiveAtStartToggle(taskActiveAtStart);
            task.MyID          = idStr;
            task.MyDescription = descStr;

            return(task.transform);
        }
Exemplo n.º 6
0
 public int GetTotalSkillPoints()
 {
     if (totalSkillPoints == -1)
     {
         int writeSkillPoints   = DbCommands.GetCountFromTable("AcquiredVocabWriteSkills", "SaveIDs = 0");
         int readSkillPoints    = DbCommands.GetCountFromTable("AcquiredVocabReadSkills", "SaveIDs = 0");
         int grammarSkillPoints = DbCommands.GetCountFromTable("AcquiredGrammarSkills", "SaveIDs = 0");
         int total = writeSkillPoints + readSkillPoints + grammarSkillPoints;
         return(total);
     }
     else
     {
         return(totalSkillPoints);
     }
 }
Exemplo n.º 7
0
        public void CompleteTaskPart(string partID, string taskID, string questName)
        {
            DbCommands.InsertTupleToTable("CompletedQuestTaskParts", partID, "0");
            //print("inserted tuple to completed task parts");
            int taskPartsCount = DbCommands.GetCountFromTable("QuestTaskParts", "TaskIDs = " + taskID);
            //print("task parts with id " + taskID + " = " + taskPartsCount);
            int taskPartsCompletedCount = DbCommands.GetCountFromQry(DbQueries.GetTaskPartsCompleteFromTaskID(taskID, "0"));

            //print("task parts completed with id " + taskID + " = " + taskPartsCompletedCount);
            //Debugging.PrintDbTable("CompletedQuestTaskParts");
            if (taskPartsCount == taskPartsCompletedCount)
            {
                DbCommands.UpdateTableField("QuestTasksActivated", "Completed", "1", "TaskIDs = " + taskID + " AND SaveIDs = 0");
                int tasksCount = DbCommands.GetCountFromTable(
                    "QuestTasks",
                    "QuestNames = " + DbCommands.GetParameterNameFromValue(questName),
                    questName);
                string[] taskResults = DbCommands.GetTupleFromQry(DbQueries.GetAllTaskResultsQry(taskID));
                //string startDialogueID = DbCommands.GetFieldValueFromTable("QuestTaskStartDialogueResults", "DialogueIDs", "TaskIDs = " + taskID);
                string endCombatWithCharName = taskResults[0];
                string startDialogueID       = taskResults[1];
                if (endCombatWithCharName != "")
                {
                    combatUI.EndCombatWithCharacter(endCombatWithCharName);
                }
                if (startDialogueID != "")
                {
                    print(startDialogueID);
                    DbCommands.InsertTupleToTable("ActivatedDialogues", startDialogueID, "0", "0");
                    dialogueUI.StartNewDialogue(startDialogueID);
                }
                int tasksCompletedCount = DbCommands.GetCountFromQry(
                    DbQueries.GetTasksCompleteFromQuestName(questName, "0"),
                    questName);
                if (tasksCount == tasksCompletedCount)
                {
                    DbCommands.UpdateTableField("QuestsActivated",
                                                "Completed", "1",
                                                "SaveIDs = 0 AND QuestNames = " + DbCommands.GetParameterNameFromValue(questName),
                                                questName);
                }
            }
            SetQuestDetails(questName);
        }
Exemplo n.º 8
0
        private void DisplayNodeChoices(string nodeID)
        {
            InsertSpacer();
            //check if player is node character override, if not then the name can be inserted
            if (GetSpeakersName(nodeID) != playerCharacter.GetMyName())
            {
                InsertCharName(playerCharacter.GetMyName());
            }
            string nodeChoiceQry = "SELECT * FROM PlayerChoices WHERE NodeIDs = " + nodeID + ";";

            AppendDisplayFromDb(nodeChoiceQry, dialogueHolder.transform, BuildPlayerChoice);
            string displayEndDialogueIndicator = (DbCommands.GetFieldValueFromTable("DialogueNodes", "EndDialogueOption", "DialogueIDs = " + nodeID));
            int    choicesInt = DbCommands.GetCountFromTable("PlayerChoices", "NodeIDs = " + nodeID);

            if (displayEndDialogueIndicator == "1" || choicesInt == 0)
            {
                InsertEndDialogue();
            }
        }
Exemplo n.º 9
0
 public void InitialiseMe(string id_, string text_, string nextNode_)
 {
     dialogueUI      = FindObjectOfType <DialogueUI>();
     playerCharacter = FindObjectOfType <PlayerCharacter>();
     myID            = id_;
     myText          = text_;
     myNextNode      = nextNode_;
     isVocabTest     = (DbCommands.GetCountFromTable("PlayerChoicesVocabTests", "ChoiceIDs = " + myID) != 0);
     if (isVocabTest)
     {
         string[] playerChoiceTestArray = DbCommands.GetTupleFromTable("PlayerChoicesVocabTests", "ChoiceIDs = " + myID);
         vocabArray    = new string[2];
         vocabArray[0] = playerChoiceTestArray[1];
         vocabArray[1] = playerChoiceTestArray[2];
         print(vocabArray[0]);
         print(vocabArray[1]);
         TestTrigger testTrigger = new TestTrigger("Translating to Welsh", dialogueUI.DialogueIcon, TestTrigger.TriggerType.DialogueChoice);
         testData = new DialogueTestDataController(testTrigger, vocabArray, DialogueTestDataController.TestType.write, playerCharacter.CharacterName);
     }
     transform.GetComponentInChildren <Text>().text = (isVocabTest) ? "\t" + testData.GetPlayerVocab()[0] : "\t" + myText;
 }
Exemplo n.º 10
0
            /* */
            public void DeleteTranslation()
            {
                string[,] translationFields = new string[, ] {
                    { "EnglishText", CurrentEnglish }, { "WelshText", CurrentWelsh }
                };
                string[,] englishFields = new string[, ] {
                    { "EnglishText", CurrentEnglish }
                };
                string[,] welshFields = new string[, ] {
                    { "WelshText", CurrentWelsh }
                };
                int translationsWithEnglish = DbCommands.GetCountFromTable("VocabTranslations",
                                                                           "EnglishText = " + DbCommands.GetParameterNameFromValue(CurrentEnglish),
                                                                           CurrentEnglish);
                int translationsWithWelsh = DbCommands.GetCountFromTable("VocabTranslations",
                                                                         "WelshText = " + DbCommands.GetParameterNameFromValue(CurrentWelsh),
                                                                         CurrentWelsh);

                if (translationsWithEnglish <= 1 && translationsWithWelsh <= 1)
                {
                    DbCommands.DeleteTupleInTable("EnglishVocab", englishFields);
                    DbCommands.DeleteTupleInTable("WelshVocab", welshFields);
                }
                else if (translationsWithEnglish > 1 && translationsWithWelsh <= 1)
                {
                    DbCommands.DeleteTupleInTable("VocabTranslations", translationFields);
                    DbCommands.DeleteTupleInTable("WelshVocab", welshFields);
                }
                else if (translationsWithEnglish <= 1 && translationsWithWelsh > 1)
                {
                    DbCommands.DeleteTupleInTable("VocabTranslations", translationFields);
                    DbCommands.DeleteTupleInTable("EnglishVocab", englishFields);
                }
                else if (translationsWithEnglish > 1 && translationsWithWelsh > 1)
                {
                    DbCommands.DeleteTupleInTable("VocabTranslations", translationFields);
                }
                Destroy(gameObject);
                grammarListUI.FillRulesNotSelected();
            }
Exemplo n.º 11
0
    private void UpdateWriteSkillPoints()
    {
        WriteProficienciesHandler profienciesHandler = new WriteProficienciesHandler(vocab[0], vocab[1]);
        string writeTallyProficiency;
        int    threshold;

        profienciesHandler.GetProficiencyDetailsFromTally(writeTally, out writeTallyProficiency, out threshold);
        int writeProficiencyAcquired = DbCommands.GetCountFromTable(
            "AcquiredVocabWriteSkills",
            "EnglishText = " + DbCommands.GetParameterNameFromValue(vocab[0]) +
            " AND WelshText = " + DbCommands.GetParameterNameFromValue(vocab[1]) +
            " AND ProficiencyNames = " + DbCommands.GetParameterNameFromValue(writeTallyProficiency) +
            " AND SaveIDs = 0",
            vocab[0],
            vocab[1],
            writeTallyProficiency
            );

        if (writeProficiencyAcquired < 1)
        {
            if (writeTally >= threshold)
            {
                DbCommands.InsertTupleToTable("AcquiredVocabWriteSkills",
                                              vocab[0],
                                              vocab[1],
                                              writeTallyProficiency,
                                              "0");
                skillPointsGainedTotal++;
                vocabSkillIncremented = true;
                if (highestTallyPossible > writeTally)
                {
                    DbCommands.UpdateTableField("DiscoveredVocab", "WriteCorrectTallies", "0",
                                                "SaveIDs = 0 " +
                                                "AND EnglishText = " + DbCommands.GetParameterNameFromValue(vocab[0]) + " " +
                                                "AND WelshText = " + DbCommands.GetParameterNameFromValue(vocab[1]),
                                                vocab[0], vocab[1]);
                }
            }
        }
    }
Exemplo n.º 12
0
 private void UpdateGrammarSkillPoints()
 {
     foreach (KeyValuePair <int, string[]> pair in grammarDetailsDict)
     {
         int    currentTally = int.Parse(pair.Value[0]);
         int    threshold;
         string grammarProficiency;
         GrammarProficienciesHandler grammarProficienciesHandler = new GrammarProficienciesHandler(pair.Key.ToString());
         grammarProficienciesHandler.GetProficiencyDetailsFromTally(currentTally, out grammarProficiency, out threshold);
         int grammarProficiencyAcquired = DbCommands.GetCountFromTable(
             "AcquiredGrammarSkills",
             "RuleIDs = " + pair.Key.ToString() +
             " AND ProficiencyNames = " + DbCommands.GetParameterNameFromValue(grammarProficiency) +
             " AND SaveIDs = 0",
             grammarProficiency);
         if (grammarProficiencyAcquired < 1)
         {
             if (currentTally >= threshold)
             {
                 DbCommands.InsertTupleToTable("AcquiredGrammarSkills",
                                               pair.Key.ToString(),
                                               grammarProficiency,
                                               "0");
                 skillPointsGainedTotal++;
                 pair.Value[1] = "+";
                 if (highestTallyPossible > currentTally)
                 {
                     DbCommands.UpdateTableField("DiscoveredVocabGrammar", "CorrectTallies", "0",
                                                 "SaveIDs = 0 " +
                                                 "AND RuleIDs = " + pair.Key.ToString() +
                                                 ";");
                     pair.Value[0] = "0";
                 }
             }
         }
     }
 }
Exemplo n.º 13
0
        public int GetChoiceResultsCount(string choiceID)
        {
            int countChoiceResults = DbCommands.GetCountFromTable("PlayerChoiceResults", "ChoiceIDs = " + choiceID);

            return(countChoiceResults);
        }
Exemplo n.º 14
0
        public void DisplayResultsRelatedToChoices()
        {
            playerChoiceResultsPanel.SetActive(true);
            EmptyDisplay(playerChoicesResultsList.transform);
            print(playerChoicesListUI);
            playerChoicesListUI = FindObjectOfType <PlayerChoicesListUI>();
            string selectedChoiceID = (playerChoicesListUI.GetSelectedItemFromGroup(playerChoicesListUI.SelectedChoice) as PlayerChoice).MyID;

            if (DbCommands.GetFieldValueFromTable("PlayerChoices", "MarkDialogueCompleted", " ChoiceIDs = " + selectedChoiceID) != "0")
            {
                AppendDisplayFromDb((DbQueries.GetChoiceCompleteDialogueQry(selectedChoiceID)), playerChoicesResultsList.transform, BuildExistingResultCompleteDialogue);
            }
            if (DbCommands.GetFieldValueFromTable("PlayerChoices", "NextNodes", " ChoiceIDs = " + selectedChoiceID) != "")
            {
                GameObject pChoiceResultsTitle = Instantiate(existingResultTitlePrefab, new Vector2(0f, 0f), Quaternion.identity) as GameObject;
                AppendDisplayWithTitle(playerChoicesResultsList.transform, pChoiceResultsTitle.transform, "Goes to dialogue node... ");
                PlayerChoice currentPlayerChoice = playerChoicesListUI.GetSelectedItemFromGroup(playerChoicesListUI.SelectedChoice) as PlayerChoice;
                AppendDisplayFromDb(DbQueries.GetNextNodeResultQry(currentPlayerChoice.MyNextNode), playerChoicesResultsList.transform, BuildExistingResultNode);
            }
            int resultsCount = DbCommands.GetCountFromTable("PlayerChoiceResults", "ChoiceIDs = " + selectedChoiceID);

            if (resultsCount > 0)
            {
                int questActivateCount = DbCommands.GetCountFromQry(DbQueries.GetQuestActivateCountFromChoiceIDqry(selectedChoiceID));
                if (questActivateCount > 0)
                {
                    GameObject existingResultsTitle = Instantiate(existingResultTitlePrefab, new Vector2(0f, 0f), Quaternion.identity) as GameObject;
                    AppendDisplayWithTitle(playerChoicesResultsList.transform, existingResultsTitle.transform, "Activates quest... ");
                    AppendDisplayFromDb(DbQueries.GetCurrentActivateQuestsPlayerChoiceResultQry(selectedChoiceID),
                                        playerChoicesResultsList.transform,
                                        BuildExistingResultActivateQuest);
                }

                int taskActivateCount = DbCommands.GetCountFromQry(DbQueries.GetTaskActivateCountFromChoiceIDqry(selectedChoiceID));
                if (taskActivateCount > 0)
                {
                    GameObject existingResultsTitle = Instantiate(existingResultTitlePrefab, new Vector2(0f, 0f), Quaternion.identity) as GameObject;
                    AppendDisplayWithTitle(playerChoicesResultsList.transform, existingResultsTitle.transform, "Activates tasks... ");
                    AppendDisplayFromDb(DbQueries.GetCurrentActivateTasksPlayerChoiceResultQry(selectedChoiceID),
                                        playerChoicesResultsList.transform,
                                        BuildExistingResultActivateTask);
                }

                int taskCompleteCount = DbCommands.GetCountFromQry(DbQueries.GetTaskCompleteCountFromChoiceIDqry(selectedChoiceID));
                if (taskCompleteCount > 0)
                {
                    GameObject existingResultsTitle = Instantiate(existingResultTitlePrefab, new Vector2(0f, 0f), Quaternion.identity) as GameObject;
                    AppendDisplayWithTitle(playerChoicesResultsList.transform, existingResultsTitle.transform, "Completes tasks... ");
                    AppendDisplayFromDb(DbQueries.GetCurrentCompleteTasksPlayerChoiceResultQry(selectedChoiceID),
                                        playerChoicesResultsList.transform,
                                        BuildExistingResultCompleteTask);
                }

                int grammarActivateCount = DbCommands.GetCountFromQry(DbQueries.GetGrammarActivateCountFromChoiceIDqry(selectedChoiceID));
                if (grammarActivateCount > 0)
                {
                    GameObject existingResultsTitle = Instantiate(existingResultTitlePrefab, new Vector2(0f, 0f), Quaternion.identity) as GameObject;
                    AppendDisplayWithTitle(playerChoicesResultsList.transform, existingResultsTitle.transform, "Activates new grammar... ");
                    AppendDisplayFromDb(DbQueries.GetCurrentActivateGrammarPlayerChoiceResultQry(selectedChoiceID),
                                        playerChoicesResultsList.transform,
                                        BuildExistingResultActivateGrammar);
                }

                int vocabActivateCount = DbCommands.GetCountFromQry(DbQueries.GetVocabActivateCountFromChoiceIDqry(selectedChoiceID));
                if (vocabActivateCount > 0)
                {
                    GameObject existingResultsTitle = Instantiate(existingResultTitlePrefab, new Vector2(0f, 0f), Quaternion.identity) as GameObject;
                    AppendDisplayWithTitle(playerChoicesResultsList.transform, existingResultsTitle.transform, "Activates new vocab... ");
                    AppendDisplayFromDb(DbQueries.GetCurrentActivateVocabPlayerChoiceResultQry(selectedChoiceID),
                                        playerChoicesResultsList.transform,
                                        BuildExistingResultActivateVocab);
                }

                int dialogueActivateCount = DbCommands.GetCountFromQry(DbQueries.GetDialogueActivateCountFromChoiceIDqry(selectedChoiceID));
                if (dialogueActivateCount > 0)
                {
                    GameObject existingResultsTitle = Instantiate(existingResultTitlePrefab, new Vector2(0f, 0f), Quaternion.identity) as GameObject;
                    AppendDisplayWithTitle(playerChoicesResultsList.transform, existingResultsTitle.transform, "Activates new dialogue(s)... ");
                    AppendDisplayFromDb(DbQueries.GetCurrentActivateDialoguePlayerChoiceResultQry(selectedChoiceID),
                                        playerChoicesResultsList.transform,
                                        BuildExistingResultActivateDialogue);
                }
            }
        }