Commit 605f8143 authored by Mitchie Maluschnig's avatar Mitchie Maluschnig
Browse files

fixed character interactions and the timers on the dialoue box

parent fb74a2c7
...@@ -486,6 +486,10 @@ Prefab: ...@@ -486,6 +486,10 @@ Prefab:
propertyPath: m_Enabled propertyPath: m_Enabled
value: 0 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 1229012123048104, guid: 9e7fbf1a7c7a84dbc9e793c25c9e722a, type: 2}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: m_RemovedComponents:
- {fileID: 81365263224242478, guid: 9e7fbf1a7c7a84dbc9e793c25c9e722a, type: 2} - {fileID: 81365263224242478, guid: 9e7fbf1a7c7a84dbc9e793c25c9e722a, type: 2}
m_SourcePrefab: {fileID: 100100000, guid: 9e7fbf1a7c7a84dbc9e793c25c9e722a, type: 2} m_SourcePrefab: {fileID: 100100000, guid: 9e7fbf1a7c7a84dbc9e793c25c9e722a, type: 2}
...@@ -6745,6 +6749,10 @@ Prefab: ...@@ -6745,6 +6749,10 @@ Prefab:
propertyPath: m_Enabled propertyPath: m_Enabled
value: 0 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 1703580708648812, guid: 36e15d0d933814ddd8f60f70726d5cdd, type: 2}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: m_RemovedComponents:
- {fileID: 81206696293522424, guid: 36e15d0d933814ddd8f60f70726d5cdd, type: 2} - {fileID: 81206696293522424, guid: 36e15d0d933814ddd8f60f70726d5cdd, type: 2}
m_SourcePrefab: {fileID: 100100000, guid: 36e15d0d933814ddd8f60f70726d5cdd, type: 2} m_SourcePrefab: {fileID: 100100000, guid: 36e15d0d933814ddd8f60f70726d5cdd, type: 2}
......
...@@ -4,21 +4,29 @@ using UnityEngine; ...@@ -4,21 +4,29 @@ using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
public class CharacterInteractions : MonoBehaviour { public class CharacterInteractions : MonoBehaviour {
//Character Speech UI
private GameObject DialogueUI;
public Button interactButton; public Button interactButton;
private Text speechBox;
private GameObject faceCamDisplay;
private Button playerbutton1;
//old speech boxes
public Text secondarySpeechBox; public Text secondarySpeechBox;
//Components
public Character characterScript; public Character characterScript;
private CharacterMovement moveScript;
public Camera faceCam; public Camera faceCam;
private Text speechBox; //utility
private Button playerbutton1;//make these private
private GameObject DialogueUI;
private bool interactable; private bool interactable;
private bool interacting; private bool interacting;
private float proximityTimer; private float proximityTimer;
private float speechBoxTimer; private float speechBoxTimer;
private CharacterMovement moveScript; private bool wasInteracting;//prevents other characters from removing the dialogue box that this character is using
private GameObject faceCamDisplay;
// Use this for initialization // Use this for initialization
void Awake() void Awake()
{ {
...@@ -47,33 +55,30 @@ public class CharacterInteractions : MonoBehaviour { ...@@ -47,33 +55,30 @@ public class CharacterInteractions : MonoBehaviour {
//if player presses up, begin the interaction. //if player presses up, begin the interaction.
if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow)) { if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow)) {
interacting = true; interacting = true;
setText(speechBox, characterScript.GreetingMessage()); setText(speechBox, characterScript.GreetingMessage(), 5);
interactButton.gameObject.SetActive(false); interactButton.gameObject.SetActive(false);
DialogueUI.gameObject.SetActive(true);
updateFaceCamDisplay();
} }
//generate speech every so often while the player is nearby //generate speech every so often while the player is nearby
if (Time.time % 5 < 0.01) { if (Time.time % 5 < 0.01) {
if (Random.Range(0f, 1f) < 0.3) { if (Random.Range(0f, 1f) < 0.3) {
proximityTimer = Time.time; setText(speechBox, characterScript.ProximityMessage(), 2);
setText(secondarySpeechBox, characterScript.ProximityMessage());
} }
} }
//deactivate the secondary box
if (Time.time > proximityTimer + 4) {
secondarySpeechBox.gameObject.SetActive(false);
}
} else {//if the player is currently interacting } else {//if the player is currently interacting
playerbutton1.gameObject.SetActive(true); playerbutton1.gameObject.SetActive(true);
if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow)) { if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow)) {
setText(speechBox, characterScript.converse()); setText(speechBox, characterScript.converse(), 5);
} }
} }
} }
////deactivate the dialogue UI //deactivate the dialogue UI
//if (Time.time > speechBoxTimer + 5) { if (wasInteracting) {
// DialogueUI.gameObject.SetActive(false); if (Time.time > speechBoxTimer) {
//} speechBoxTimer = Time.time + 5;
DialogueUI.gameObject.SetActive(false);
wasInteracting = false;
}
}
} }
//characterMovement script sets this for us when the player //characterMovement script sets this for us when the player
//enters or exits characters range //enters or exits characters range
...@@ -91,26 +96,28 @@ public class CharacterInteractions : MonoBehaviour { ...@@ -91,26 +96,28 @@ public class CharacterInteractions : MonoBehaviour {
interactButton.gameObject.SetActive(true); interactButton.gameObject.SetActive(true);
faceCam.gameObject.SetActive(true); faceCam.gameObject.SetActive(true);
updateFaceCamDisplay(); updateFaceCamDisplay();
DialogueUI.gameObject.SetActive(false);
} }
//player exits characters range //player exits characters range
void exitInteractable(){ void exitInteractable(){
interactButton.gameObject.SetActive(false); interactButton.gameObject.SetActive(false);
faceCam.gameObject.SetActive(false); faceCam.gameObject.SetActive(false);
speechBoxTimer = Time.time;
DialogueUI.gameObject.SetActive(false); DialogueUI.gameObject.SetActive(false);
if (interacting) if (interacting)
{ {
setText(speechBox, characterScript.GoodbyeMessage()); setText(speechBox, characterScript.GoodbyeMessage(), 2);
} }
else{ else{
setText(speechBox, characterScript.butthurtGoodbye()); setText(speechBox, characterScript.butthurtGoodbye(), 2);
} }
interacting = false; interacting = false;
} }
//sets the text of a given text box and sets it to active. //sets the text of a given text box and sets it to active.
void setText(Text box, string text){ void setText(Text box, string text, float uptime){
speechBoxTimer = Time.time; speechBoxTimer = Time.time + uptime;
//box.gameObject.SetActive(true); wasInteracting = true;
DialogueUI.gameObject.SetActive(true);
updateFaceCamDisplay();
box.text = text; box.text = text;
print(text); print(text);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment