Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Project/Assets/Vendor/Badges/BadgeStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ public class BadgeStore {
public void Add(string name, string label, string path){
if(!badges.ContainsKey(name))
{
badges.Add(name, new BadgeInfo(label, path));
badges.Add(name, new BadgeInfo(name, label, path));
names.Add(name);
}
}

public void Replace(string name, string new_name, string label, string path){
if(badges.ContainsKey(name))
{
badges.Add(new_name, new BadgeInfo(label, path));
badges.Add(new_name, new BadgeInfo(name, label, path));

badges.Remove(name);

Expand Down Expand Up @@ -87,13 +87,15 @@ public int Size()

public class BadgeInfo{
public Texture2D texture;
public string name;
public string label;
public string path;
public bool buttonUnlockable;

public BadgeInfo(string label, string path)
public BadgeInfo(string name, string label, string path)
{
texture = Resources.Load(path) as Texture2D;
this.name = name;
this.label = label;
this.path = path;
buttonUnlockable = false;
Expand Down
9 changes: 7 additions & 2 deletions Project/Assets/Vendor/Badges/Badgebook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public class Badgebook : MonoBehaviour {
public delegate void EventHandler(BadgeStore.BadgeInfo badge);
public static event EventHandler BadgeUnlocked;

public delegate void QuestSelectedEventHandler(BadgeStore.BadgeInfo badge);
public static event EventHandler BadgeSelected;

public Texture2D background;
GameObject previous_state;

Expand All @@ -54,7 +57,7 @@ public class Badgebook : MonoBehaviour {

bool enabled = false;

BadgeStore badgeStore = new BadgeStore();
public BadgeStore badgeStore = new BadgeStore();

GUIStyle label_style;
GUIStyle icon_style;
Expand Down Expand Up @@ -255,7 +258,9 @@ void displayPage(int page_number, int table_width, int table_height)
int y = row * field_height;

icon_style.normal.background = badgeStore.icon(i);
GUI.Box(new Rect(x,y, 50 ,50), "" , icon_style);
if (GUI.Button(new Rect(x,y, 50 ,50), "" , icon_style)) {
BadgeSelected(badgeStore.Get(i));
}

if(badgeStore.path(i).Contains("incomplete"))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void setupSpecialEvents()
//main_audio.audio.PlayOneShot(hi_clip);
};

ConversationDisplayer.ConversationStopped += (target) => {
ConversationDisplayer.ConversationStopped += (target, bailed) => {
int i = Random.Range(1, 3);
AudioClip bye_clip = Resources.Load("GnomeBye" + i) as AudioClip;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
public class ConversationDisplayer : MonoBehaviour {

public delegate void EventHandler(Conversation conversation);
public delegate void ConversationStoppedEventHandler(Conversation conversation, string startingQuest);
public static event EventHandler ConversationStarted;
public static event EventHandler ConversationStopped;
public static event ConversationStoppedEventHandler ConversationStopped;


public int height = 300;
Expand Down Expand Up @@ -38,11 +39,11 @@ public void show(GameObject previous_state)
ConversationStarted(conversation);
}

void exit()
void exit(string startingQuest)
{
((Camera) GameObject.Find ("MinimapCamera").camera).enabled = true;
if(ConversationStarted != null)
ConversationStopped(conversation);
if(ConversationStopped != null)
ConversationStopped(conversation, startingQuest);

conversation = null;
Time.timeScale = 1;
Expand Down Expand Up @@ -103,7 +104,7 @@ void OnGUI(){

if(response.isExit())
{
exit();
exit(response.startsQuest());
}
}
response_height += 60;
Expand All @@ -114,7 +115,7 @@ void OnGUI(){

if(Event.current.type == EventType.MouseDown && !mouse_over_button){
Event.current.Use();
exit();
exit("");
return;
}
}
Expand Down
12 changes: 6 additions & 6 deletions Project/Assets/Vendor/Conversations/Scripts/Graph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ public void readInConversation(string convo_file)
}
else if(readEdges)
{
string [] split = txt.Split('=');
string [] split = txt.Split('=');
this.addEdge(System.Int32.Parse(split[0]), split[1], System.Int32.Parse(split[2]), System.Int32.Parse(split[3]));
}
else if(readExits)
{
string [] split = txt.Split('=');
this.addExit(System.Int32.Parse(split[0]), split[1], System.Int32.Parse(split[2]), System.Int32.Parse(split[3]));
string [] split = txt.Split('=');
this.addExit(System.Int32.Parse(split[0]), split[1], System.Int32.Parse(split[2]), System.Int32.Parse(split[3]), split.Length >= 5 ? split[4] : "");
}
txt = reader.ReadLine();
}
Expand All @@ -101,7 +101,7 @@ public void addNode(int p_id, string p_statement)
// Adds response edges to the graph
public void addEdge(int p_id, string p_statement, int p_fromNode, int p_toNode)
{
Response temp = new Response(p_statement, p_fromNode, p_toNode, false);
Response temp = new Response(p_statement, p_fromNode, p_toNode, false, "");

edges.Insert(p_id, temp);
foreach (KeyValuePair<Node, ArrayList> pair in graph)
Expand All @@ -115,9 +115,9 @@ public void addEdge(int p_id, string p_statement, int p_fromNode, int p_toNode)
}

// Adds exit edges to the graph
public void addExit(int p_id, string p_statement, int p_fromNode, int p_toNode)
public void addExit(int p_id, string p_statement, int p_fromNode, int p_toNode, string startingQuest)
{
Response temp = new Response(p_statement, p_fromNode, p_toNode, true);
Response temp = new Response(p_statement, p_fromNode, p_toNode, true, startingQuest);
temp.setIsExit(true);
edges.Insert(p_id, temp);
foreach (KeyValuePair<Node, ArrayList> pair in graph)
Expand Down
9 changes: 8 additions & 1 deletion Project/Assets/Vendor/Conversations/Scripts/Response.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ public class Response {
private int nextNode = -1;
private int prevNode = -1;
private bool is_exit = false;
private string starts_quest = "";

public Response(string p_response, int p_prevNode, int p_nextNode, bool exit)
public Response(string p_response, int p_prevNode, int p_nextNode, bool exit, string starts_quest)
{
response = p_response;
nextNode = p_nextNode;
prevNode = p_prevNode;
is_exit = exit;
this.starts_quest = starts_quest;
}

public string getResponseText()
Expand All @@ -40,6 +42,11 @@ public bool isExit()
{
return this.is_exit;
}

public string startsQuest()
{
return this.starts_quest;
}

public void setNextNode(int p_nextNode)
{
Expand Down
65 changes: 54 additions & 11 deletions Project/Assets/Vendor/Level1/Setup/SetupLevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ public class SetupLevel : MonoBehaviour {
private bool crate1 = false;
private bool crate2 = false;
private bool hintstart = false;
private string currentQuest = "";

private int helpingUnlocked = 0;
private int num_unlocked = 0;
private const int NUMBER_OF_QUESTS = 8 + 1; //extra 1 for staff, though it's not exactly a quest, it is used to unlock helping_others

private GUIStyle helpButtonStyle = new GUIStyle();
private GUIStyle currentQuestStyle = new GUIStyle();
private GUIStyle currentQuestButtonStyle = new GUIStyle();
private Texture2D yellowBorder;
private bool showYellowBorder = false;

Expand Down Expand Up @@ -66,11 +69,18 @@ public void Init() {
helpButtonStyle.active.textColor = new Color(0.75f, 0.68f, 0.016f);
helpButtonStyle.alignment = TextAnchor.MiddleCenter;
helpButtonStyle.fontSize = 20;


currentQuestStyle.normal.background = colorTexture(Color.yellow);
currentQuestStyle.alignment = TextAnchor.MiddleCenter;

currentQuestButtonStyle.normal.background = colorTexture(1, 180.0f/255.0f, 40.0f/255.0f);
currentQuestButtonStyle.active.background = colorTexture(Color.yellow);
currentQuestButtonStyle.alignment = TextAnchor.MiddleCenter;

// Setup quest check border
createOrangeBorderTexture();
}

void givePlayerAFlag() {
// If all the bread is collected, give them a staff/flag
FlyQuestChecker.UnlockedStaff += () => {
Expand Down Expand Up @@ -236,6 +246,11 @@ void givePlayerABadgeBook()
};

int collectedBread = 0;

Badgebook.BadgeSelected += (badge) => {
currentQuest = badge.name;
showAppropriateQuestArrows();
};

FlyQuestChecker.Levitated += () => {
if (badgebook.Complete("helping_others_reaching_up_high"))
Expand Down Expand Up @@ -478,12 +493,16 @@ void givePlayerExistingSpells() {
}

void showAppropriateQuestArrows() {
Debug.Log("hiding all quest arrows");
hideAllQuestArrows();

foreach (string questName in nextQuests()) {
Debug.Log("showing quest arrows for " + questName);
showQuestObjects(objectNameForQuest(questName));

if (currentQuest != "") {
//Debug.Log("showing quest arrows for " + currentQuest);
showQuestObjects(objectNameForQuest(currentQuest));
} else {
foreach (string questName in nextQuests()) {
//Debug.Log("showing quest arrows for " + questName);
showQuestObjects(objectNameForQuest(questName));
}
}
}

Expand Down Expand Up @@ -656,11 +675,17 @@ void setupSpecialEvents()
main_audio.audio.PlayOneShot(hi_clip);
};

ConversationDisplayer.ConversationStopped += (target) => {
ConversationDisplayer.ConversationStopped += (target, startingQuest) => {
int i = Random.Range(1, 3);
AudioClip bye_clip = Resources.Load("GnomeBye" + i) as AudioClip;

main_audio.audio.PlayOneShot(bye_clip);
main_audio.audio.PlayOneShot(bye_clip);

if (startingQuest != "") {
Debug.Log("Quest accepted: " + startingQuest);
currentQuest = startingQuest;
showAppropriateQuestArrows();
}
};
}

Expand Down Expand Up @@ -755,8 +780,16 @@ void OnGUI()
ProgramLogger.LogKVtime("hint", redButtonText);
showYellowBorder = !showYellowBorder;
}

if (currentQuest != "") {
GUI.Label(new Rect(50, 10, Screen.width - 400, 20), "Current Quest: " + badgebook.badgeStore.label(currentQuest).Trim(), currentQuestStyle);
int buttonWidth = 90;
if (GUI.Button(new Rect(Screen.width - 400 + 50 - (buttonWidth + 2), 12, buttonWidth, 16), "Abandon!", currentQuestButtonStyle)) {
currentQuest = "";
}
}
}

// Yellow border shows up around screen if help is requested
void createYellowBorderTexture() {
yellowBorder = new Texture2D(1,1);
Expand All @@ -770,5 +803,15 @@ void createOrangeBorderTexture() {
orangeBorder.SetPixel(0, 0, new Color(1,.5f,0,1));
orangeBorder.Apply();
}


Texture2D colorTexture(float r, float g, float b) {
return colorTexture(new Color(r, g, b));
}

Texture2D colorTexture(Color color) {
Texture2D tex = new Texture2D(1, 1);
tex.SetPixel(0, 0, color);
tex.Apply();
return tex;
}
}