public void StartQuest(TopDownUIDialog dialog) { if (questHub != null && questState != QuestState.Started && questFinished == false) { this.enabled = true; if (dialog != null) { questGiverDialog = dialog; } else { Debug.LogError("You must assign TopDownUIDialog component of quest giver to the dialog event action that fires the StartQuest function of quest: " + questName); } questState = QuestState.Started; questHub.startedQuests.Add(this); questHub.activeQuest = this; uiManager.questLog.GetComponent <TopDownRpgQuestLog>().UpdateQuestList(); questStartEvents.Invoke(); //SOME NOTIFICATION THAT QUEST STARTED uiManager.notificationText.GetComponent <TopDownUIShowNotification>().ShowNotification("Quest Started \n''" + questName + "''"); } }
public void ClearDialog() { if (cameraBasic.td_Target.name == "TempCameraBetweenPosition") { Destroy(cameraBasic.td_Target.gameObject); } cameraBasic.td_Target = TopDownCharacterManager.instance.controllingCharacter.transform; cameraBasic.cameraFreeze = false; dialogChoices[0].dialogTxt.text = string.Empty; for (int i = 0; i < dialogChoices.Length; i++) { dialogChoices[i].GetComponent <Button>().interactable = false; dialogChoices[i].GetComponentInChildren <Text>().text = string.Empty; } if (dialogInUse != null) { if (dialogInUse.choiceOne != string.Empty) { dialogInUse.numberOfChoices = 1; } else { dialogInUse = null; return; } if (dialogInUse.choiceTwo != string.Empty) { dialogInUse.numberOfChoices = 2; } else { dialogInUse = null; return; } if (dialogInUse.choiceThree != string.Empty) { dialogInUse.numberOfChoices = 3; } else { dialogInUse = null; return; } if (dialogInUse.choiceFour != string.Empty) { dialogInUse.numberOfChoices = 4; } else { dialogInUse = null; return; } dialogInUse = null; } }
public void OnEnable() { td_target = (TopDownUIDialog)target; if (TopDownIcon == null) { TopDownIcon = Resources.Load("TopDownIcon") as Texture; } }
/// <summary> /// Used to add new dialog choices. /// </summary> /// <param name="dialog">Dialog that we are adding choice to.</param> /// <param name="choiceText">Text in the choice button.</param> /// <param name="dialogText">Text in the dialog box when choice is activated.</param> /// <param name="dialogChoiceType">What type of dialog choice this is?</param> /// <param name="choicePosition">Position of choice in the choices list. It can be at Top or at Bottom. If there is four choices already if on Top the last one will be removed and if on Bottom the first one will be removed.</param> public void AddNewChoice(TopDownRpgQuest quest, TopDownUIDialog dialog, string choiceText, string dialogText, DialogType dialogChoiceType, ChoicePosition choicePosition) { if (choicePosition == ChoicePosition.Top) { for (int i = dialog.numberOfChoices; i > 0; i--) { if (i == 4) { dialog.choiceFour = dialog.choiceThree; dialog.choiceFourDialog = dialog.choiceThreeDialog; dialog.choiceFourType = dialog.choiceThreeType; dialog.removeOnChoiceFour = dialog.removeOnChoiceThree; dialog.branchFourDialog = dialog.branchThreeDialog; dialog.typeFourResponse = dialog.typeThreeResponse; dialog.choiceFourEvent = dialog.choiceThreeEvent; } if (i == 3) { dialog.choiceThree = dialog.choiceTwo; dialog.choiceThreeDialog = dialog.choiceTwoDialog; dialog.choiceThreeType = dialog.choiceTwoType; dialog.removeOnChoiceThree = dialog.removeOnChoiceTwo; dialog.branchThreeDialog = dialog.branchTwoDialog; dialog.typeThreeResponse = dialog.typeTwoResponse; dialog.choiceThreeEvent = dialog.choiceTwoEvent; } if (i == 2) { dialog.choiceTwo = dialog.choiceOne; dialog.choiceTwoDialog = dialog.choiceOneDialog; dialog.choiceTwoType = dialog.choiceOneType; dialog.removeOnChoiceTwo = dialog.removeOnChoiceOne; dialog.branchTwoDialog = dialog.branchOneDialog; dialog.typeTwoResponse = dialog.typeOneResponse; dialog.choiceTwoEvent = dialog.choiceOneEvent; } if (i == 1) { dialog.choiceOne = choiceText; dialog.choiceOneDialog = dialogText; dialog.choiceOneType = dialogChoiceType; dialog.removeOnChoiceOne = true; dialog.branchOneDialog = null; dialog.typeOneResponse = string.Empty; dialog.choiceOneEvent = null; if (quest == null) { print("No quest"); } dialog.choiceOneEvent = quest.questFinishEvents; } } return; } }
public void CheckQuestStatus() { if (questType == QuestType.KillTargets) { if (questTargetsCards.Count > 0) { for (int i = 0; i < questTargetsCards.Count; i++) { if (questTargetsCards[i] == null) { questTargets.RemoveAt(i); questTargetsCards.RemoveAt(i); } } } else { //All targets killed, return to quest giver and report if (questEnding == QuestEnding.ReturnToNpc) { if (questGiverDialog != null) { TopDownUIDialogMain.instance.AddNewChoice(this, questGiverDialog, questFinishChoice, questFinishDialog, questFinishDialogType, TopDownUIDialogMain.ChoicePosition.Top); questGiverDialog = null; } } else if (questEnding == QuestEnding.EndInPlace) { FinishQuest(); } } } else if (questType == QuestType.TalkToNpc) { } else if (questType == QuestType.GoToLocation) { float dist = Vector3.Distance(TopDownCharacterManager.instance.controllingCharacter.transform.position, questTarget.transform.position); if (dist <= 4) { if (questEnding == QuestEnding.ReturnToNpc) { if (questGiverDialog != null) { TopDownUIDialogMain.instance.AddNewChoice(this, questGiverDialog, questFinishChoice, questFinishDialog, questFinishDialogType, TopDownUIDialogMain.ChoicePosition.Top); questGiverDialog = null; } } else if (questEnding == QuestEnding.EndInPlace) { } } } }
public void ShowChoiceDialog() { TopDownUIDialog dialogInUse = dialogMain.dialogInUse; dialogTxt.text = dialog; if (events != null) { events.Invoke(); } switch (type) { case DialogType.BranchDialog: StartCoroutine(SetupBranchingDialog()); break; case DialogType.CloseDialog: TopDownUIDialogMain.instance.CloseDialogPerType("[Exit]"); break; case DialogType.ImmediateClose: CloseTheDialog(); break; case DialogType.CombatDialog: if (dialogInUse.GetComponent <TopDownAI>()) { dialogInUse.GetComponent <TopDownAI>().TurnHostile(); } CloseTheDialog(); break; default: if (remove == true) { TopDownUIDialogChoice[] choice = dialogMain.dialogChoices; for (int i = 0; i < choice.Length; i++) { if ((i + 1) >= index) { if ((i + 1) < choice.Length) { if (choice[i + 1].GetComponent <Button>().interactable == true) { choice[i].GetComponent <Button>().interactable = choice[i + 1].GetComponent <Button>().interactable; choice[i].choiceTxt.text = choice[i + 1].choiceTxt.text; choice[i].dialog = choice[i + 1].dialog; choice[i].type = choice[i + 1].type; choice[i].remove = choice[i + 1].remove; choice[i].branch = choice[i + 1].branch; choice[i].response = choice[i + 1].response; choice[i].events = choice[i + 1].events; choice[i + 1].GetComponent <Button>().interactable = false; choice[i + 1].choiceTxt.text = string.Empty; choice[i + 1].dialog = string.Empty; choice[i + 1].type = DialogType.None; choice[i + 1].remove = false; choice[i + 1].branch = null; choice[i + 1].response = string.Empty; choice[i + 1].events = null; switch (i) { case 0: dialogInUse.choiceOne = choice[i].choiceTxt.text; dialogInUse.choiceOneDialog = choice[i].dialog; dialogInUse.choiceOneType = choice[i].type; dialogInUse.removeOnChoiceOne = choice[i].remove; dialogInUse.branchOneDialog = choice[i].branch; dialogInUse.typeOneResponse = choice[i].response; dialogInUse.choiceOneEvent = choice[i].events; dialogInUse.choiceTwo = string.Empty; dialogInUse.choiceTwoDialog = string.Empty; dialogInUse.choiceTwoType = DialogType.None; dialogInUse.removeOnChoiceTwo = false; dialogInUse.branchTwoDialog = choice[i].branch; dialogInUse.typeTwoResponse = string.Empty; dialogInUse.choiceTwoEvent = null; break; case 1: dialogInUse.choiceTwo = choice[i].choiceTxt.text; dialogInUse.choiceTwoDialog = choice[i].dialog; dialogInUse.choiceTwoType = choice[i].type; dialogInUse.removeOnChoiceTwo = choice[i].remove; dialogInUse.branchTwoDialog = choice[i].branch; dialogInUse.typeTwoResponse = choice[i].response; dialogInUse.choiceTwoEvent = choice[i].events; dialogInUse.choiceThree = string.Empty; dialogInUse.choiceThreeDialog = string.Empty; dialogInUse.choiceThreeType = DialogType.None; dialogInUse.removeOnChoiceThree = false; dialogInUse.branchThreeDialog = choice[i].branch; dialogInUse.typeThreeResponse = string.Empty; dialogInUse.choiceThreeEvent = null; break; case 2: dialogInUse.choiceThree = choice[i].choiceTxt.text; dialogInUse.choiceThreeDialog = choice[i].dialog; dialogInUse.choiceThreeType = choice[i].type; dialogInUse.removeOnChoiceThree = choice[i].remove; dialogInUse.branchThreeDialog = choice[i].branch; dialogInUse.typeThreeResponse = choice[i].response; dialogInUse.choiceThreeEvent = choice[i].events; dialogInUse.choiceFour = string.Empty; dialogInUse.choiceFourDialog = string.Empty; dialogInUse.choiceFourType = DialogType.None; dialogInUse.removeOnChoiceFour = false; dialogInUse.branchFourDialog = choice[i].branch; dialogInUse.typeFourResponse = string.Empty; dialogInUse.choiceFourEvent = null; break; case 3: dialogInUse.choiceFour = string.Empty; dialogInUse.choiceFourDialog = string.Empty; dialogInUse.choiceFourType = DialogType.None; dialogInUse.removeOnChoiceFour = false; dialogInUse.branchFourDialog = choice[i].branch; dialogInUse.typeFourResponse = string.Empty; dialogInUse.choiceFourEvent = null; dialogInUse.choiceFour = string.Empty; break; /*case 4: * dialogInUse.choiceFour = string.Empty; * dialogInUse.choiceFourDialog = string.Empty; * dialogInUse.choiceFourType = DialogType.None; * dialogInUse.removeOnChoiceFour = false; * dialogInUse.branchFourDialog = choice[i].branch; * dialogInUse.typeFourResponse = string.Empty; * dialogInUse.choiceFourEvent = null; * break;*/ } } } } } } break; } }
public void ShowDialog(TopDownUIDialog dialog) { if (dialog != null) { dialogInUse = dialog; cameraBasic.td_Target = dialog.transform; Quaternion npcRotation = Quaternion.LookRotation(TopDownCharacterManager.instance.controllingCharacter.transform.position - dialog.transform.position); dialog.transform.rotation = Quaternion.Slerp(transform.rotation, npcRotation, Time.deltaTime * 600f); Quaternion playerRotation = Quaternion.LookRotation(dialog.transform.position - TopDownCharacterManager.instance.controllingCharacter.transform.position); TopDownCharacterManager.instance.controllingCharacter.transform.rotation = Quaternion.Slerp(TopDownCharacterManager.instance.controllingCharacter.transform.rotation, playerRotation, Time.deltaTime * 600f); StartCoroutine(SetCameraPosition()); dialogChoices[0].dialogTxt.text = dialog.welcomeDialog; for (int i = 0; i < dialogChoices.Length; i++) { if (i < dialog.numberOfChoices) { if (i == 0) { dialogChoices[i].GetComponent <Button>().interactable = true; dialogChoices[i].choiceTxt.text = dialog.choiceOne; dialogChoices[i].dialog = dialog.choiceOneDialog; dialogChoices[i].type = dialog.choiceOneType; dialogChoices[i].remove = dialog.removeOnChoiceOne; dialogChoices[i].branch = dialog.branchOneDialog; dialogChoices[i].response = dialog.typeOneResponse; dialogChoices[i].events = dialog.choiceOneEvent; dialogChoices[i].index = i; } if (i == 1) { dialogChoices[i].GetComponent <Button>().interactable = true; dialogChoices[i].choiceTxt.text = dialog.choiceTwo; dialogChoices[i].dialog = dialog.choiceTwoDialog; dialogChoices[i].type = dialog.choiceTwoType; dialogChoices[i].remove = dialog.removeOnChoiceTwo; dialogChoices[i].branch = dialog.branchTwoDialog; dialogChoices[i].response = dialog.typeTwoResponse; dialogChoices[i].events = dialog.choiceTwoEvent; dialogChoices[i].index = 2; } if (i == 2) { dialogChoices[i].GetComponent <Button>().interactable = true; dialogChoices[i].choiceTxt.text = dialog.choiceThree; dialogChoices[i].dialog = dialog.choiceThreeDialog; dialogChoices[i].type = dialog.choiceThreeType; dialogChoices[i].remove = dialog.removeOnChoiceThree; dialogChoices[i].branch = dialog.branchThreeDialog; dialogChoices[i].response = dialog.typeThreeResponse; dialogChoices[i].events = dialog.choiceThreeEvent; dialogChoices[i].index = 3; } if (i == 3) { dialogChoices[i].GetComponent <Button>().interactable = true; dialogChoices[i].choiceTxt.text = dialog.choiceFour; dialogChoices[i].dialog = dialog.choiceFourDialog; dialogChoices[i].type = dialog.choiceFourType; dialogChoices[i].remove = dialog.removeOnChoiceFour; dialogChoices[i].branch = dialog.branchFourDialog; dialogChoices[i].response = dialog.typeFourResponse; dialogChoices[i].events = dialog.choiceFourEvent; dialogChoices[i].index = 4; } } else { dialogChoices[i].GetComponent <Button>().interactable = false; dialogChoices[i].choiceTxt.text = string.Empty; dialogChoices[i].index = 0; } } } }