private void OnTriggerEnter(Collider collider) { //Debug.Log(interactable.gameObject.name + ".InteractableRange.OnTriggerEnter(" + collider.gameObject.name + ") count : " + inRangeColliders.Count); if (collider.gameObject == playerManager.ActiveUnitController.gameObject && inRangeColliders.Contains(collider.gameObject) == false) { inRangeColliders.Add(collider.gameObject); if (interactable.PrerequisitesMet == false || interactable.GetCurrentInteractables().Count == 0) { return; } playerManager.PlayerController.AddInteractable(interactable); } }
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; } } }