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 6036743..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; @@ -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; @@ -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/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; 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 44056e7..a83d67f 100644 --- a/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs +++ b/Project/Assets/Vendor/Level1/Setup/SetupLevel.cs @@ -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; @@ -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 += () => { @@ -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")) @@ -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)); + } } } @@ -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(); + } }; } @@ -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); @@ -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; + } }