Commit 01edf6c6 authored by Mitchie Maluschnig's avatar Mitchie Maluschnig
Browse files

player responses are now spaced nicely

parent 87349629
......@@ -24,7 +24,6 @@ public class CharacterInteractions : MonoBehaviour {
//utility
private bool interactable;
private bool interacting;
private float proximityTimer;
private float speechBoxTimer;
private bool wasInteracting;//prevents other characters from removing the dialogue box that this character is using
......@@ -57,18 +56,18 @@ 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(), 5, testReplies);
setText(speechBox, characterScript.GreetingMessage(), 5, characterScript.getResponses());
interactButton.gameObject.SetActive(false);
}
//generate speech every so often while the player is nearby
if (Time.time % 5 < 0.01) {
if (Random.Range(0f, 1f) < 0.3) {
setText(speechBox, characterScript.ProximityMessage(), 2, testReplies);
setText(speechBox, characterScript.ProximityMessage(), 2, characterScript.getResponses());
}
}
} else {//if the player is currently interacting
if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow)) {
setText(speechBox, characterScript.converse(), 5, testReplies);
setText(speechBox, characterScript.converse(), 5, characterScript.getResponses());
}
}
}
......@@ -106,10 +105,10 @@ public class CharacterInteractions : MonoBehaviour {
DialogueUI.gameObject.SetActive(false);
if (interacting)
{
setText(speechBox, characterScript.GoodbyeMessage(), 2, testReplies);
setText(speechBox, characterScript.GoodbyeMessage(), 2, characterScript.getResponses());
}
else{
setText(speechBox, characterScript.butthurtGoodbye(), 2, testReplies);
setText(speechBox, characterScript.butthurtGoodbye(), 2, characterScript.getResponses());
}
interacting = false;
}
......@@ -122,8 +121,24 @@ public class CharacterInteractions : MonoBehaviour {
box.text = text;
print(text);
//setting player reply options
for (int i = 0; i < replies.Length; i++) {
for (int i = 0; i < playerResponses.Length; i++) {
//find spacing to arrange buttons
float spacing = responsePanel.rectTransform.rect.width / (replies.Length + 1);
print("spacing" + spacing);
//set the text on the reply buttons
if (i < replies.Length) {
//arrange buttons
Vector2 newPos = playerResponses[i].GetComponent<RectTransform>().localPosition;
float panelEdge = responsePanel.rectTransform.rect.xMin;
newPos.x = panelEdge + (spacing * (i+1));
playerResponses[i].GetComponent<RectTransform>().localPosition = newPos;
playerResponses[i].gameObject.SetActive(true);
playerResponses[i].GetComponentInChildren<Text>().text = replies[i];
} else {
playerResponses[i].gameObject.SetActive(false);
}
}
}
......@@ -140,6 +155,8 @@ public class CharacterInteractions : MonoBehaviour {
}
}
public void ButtonPress() {
setText(speechBox, characterScript.converse(), 5, testReplies);
if (interacting) {
setText(speechBox, characterScript.converse(), 5, characterScript.getResponses());
}
}
}
......@@ -6,23 +6,31 @@ using UnityEngine;
public class AhavaSpeech : MonoBehaviour, Character {
private Queue<string> conversation = new Queue<string>();
private Queue<string[]> responseQueue = new Queue<string[]>();
private string[] currentResponses;
public string GreetingMessage(){
loadConversation();
currentResponses = new string[] { "Hi there", "Who are you", "what is this place" };
return "Hello Player, I am Ahava";
}
public string GoodbyeMessage(){
currentResponses = new string[] {};
return "See you soon!";
}
public string ProximityMessage(){
currentResponses = new string[] {};
return "My beard sense is tingling...";
}
public string butthurtGoodbye(){
currentResponses = new string[] {};
return "Didnt want to admire my glorious beard?";
}
public string nothingMoreToSay() {
currentResponses = new string[] { };
if (Random.Range(0, 1f) < 0.8) {
return "my beard grows tired of your chitter chatter";
} else {
......@@ -32,6 +40,7 @@ public class AhavaSpeech : MonoBehaviour, Character {
public string converse() {
if (conversation.Count > 0) {
currentResponses = responseQueue.Dequeue();
return conversation.Dequeue();
} else {
return nothingMoreToSay();
......@@ -40,11 +49,28 @@ public class AhavaSpeech : MonoBehaviour, Character {
private void loadConversation() {
conversation.Clear();
responseQueue.Clear();
conversation.Enqueue("welcome to the circus");
responseQueue.Enqueue(new string[] { "response 1"});
conversation.Enqueue("line 2");
responseQueue.Enqueue(new string[] { "response 2", "response 2" });
conversation.Enqueue("line 3");
responseQueue.Enqueue(new string[] { "response 3", "response 3", "response 3" });
conversation.Enqueue("line 4");
responseQueue.Enqueue(new string[] { "response 4", "response 4" });
conversation.Enqueue("line 5");
responseQueue.Enqueue(new string[] { "response 5", "response 5", "response 5" });
conversation.Enqueue("line 6");
responseQueue.Enqueue(new string[] { "response 6" });
}
public string[] getResponses() {
return currentResponses;
}
}
......@@ -11,4 +11,6 @@ public interface Character {
string ProximityMessage();
string converse();
string[] getResponses();
}
......@@ -7,8 +7,11 @@ public class SilasSpeech : MonoBehaviour, Character {
private Queue<string> conversation = new Queue<string>();
private string[] currentResponses;
public string GreetingMessage(){
loadConversation();
currentResponses = new string[] { "Hi there", "Who are you", "what is this place" };
return "...";
}
public string GoodbyeMessage(){
......@@ -56,4 +59,8 @@ public class SilasSpeech : MonoBehaviour, Character {
conversation.Enqueue("...well its mostly just me talking about it but they say its the best");
conversation.Enqueue("...well i say its the best");
}
public string[] getResponses() {
return currentResponses;
}
}
......@@ -7,8 +7,11 @@ public class SimonSpeech : MonoBehaviour, Character {
private Queue<string> conversation = new Queue<string>();
private string[] currentResponses;
public string GreetingMessage(){
loadConversation();
currentResponses = new string[] { "Hi there", "Who are you", "what is this place" };
return "(happy) grr";
}
public string GoodbyeMessage(){
......@@ -47,4 +50,8 @@ public class SimonSpeech : MonoBehaviour, Character {
conversation.Enqueue("GRR");
conversation.Enqueue("grr");
}
public string[] getResponses() {
return currentResponses;
}
}
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