From 7f6495ce5ac41fb70b70820c9d30f83058ced7bb Mon Sep 17 00:00:00 2001 From: Tom Lieber Date: Mon, 18 Nov 2013 11:55:17 -0500 Subject: [PATCH 1/7] currentQuest. only show arrows for that quest --- Project/Assets/Vendor/Level1/Setup/SetupLevel.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs b/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs index 44056e7..0820be8 100644 --- a/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs +++ b/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs @@ -9,6 +9,7 @@ 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; @@ -480,10 +481,15 @@ 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)); + } } } From cad6e05e73d5b7442b883a61bdbaa23bf7be9774 Mon Sep 17 00:00:00 2001 From: Tom Lieber Date: Mon, 18 Nov 2013 12:49:24 -0500 Subject: [PATCH 2/7] added field to dialog file for which quest an exit starts --- .../Conversations/Scripts/ConversationDisplayer.cs | 13 +++++++------ .../Assets/Vendor/Conversations/Scripts/Graph.cs | 12 ++++++------ .../Assets/Vendor/Conversations/Scripts/Response.cs | 9 ++++++++- Project/Assets/Vendor/Level1/Setup/SetupLevel.cs | 10 +++++++--- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Project/Assets/Vendor/Conversations/Scripts/ConversationDisplayer.cs b/Project/Assets/Vendor/Conversations/Scripts/ConversationDisplayer.cs index 9b49ecd..9e5ab60 100644 --- a/Project/Assets/Vendor/Conversations/Scripts/ConversationDisplayer.cs +++ b/Project/Assets/Vendor/Conversations/Scripts/ConversationDisplayer.cs @@ -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; @@ -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; @@ -103,7 +104,7 @@ void OnGUI(){ if(response.isExit()) { - exit(); + exit(response.startsQuest()); } } response_height += 60; @@ -114,7 +115,7 @@ void OnGUI(){ if(Event.current.type == EventType.MouseDown && !mouse_over_button){ Event.current.Use(); - exit(); + exit(""); return; } } diff --git a/Project/Assets/Vendor/Conversations/Scripts/Graph.cs b/Project/Assets/Vendor/Conversations/Scripts/Graph.cs index ee97b00..c8d5b6d 100644 --- a/Project/Assets/Vendor/Conversations/Scripts/Graph.cs +++ b/Project/Assets/Vendor/Conversations/Scripts/Graph.cs @@ -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(); } @@ -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 pair in graph) @@ -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 pair in graph) diff --git a/Project/Assets/Vendor/Conversations/Scripts/Response.cs b/Project/Assets/Vendor/Conversations/Scripts/Response.cs index 71e7d8d..17e62ea 100644 --- a/Project/Assets/Vendor/Conversations/Scripts/Response.cs +++ b/Project/Assets/Vendor/Conversations/Scripts/Response.cs @@ -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() @@ -40,6 +42,11 @@ public bool isExit() { return this.is_exit; } + + public string startsQuest() + { + return this.starts_quest; + } public void setNextNode(int p_nextNode) { diff --git a/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs b/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs index 0820be8..5357ef1 100644 --- a/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs +++ b/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs @@ -479,7 +479,6 @@ void givePlayerExistingSpells() { } void showAppropriateQuestArrows() { - Debug.Log("hiding all quest arrows"); hideAllQuestArrows(); if (currentQuest != "") { @@ -662,11 +661,16 @@ 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 != "") { + currentQuest = startingQuest; + showAppropriateQuestArrows(); + } }; } From e1d25eb433e83f134724575ed133b9fb3980ac9d Mon Sep 17 00:00:00 2001 From: Tom Lieber Date: Sat, 30 Nov 2013 15:25:47 -0500 Subject: [PATCH 3/7] fix compile error --- .../Vendor/CodeSpells/DuelingModePrototype/SetupDuelingMode.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project/Assets/Vendor/CodeSpells/DuelingModePrototype/SetupDuelingMode.cs b/Project/Assets/Vendor/CodeSpells/DuelingModePrototype/SetupDuelingMode.cs index 035f075..b72bcad 100644 --- a/Project/Assets/Vendor/CodeSpells/DuelingModePrototype/SetupDuelingMode.cs +++ b/Project/Assets/Vendor/CodeSpells/DuelingModePrototype/SetupDuelingMode.cs @@ -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; From 53f81a321038339d17494508610cd560bdfe8c0e Mon Sep 17 00:00:00 2001 From: Tom Lieber Date: Sat, 30 Nov 2013 16:15:07 -0500 Subject: [PATCH 4/7] show current quest & tweaked current quest logging --- .../Assets/Vendor/Level1/Setup/SetupLevel.cs | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs b/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs index 5357ef1..a0e7d61 100644 --- a/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs +++ b/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs @@ -16,6 +16,7 @@ public class SetupLevel : MonoBehaviour { 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 Texture2D yellowBorder; private bool showYellowBorder = false; @@ -67,7 +68,13 @@ public void Init() { helpButtonStyle.active.textColor = new Color(0.75f, 0.68f, 0.016f); helpButtonStyle.alignment = TextAnchor.MiddleCenter; helpButtonStyle.fontSize = 20; - + + Texture2D currentQuestBackground = new Texture2D(1, 1); + currentQuestBackground.SetPixel(0, 0, Color.yellow); + currentQuestBackground.Apply(); + currentQuestStyle.normal.background = currentQuestBackground; + currentQuestStyle.alignment = TextAnchor.MiddleCenter; + // Setup quest check border createOrangeBorderTexture(); } @@ -482,11 +489,11 @@ void showAppropriateQuestArrows() { hideAllQuestArrows(); if (currentQuest != "") { - Debug.Log("showing quest arrows for " + currentQuest); + //Debug.Log("showing quest arrows for " + currentQuest); showQuestObjects(objectNameForQuest(currentQuest)); } else { foreach (string questName in nextQuests()) { - Debug.Log("showing quest arrows for " + questName); + //Debug.Log("showing quest arrows for " + questName); showQuestObjects(objectNameForQuest(questName)); } } @@ -668,6 +675,7 @@ void setupSpecialEvents() main_audio.audio.PlayOneShot(bye_clip); if (startingQuest != "") { + Debug.Log("Quest accepted: " + startingQuest); currentQuest = startingQuest; showAppropriateQuestArrows(); } @@ -765,8 +773,12 @@ void OnGUI() ProgramLogger.LogKVtime("hint", redButtonText); showYellowBorder = !showYellowBorder; } + + if (currentQuest != "") { + GUI.Label(new Rect(50, 10, Screen.width - 400, 20), "Current Quest: " + currentQuest, currentQuestStyle); + } } - + // Yellow border shows up around screen if help is requested void createYellowBorderTexture() { yellowBorder = new Texture2D(1,1); From f1a51b914286a483e4110fc70b6ac83db7bb0b64 Mon Sep 17 00:00:00 2001 From: Tom Lieber Date: Sat, 30 Nov 2013 16:25:08 -0500 Subject: [PATCH 5/7] show the name of the current quest instead of its ID --- Project/Assets/Vendor/Badges/Badgebook.cs | 2 +- Project/Assets/Vendor/Level1/Setup/SetupLevel.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Project/Assets/Vendor/Badges/Badgebook.cs b/Project/Assets/Vendor/Badges/Badgebook.cs index 6036743..e97cdce 100644 --- a/Project/Assets/Vendor/Badges/Badgebook.cs +++ b/Project/Assets/Vendor/Badges/Badgebook.cs @@ -54,7 +54,7 @@ public class Badgebook : MonoBehaviour { bool enabled = false; - BadgeStore badgeStore = new BadgeStore(); + public BadgeStore badgeStore = new BadgeStore(); GUIStyle label_style; GUIStyle icon_style; diff --git a/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs b/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs index a0e7d61..ec93c59 100644 --- a/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs +++ b/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs @@ -775,7 +775,7 @@ void OnGUI() } if (currentQuest != "") { - GUI.Label(new Rect(50, 10, Screen.width - 400, 20), "Current Quest: " + currentQuest, currentQuestStyle); + GUI.Label(new Rect(50, 10, Screen.width - 400, 20), "Current Quest: " + badgebook.badgeStore.label(currentQuest).Trim(), currentQuestStyle); } } From 6d912bc5c04202074fafa31f123dc3062c70d913 Mon Sep 17 00:00:00 2001 From: Tom Lieber Date: Sat, 30 Nov 2013 16:43:28 -0500 Subject: [PATCH 6/7] button for abandoning the current quest --- .../Assets/Vendor/Level1/Setup/SetupLevel.cs | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs b/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs index ec93c59..a52a037 100644 --- a/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs +++ b/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs @@ -9,7 +9,7 @@ public class SetupLevel : MonoBehaviour { private bool crate1 = false; private bool crate2 = false; private bool hintstart = false; - private string currentQuest = ""; + private string currentQuest = ""; // helping_others_light_fire private int helpingUnlocked = 0; private int num_unlocked = 0; @@ -17,6 +17,7 @@ public class SetupLevel : MonoBehaviour { private GUIStyle helpButtonStyle = new GUIStyle(); private GUIStyle currentQuestStyle = new GUIStyle(); + private GUIStyle currentQuestButtonStyle = new GUIStyle(); private Texture2D yellowBorder; private bool showYellowBorder = false; @@ -69,16 +70,17 @@ public void Init() { helpButtonStyle.alignment = TextAnchor.MiddleCenter; helpButtonStyle.fontSize = 20; - Texture2D currentQuestBackground = new Texture2D(1, 1); - currentQuestBackground.SetPixel(0, 0, Color.yellow); - currentQuestBackground.Apply(); - currentQuestStyle.normal.background = currentQuestBackground; + 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 += () => { @@ -776,6 +778,10 @@ void OnGUI() 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 = ""; + } } } @@ -792,5 +798,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; + } } From c1085ef2802ea80b3faf919e757afb80dc57bd18 Mon Sep 17 00:00:00 2001 From: Tom Lieber Date: Sat, 30 Nov 2013 17:02:27 -0500 Subject: [PATCH 7/7] select quests by clicking their icons in the badge book --- Project/Assets/Vendor/Badges/BadgeStore.cs | 8 +++++--- Project/Assets/Vendor/Badges/Badgebook.cs | 7 ++++++- Project/Assets/Vendor/Level1/Setup/SetupLevel.cs | 7 ++++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Project/Assets/Vendor/Badges/BadgeStore.cs b/Project/Assets/Vendor/Badges/BadgeStore.cs index 641a5af..2602180 100644 --- a/Project/Assets/Vendor/Badges/BadgeStore.cs +++ b/Project/Assets/Vendor/Badges/BadgeStore.cs @@ -11,7 +11,7 @@ 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); } } @@ -19,7 +19,7 @@ public void Add(string name, string label, string path){ 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); @@ -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; diff --git a/Project/Assets/Vendor/Badges/Badgebook.cs b/Project/Assets/Vendor/Badges/Badgebook.cs index e97cdce..04849b7 100644 --- a/Project/Assets/Vendor/Badges/Badgebook.cs +++ b/Project/Assets/Vendor/Badges/Badgebook.cs @@ -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; @@ -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")) { diff --git a/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs b/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs index a52a037..a83d67f 100644 --- a/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs +++ b/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs @@ -9,7 +9,7 @@ public class SetupLevel : MonoBehaviour { private bool crate1 = false; private bool crate2 = false; private bool hintstart = false; - private string currentQuest = ""; // helping_others_light_fire + private string currentQuest = ""; private int helpingUnlocked = 0; private int num_unlocked = 0; @@ -246,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"))