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