private void AvaliableQuest() { if (QuestDetected() && questSystem.haveActiveQuest == false) { StuffToSayThisFrame += "Press E to take quest\n"; if (Input.GetButtonDown("Fire1")) { foreach (Collider2D i in QuestHitResults) { if (i.CompareTag("Quest")) { questSystem.RetreiveQuest(i.name); i.gameObject.SetActive(false); } } } } else if (InteractableDetected() && InteractableTimer == 0) { foreach (Collider2D i in InteractableHitResults) { if (Input.GetButtonDown("Fire1")) { Interactiables thing = i.GetComponentInParent <Interactiables>(); InteractableTimer = 100; thing.giveprompt(); } else { StuffToSayThisFrame += "Press E to interact with " + i.name + "\n"; break; } } } else { speech.text = ""; } }
private void SenseAround() { if (FreezePlayer)//don't let the player look for more things to do while they're busy doing something else { return; } if (QuestDetected() && questSystem.haveActiveQuest == false) { StuffToSayThisFrame += "Press E to take quest\n"; if (Input.GetButtonDown("Fire1")) { FreezePlayer = true; foreach (Collider2D i in QuestHitResults) { if (!i) //null reference exceptions were being thrown because looping through every collider in QuestHitResults was also returning a null object in addition to the quest { //this skips over any of those null results continue; } if (i.CompareTag("Quest")) { questSystem.RetreiveQuest(i.name); i.gameObject.SetActive(false); } } } } else { speech.text = ""; } if (InteractableDetected() && InteractableTimer == 0) { foreach (Collider2D i in InteractableHitResults) { if (!i) { continue; } if (Input.GetButtonDown("Fire1")) { Interactiables thing = i.GetComponentInParent <Interactiables>(); InteractableTimer = 100; FreezePlayer = true; thing.giveprompt(); } else { StuffToSayThisFrame += "Press E to interact with " + i.name + "\n"; break; } } } if (MinigameDetected()) { foreach (Collider2D i in MinigameHitResults) { if (!i) { continue; } if (Input.GetButtonDown("Fire1")) { i.GetComponent <NPCScript>().TalkToNPC(); } } } if (FireDetected()) { //StuffToSayThisFrame += "Press E put out fire \n"; if (Input.GetButtonDown("Fire1")) { FireHitResults[0].GetComponentInParent <FireBehavior>().ReduceFire(); } } }