public void ShowQuestsCommon() { //Debug.Log("QuestTrackerUI.ShowQuestsCommon()"); if (PlayerManager.MyInstance != null && PlayerManager.MyInstance.PlayerUnitSpawned == false) { // shouldn't be doing anything without a player spawned. return; } ClearQuests(); foreach (Quest quest in QuestLog.MyInstance.MyQuests.Values) { //Debug.Log("QuestTrackerUI.ShowQuestsCommon(): quest: " + quest); GameObject go = Instantiate(questPrefab, questParent); QuestTrackerQuestScript qs = go.GetComponent <QuestTrackerQuestScript>(); qs.MyQuest = quest; if (qs == null) { //Debug.Log("QuestTrackerUI.ShowQuestsCommon(): QuestGiverQuestScript is null"); } qs.MyText.text = "[" + quest.MyExperienceLevel + "] " + quest.DisplayName; if (quest.IsComplete) { qs.MyText.text += " (Complete)"; } string objectives = string.Empty; qs.MyText.text += "\n<size=12>" + quest.GetUnformattedObjectiveList() + "</size>"; //Debug.Log("QuestTrackerUI.ShowQuestsCommon(" + questGiver.name + "): " + questNode.MyQuest.MyTitle); qs.MyText.color = LevelEquations.GetTargetColor(PlayerManager.MyInstance.MyCharacter.CharacterStats.Level, quest.MyExperienceLevel); //quests.Add(go); questScripts.Add(qs); } }
public void IsComplete() { //Debug.Log("Checking questscript iscomplete on myquest: " + MyQuest.MyTitle); if (MyQuest.IsComplete && !markedComplete) { markedComplete = true; //Debug.Log("the quest is complete"); MyText.text = "[" + MyQuest.MyExperienceLevel + "] " + MyQuest.MyName + " (Complete)"; } else if (!MyQuest.IsComplete) { markedComplete = false; MyText.text = "[" + MyQuest.MyExperienceLevel + "] " + MyQuest.MyName; } MyText.color = LevelEquations.GetTargetColor(PlayerManager.MyInstance.MyCharacter.MyCharacterStats.MyLevel, MyQuest.MyExperienceLevel); }
public void ShowInteractablesCommon(Interactable interactable, bool suppressAutoInteract = false) { //Debug.Log("InteractionPanelUI.ShowInteractablesCommon(" + interactable.name + ")"); ClearButtons(); // updated to only use valid interactables if (playerManager.PlayerUnitSpawned == false) { //Debug.Log("InteractionPanelUI.ShowInteractablesCommon(" + interactable.name + ") player unit is null"); return; } List <InteractableOptionComponent> currentInteractables = interactable.GetCurrentInteractables(); if (currentInteractables.Count == 0) { // this could have been a refresh from while a quest was open overtop. close it if there are no valid interactables uIManager.interactionWindow.CloseWindow(); return; } // going to just pop the first available interaction window for now and see how that feels //bool optionOpened = false; foreach (InteractableOptionComponent _interactable in currentInteractables) { // handle questgiver if (_interactable is QuestGiverComponent) { foreach (QuestNode questNode in (_interactable as QuestGiverComponent).Props.Quests) { Quest quest = questNode.Quest; if (quest != null) { string displayText = string.Empty; string questStatus = quest.GetStatus(); if (questStatus == "complete" && questNode.EndQuest == true) { displayText = "<color=yellow>?</color> "; } else if (questNode.StartQuest == true && questStatus == "available") { displayText = "<color=yellow>!</color> "; } // only display complete and available quests here if (displayText != string.Empty) { GameObject go = objectPooler.GetPooledObject(questPrefab, availableQuestArea.transform); InteractionPanelQuestScript qs = go.GetComponent <InteractionPanelQuestScript>(); qs.Configure(systemGameManager); qs.Quest = quest; qs.QuestGiver = (_interactable as QuestGiverComponent); displayText += quest.DisplayName; qs.Text.text = displayText; //Debug.Log("QuestTrackerUI.ShowQuestsCommon(" + questGiver.name + "): " + questNode.MyQuest.MyTitle); qs.Text.color = LevelEquations.GetTargetColor(playerManager.MyCharacter.CharacterStats.Level, quest.ExperienceLevel); questScripts.Add(qs); // disabled this next bit because it was causing repeatables with no objectives to be marked as complete /* * if (quest.IsComplete && !quest.TurnedIn) { * go.transform.SetParent(completeQuestArea.transform); * } else if (!quest.IsComplete && questLog.HasQuest(quest.DisplayName) == false) { * go.transform.SetParent(availableQuestArea.transform); * } */ } } } } else { // this block used to be outside the else statement, but for now we don't want quests to show as an interaction option because they are handled separately above // handle generic stuff if (_interactable.DisplayName != null && _interactable.DisplayName != string.Empty && _interactable.GetCurrentOptionCount() > 0) { //Debug.Log("InteractionPanelUI.ShowInteractablesCommon(" + interactable.name + "): Instantiating button"); for (int i = 0; i < _interactable.GetCurrentOptionCount(); i++) { GameObject go = objectPooler.GetPooledObject(interactableButtonPrefab, interactableButtonParent); InteractionPanelScript iPS = go.GetComponent <InteractionPanelScript>(); if (iPS != null) { iPS.Configure(systemGameManager); iPS.Setup(_interactable, i); interactionPanelScripts.Add(iPS); } } } } } foreach (InteractionPanelQuestScript questScript in questScripts) { uINavigationControllers[0].AddActiveButton(questScript); } foreach (InteractionPanelScript interactionPanelScript in interactionPanelScripts) { uINavigationControllers[0].AddActiveButton(interactionPanelScript); } uINavigationControllers[0].FocusFirstButton(); if (uIManager.dialogWindow.IsOpen) { //Debug.Log("InteractionPanelUI.ShowInteractablesCommon(" + interactable.name + "): Dialog Window is open, returning to prevent other windows from popping"); // if we are mid dialog, we don't want to pop another window yet return; } // priority open - any other current interactable third, but only if there is one if (currentInteractables.Count > 1 || suppressAutoInteract == true || uINavigationControllers[0].ActiveNavigableButtonCount > 1) { //Debug.Log("InteractionPanelUI.Interact(): currentInteractables count: " + currentInteractables.Count); return; } // priority open - completed quest first foreach (InteractionPanelQuestScript questScript in questScripts) { //Debug.Log("InteractionPanelUI.ShowInteractablesCommon(" + interactable.name + "): Checking questScript for complete quest"); if (questScript.Quest.MarkedComplete) { //Debug.Log("InteractionPanelUI.ShowInteractablesCommon(" + interactable.name + "): Checking questScript: quest is complete, selecting"); questScript.Interact(); //optionOpened = true; return; } } // priority open - available quest second foreach (InteractionPanelQuestScript questScript in questScripts) { //Debug.Log("InteractionPanelUI.ShowInteractablesCommon(" + interactable.name + "): Checking questScript for available quest"); if (questScript.Quest.GetStatus() == "available") { //Debug.Log("InteractionPanelUI.ShowInteractablesCommon(" + interactable.name + "): Checking questScript: quest is available, selecting"); questScript.Interact(); //optionOpened = true; return; } } foreach (InteractionPanelScript interactionPanelScript in interactionPanelScripts) { //Debug.Log("InteractionPanelUI.ShowInteractablesCommon(" + interactable.name + "): Checking interaction Panel Script"); if (interactionPanelScript.InteractableOption.CanInteract() && interactionPanelScript.InteractableOption.GetCurrentOptionCount() == 1) { //Debug.Log("InteractionPanelUI.ShowInteractablesCommon(" + interactable.name + "): Checking interaction Panel Script: canInteract is TRUE!!!"); interactionPanelScript.InteractableOption.Interact(playerManager.UnitController.CharacterUnit); //optionOpened = true; return; } } }