void givePlayerASpellbook() { GameObject book = new GameObject(); book.name = "Book"; book.AddComponent <SpellbookItem>(); SpellbookItem item = book.GetComponent <SpellbookItem>(); item.item_name = "Spells"; Inventory inventory = GameObject.Find("Inventory").GetComponent <Inventory>(); inventory.addItem(book); Spellbook spellbook = GameObject.Find("Spellbook").GetComponent <Spellbook>(); Badgebook badgebook = GameObject.Find("Badgebook").GetComponent <Badgebook>(); spellbook.Add(new FilePage("MySpell", "MySpell/texture", "MySpell/code")); //spellbook.Add(new FilePage("MassiveLevitation", "MassiveLevitation/texture", "MassiveLevitation/code")); //spellbook.Add(new FilePage("FollowTheLeader", "FollowTheLeader/texture", "FollowTheLeader/code")); spellbook.Add(new FilePage("Flame", "Flame/texture", "Flame/code")); spellbook.Add(new FilePage("Sentry", "Sentry/texture", "Sentry/code")); spellbook.Add(new FilePage("Levitate", "Levitate/texture", "Levitate/code")); spellbook.Add(new FilePage("AdeptLevitate", "AdeptLevitate/texture", "AdeptLevitate/code")); spellbook.Add(new FilePage("Teleport", "Teleport/texture", "Teleport/code")); spellbook.Add(new FilePage("Flight", "Flight/texture", "Flight/code")); spellbook.Add(new FilePage("Summon", "Summon/texture", "Summon/code")); //if(badgebook.Complete("helping_others_putting_something_high")) //{ //spellbook.Add(new FilePage("MassiveFire", "MassiveFire/texture", "MassiveFire/code")); //spellbook.Add(new FilePage("Architecture", "Architecture/texture", "Architecture/code")); //spellbook.Add(new FilePage("Architecture2", "Architecture2/texture", "Architecture2/code")); //} }
void givePlayerABadgeBook() { GameObject book = new GameObject(); book.name = "Badges"; book.AddComponent <BadgebookItem>(); BadgebookItem item = book.GetComponent <BadgebookItem>(); item.item_name = "Badges"; Inventory inventory = GameObject.Find("Inventory").GetComponent <Inventory>(); inventory.addItem(book); Badgebook badgebook = GameObject.Find("Badgebook").GetComponent <Badgebook>(); badgebook.Add("helping_others", "Example Badge", "incomplete_helping_others_badge", false); bool badge_given = false; Enchantable.EnchantmentEnded += (spell_target, item_name) => { if (!badge_given) { badgebook.Complete("helping_others"); } badge_given = true; }; }
public override void DroppedOnInventory(Vector3 mousePosition) { SetHidden(false); Badgebook badgebook = (GameObject.Find("Badgebook").GetComponent <Badgebook>()); badgebook.show(GameObject.Find("Inventory")); }
void OnGUI() { string redButtonText = "Help"; Badgebook badgebook = GameObject.Find("Badgebook").GetComponent <Badgebook>(); // If quest check has been requested, display an orange border if (badgebook.showOrangeBorder) { int thick = 10; GUI.DrawTexture(new Rect(0, 0, Screen.width, thick), orangeBorder, ScaleMode.StretchToFill, false); GUI.DrawTexture(new Rect(0, 0, thick, Screen.height), orangeBorder, ScaleMode.StretchToFill, false); GUI.DrawTexture(new Rect(Screen.width - thick, 0, thick, Screen.height), orangeBorder, ScaleMode.StretchToFill, false); GUI.DrawTexture(new Rect(0, Screen.height - thick, Screen.width, thick), orangeBorder, ScaleMode.StretchToFill, false); if (showYellowBorder) { redButtonText = "Ok"; GUI.DrawTexture(new Rect(thick, thick, Screen.width - 2 * thick, thick), yellowBorder, ScaleMode.StretchToFill, false); GUI.DrawTexture(new Rect(thick, thick, thick, Screen.height - 2 * thick), yellowBorder, ScaleMode.StretchToFill, false); GUI.DrawTexture(new Rect(Screen.width - 2 * thick, thick, thick, Screen.height - 2 * thick), yellowBorder, ScaleMode.StretchToFill, false); GUI.DrawTexture(new Rect(thick, Screen.height - 2 * thick, Screen.width - 2 * thick, thick), yellowBorder, ScaleMode.StretchToFill, false); } } // If help has been requested, display a yellow border else if (showYellowBorder) { redButtonText = "Ok"; int thick = 10; GUI.DrawTexture(new Rect(0, 0, Screen.width, thick), yellowBorder, ScaleMode.StretchToFill, false); GUI.DrawTexture(new Rect(0, 0, thick, Screen.height), yellowBorder, ScaleMode.StretchToFill, false); GUI.DrawTexture(new Rect(Screen.width - thick, 0, thick, Screen.height), yellowBorder, ScaleMode.StretchToFill, false); GUI.DrawTexture(new Rect(0, Screen.height - thick, Screen.width, thick), yellowBorder, ScaleMode.StretchToFill, false); } bool oldhint = hintstart; // Toggle control for marking start/end of giving a hint hintstart = GUI.Toggle(new Rect(Screen.width - 30, Screen.height - 30, 30, 30), hintstart, "H"); if (oldhint != hintstart) { showYellowBorder = false; TraceLogger.LogKVtime("hint", "" + hintstart); ProgramLogger.LogKVtime("hint", "" + hintstart); } // Display a button that requests help or cancels a call for help if (GUI.Button(new Rect(0, Screen.height - 64, 64, 64), redButtonText + "!", helpButtonStyle)) { TraceLogger.LogKVtime("hint", redButtonText); ProgramLogger.LogKVtime("hint", redButtonText); showYellowBorder = !showYellowBorder; } if (Input.GetKey(KeyCode.B)) { Inventory inventory = GameObject.Find("Inventory").GetComponent <Inventory>(); Spellbook spellbook = GameObject.Find("Spellbook").GetComponent <Spellbook>(); spellbook.show(GameObject.Find("Inventory")); } }
void showAppropriateSpells(GameObject badgeBook) { Debug.Log("adding advanced spells"); Badgebook badgebook = badgeBook.GetComponent <Badgebook>(); Spellbook spellbook = GameObject.Find("Spellbook").GetComponent <Spellbook>(); if (badgebook.Complete("collecting_objects_staff")) { spellbook.Add(new FilePage("MassiveFire", "MassiveFire/texture", "MassiveFire/code")); spellbook.Add(new FilePage("Architecture", "Architecture/texture", "Architecture/code")); spellbook.Add(new FilePage("Architecture2", "Architecture2/texture", "Architecture2/code")); } }
public override bool checkIfCompleted() { Badgebook badgebook = GameObject.Find("Badgebook").GetComponent <Badgebook>(); if (Levitated != null && !badgebook.IsComplete("helping_others_reaching_up_high")) { Levitated(); } if (badgebook.IsComplete("helping_others_putting_something_high")) { if (UnlockedStaff != null) { UnlockedStaff(); } return(true); } return(false); }
// Reads a log of completed badges and marks them as already complete void markCompletedBadges() { if (File.Exists("./CodeSpellsBadges.log")) { string[] lines = File.ReadAllLines("./CodeSpellsBadges.log"); Badgebook badgebook = GameObject.Find("Badgebook").GetComponent <Badgebook>(); foreach (string line in lines) { if (badgebook.MarkAlreadyComplete(line.Trim())) { if (line.StartsWith("helping_others_")) { helpingUnlocked++; } else if (line.StartsWith("reading_your_book_")) { num_unlocked++; } else if (line.StartsWith("collecting_objects_staff")) { helpingUnlocked++; GameObject game_flag = new GameObject(); game_flag.AddComponent <Flag>(); game_flag.name = "game_flag"; Inventory inventory = GameObject.Find("Inventory").GetComponent(typeof(Inventory)) as Inventory; inventory.addItem(game_flag); game_flag.GetComponent <Item>().item_name = "Staff"; showAppropriateSpells(GameObject.Find("Badgebook")); } } } } }
public override bool checkIfCompleted() { Badgebook badgebook = GameObject.Find("Badgebook").GetComponent <Badgebook>(); return(badgebook.IsComplete("unlevitate")); }
string[] nextQuests() { Badgebook badgebook = GameObject.Find("Badgebook").GetComponent <Badgebook>(); if (!badgebook.IsComplete("helping_others_picking_up_item")) { return new string[] { "intro", "helping_others_picking_up_item" } } ; if (!badgebook.IsComplete("helping_others_cross_river")) { return new string[] { "helping_others_cross_river" } } ; if (!badgebook.IsComplete("helping_others_reaching_up_high")) { return new string[] { "helping_others_reaching_up_high" } } ; if (!badgebook.IsComplete("helping_others_putting_out_fire")) { return new string[] { "helping_others_putting_out_fire" } } ; if (!badgebook.IsComplete("helping_others_light_fire")) { return new string[] { "helping_others_light_fire" } } ; if (!badgebook.IsComplete("helping_others_summonObject")) { return new string[] { "helping_others_summonObject" } } ; if (!badgebook.IsComplete("helping_others_unlevitate")) { return new string[] { "helping_others_unlevitate" } } ; if (!badgebook.IsComplete("square_dance")) { return new string[] { "square_dance" } } ; if (!badgebook.IsComplete("creative_dance")) { return new string[] { "creative_dance" } } ; if (!badgebook.IsComplete("massive_levitate")) { return new string[] { "massive_levitate" } } ; if (!badgebook.IsComplete("massive_unlevitate")) { return new string[] { "massive_unlevitate" } } ; if (!badgebook.IsComplete("massive_dance")) { return new string[] { "massive_dance" } } ; if (!badgebook.IsComplete("follow_the_leader")) { return new string[] { "follow_the_leader" } } ; if (!badgebook.IsComplete("portal")) { return new string[] { "portal" } } ; if (!badgebook.IsComplete("umbrella")) { return new string[] { "umbrella" } } ; return(new string[] {}); } string objectNameForQuest(string questName) { switch (questName) { case "intro": return("IntroGnome"); case "helping_others_picking_up_item": return("RiverQuest"); case "helping_others_cross_river": return("RiverQuest"); case "helping_others_reaching_up_high": return("FlyingQuest"); case "helping_others_putting_out_fire": return("SummonQuest"); //case "light fire": return "SummonQuest"; case "helping_others_light_fire": return("FireQuest"); case "helping_others_summonObject": return("SummonObjectQuest"); case "helping_others_unlevitate": return("UnlevitationQuest"); case "square_dance": return("DanceQuest"); case "creative_dance": return("DanceQuest"); case "massive_levitate": return("MassiveLevitationQuest"); case "massive_unlevitate": return("MassiveLevitationQuest"); //case "massive creative dance": return ""; case "follow_the_leader": return("FollowTheLeaderQuest"); case "portal": return("PortalQuest"); case "umbrella": return("UmbrellaQuest"); } return(""); }
void givePlayerABadgeBook() { GameObject book = new GameObject(); book.name = "Badges"; book.AddComponent <BadgebookItem>(); BadgebookItem item = book.GetComponent <BadgebookItem>(); item.item_name = "Badges"; Inventory inventory = GameObject.Find("Inventory").GetComponent <Inventory>(); inventory.addItem(book); Badgebook badgebook = GameObject.Find("Badgebook").GetComponent <Badgebook>(); badgebook.AddColumn(NUMBER_OF_QUESTS + 1); badgebook.Add("helping_others", "HELPING OTHERS", "incomplete_helping_others_badge", false); badgebook.Add("helping_others_picking_up_item", " Pickin up Stuff", "incomplete_picking_up_item_badge", false); badgebook.Add("helping_others_cross_river", " Cross River", "incomplete_crossing_river_badge", false); badgebook.Add("helping_others_reaching_up_high", " New Heights", "incomplete_reaching_up_high_badge", false); badgebook.Add("helping_others_putting_something_high", " Out of Reach", "incomplete_putting_something_high_badge", false); badgebook.Add("helping_others_putting_out_fire", " Firefighter", "incomplete_putting_out_fire_badge", false); badgebook.Add("helping_others_light_fire", " Light Fire", "incomplete_light_fire_badge", false); badgebook.Add("helping_others_unlevitate", " Unlevitate", "incomplete_unlevitate_badge", false); badgebook.Add("helping_others_summonObject", " Summon Object", "incomplete_summonObject_badge", false); badgebook.Add("collecting_objects_staff", " Staff", "incomplete_collecting_objects_staff", false); badgebook.AddColumn(9); badgebook.Add("reading_your_book", "READING YOUR BOOK", "incomplete_reading_your_book_badge", false); badgebook.Add("reading_your_book_fire", " Flames", "incomplete_cast_flame_badge", false); badgebook.Add("reading_your_book_sentry", " Sentry", "incomplete_cast_sentry_badge", false); badgebook.Add("reading_your_book_adv_levitate", " Adept Levitation", "incomplete_cast_levitate_badge", false); badgebook.Add("reading_your_book_flight", " Flight", "incomplete_cast_flight_badge", false); badgebook.Add("reading_your_book_teleport", " Teleportation", "incomplete_cast_teleport_badge", false); badgebook.Add("reading_your_book_summon", " Summoning", "incomplete_cast_summoning_badge", false); badgebook.Add("reading_your_book_massive", " Massive Fire", "incomplete_cast_massive_fire_badge", false); badgebook.Add("reading_your_book_architecture", " Architecture", "incomplete_cast_architecture_badge", false); badgebook.AddColumn(8); badgebook.Add("square_dance", " Square Dance", "incomplete_square_dance", false); badgebook.MakeButtonUnlockable("square_dance"); badgebook.Add("creative_dance", " Creative Dance", "incomplete_creative_dance", false); badgebook.MakeButtonUnlockable("creative_dance"); badgebook.Add("massive_levitate", " Massive Levitate", "incomplete_massive_levitate", false); badgebook.MakeButtonUnlockable("massive_levitate"); badgebook.Add("massive_unlevitate", " Massive Unlevitate", "incomplete_massive_unlevitate", false); badgebook.MakeButtonUnlockable("massive_unlevitate"); badgebook.Add("massive_dance", " Massive Dance", "incomplete_massive_dance", false); badgebook.MakeButtonUnlockable("massive_dance"); badgebook.Add("follow_the_leader", " Follow The Leader", "incomplete_follow_the_leader", false); badgebook.MakeButtonUnlockable("follow_the_leader"); badgebook.Add("portal", " Portal", "incomplete_portal", false); badgebook.MakeButtonUnlockable("portal"); badgebook.Add("umbrella", " Umbrella", "incomplete_umbrella", false); badgebook.MakeButtonUnlockable("umbrella"); // To make a badge unlockable by an instructor, add // badgebook.MakeButtonUnlockable(<badge_name>); // example: // badgebook.MakeButtonUnlockable("reading_your_book"); // mark badges as already complete markCompletedBadges(); // mark areas that are already cleared getCompletedAreas(); showAppropriateQuestArrows(); //Set up the callbacks for unlocking the badges. //int num_unlocked = 0; Enchantable.EnchantmentEnded += (spell_target, item_name) => { bool success = false; if (item_name.StartsWith("Flame")) { success = badgebook.Complete("reading_your_book_fire"); } if (item_name.StartsWith("Sentry")) { success = badgebook.Complete("reading_your_book_sentry"); } if (item_name.StartsWith("Massive")) { success = badgebook.Complete("reading_your_book_massive"); } if (item_name.StartsWith("Flight")) { success = badgebook.Complete("reading_your_book_flight"); } if (item_name.StartsWith("AdeptLevitate")) { success = badgebook.Complete("reading_your_book_adv_levitate"); } if (item_name.StartsWith("Summon")) { success = badgebook.Complete("reading_your_book_summon"); } if (item_name.StartsWith("Teleport")) { success = badgebook.Complete("reading_your_book_teleport"); } if (item_name.StartsWith("Architecture")) { success = badgebook.Complete("reading_your_book_architecture"); } if (success) { num_unlocked++; } if (num_unlocked == 8) { badgebook.Complete("reading_your_book"); } showAppropriateQuestArrows(); }; int collectedBread = 0; FlyQuestChecker.Levitated += () => { if (badgebook.Complete("helping_others_reaching_up_high")) { //GameObject.Find("LevitationQuestGnomeArmature").GetComponent<DisplayOnMinimap>().show = false; //GameObject.Find("LevitationQuestGnomeArmature").GetComponent<Icon3D>().show = false; helpingUnlocked++; } if (helpingUnlocked == NUMBER_OF_QUESTS) { badgebook.Complete("helping_others"); } showAppropriateQuestArrows(); }; AudioSource main_audio = GameObject.Find("Voice").audio; AudioClip pickup_clip = Resources.Load("PickupArpeg") as AudioClip; int unlevitatingBoxes = 0; Unlevitate.UnlevitateQuest += () => { unlevitatingBoxes++; main_audio.PlayOneShot(pickup_clip); Popup.mainPopup.popup("Got it! (" + (3 - unlevitatingBoxes) + " left)"); if (unlevitatingBoxes == 3) { if (badgebook.Complete("helping_others_unlevitate")) { //GameObject.Find("UnlevitationQuestGnomeArmature").GetComponent<DisplayOnMinimap>().show = false; //GameObject.Find("UnlevitationQuestGnomeArmature").GetComponent<Icon3D>().show = false; //GameObject.Find("QuestUnlevitationCrate").GetComponent<Icon3D>().show = false; //GameObject.Find("QuestUnlevitationCrate1").GetComponent<Icon3D>().show = false; //GameObject.Find("QuestUnlevitationCrate2").GetComponent<Icon3D>().show = false; helpingUnlocked++; } } if (helpingUnlocked == NUMBER_OF_QUESTS) { badgebook.Complete("helping_others"); } //update current level for areas and log the area GameObject.Find("Area2").GetComponent <Area2>().area2 = true; AreaLogger.Log("Area2"); showAppropriateQuestArrows(); }; SummonObject.SummonObjectQuest += () => { if (badgebook.Complete("helping_others_summonObject")) { //GameObject.Find("SummonObjectGnomeArmature").GetComponent<DisplayOnMinimap>().show = false; //GameObject.Find("SummonObjectGnomeArmature").GetComponent<Icon3D>().show = false; //GameObject.Find("SummonedObject").GetComponent<Icon3D>().show = false; //Destroy the yellow summoning block when they have summond the square to it. Destroy(GameObject.Find("SummonTo")); helpingUnlocked++; } if (helpingUnlocked == NUMBER_OF_QUESTS) { badgebook.Complete("helping_others"); } showAppropriateQuestArrows(); }; CollectBread.CollectedBread += () => { collectedBread++; main_audio.PlayOneShot(pickup_clip); Popup.mainPopup.popup("Got it! (" + (12 - collectedBread) + " left)"); if (12 == 12) { if (badgebook.Complete("helping_others_putting_something_high")) { //GameObject.Find("FlyQuestGnomeArmature").GetComponent<DisplayOnMinimap>().show = false; //GameObject.Find("FlyQuestGnomeArmature").GetComponent<Icon3D>().show = false; helpingUnlocked++; } } if (helpingUnlocked == NUMBER_OF_QUESTS) { badgebook.Complete("helping_others"); } showAppropriateQuestArrows(); showAppropriateSpells(GameObject.Find("Badgebook")); }; Inventory.PickedUp += (target) => { if (target.name.Equals("Presents")) { //Debug.Log("Trying to enable the Icon3D for Dance Quest"); //GameObject.Find("DanceQuest").GetComponent<Icon3D>().color = Color.white; if (badgebook.Complete("helping_others_picking_up_item")) { helpingUnlocked++; } } if (target.name.Equals("game_flag")) { if (badgebook.Complete("collecting_objects_staff")) { helpingUnlocked++; } } if (helpingUnlocked == NUMBER_OF_QUESTS) { badgebook.Complete("helping_others"); } showAppropriateQuestArrows(); }; Inventory.DroppedOff += (target) => { GameObject gnome = GameObject.Find("QuestSwampGnomeEnd"); GameObject presents = GameObject.Find("Presents"); if (target.name.Equals("Presents") && Vector3.Distance(gnome.transform.position, presents.transform.position) < 10) { //GameObject.Find("QuestSwampGnomeEnd").GetComponent<Icon3D>().enabled = false; if (badgebook.Complete("helping_others_cross_river")) { helpingUnlocked++; } } if (helpingUnlocked == NUMBER_OF_QUESTS) { badgebook.Complete("helping_others"); } showAppropriateQuestArrows(); }; Flamable.Extinguished += (target) => { //Debug.Log("Extinguished was called with target: "+target.gameObject.name); if (target.name.Equals("QuestSummonCrate")) { Debug.Log("Completing the summoning quest"); if (badgebook.Complete("helping_others_putting_out_fire")) { helpingUnlocked++; } } if (helpingUnlocked == NUMBER_OF_QUESTS) { badgebook.Complete("helping_others"); } showAppropriateQuestArrows(); }; Flamable.CaughtFire += (target) => { if (!crate1 && target.name.Equals("QuestFlammingCrate")) { crate1 = true; if (crate2) { if (badgebook.Complete("helping_others_light_fire")) { helpingUnlocked++; } } } if (!crate2 && target.name.Equals("QuestFlammingCrate1")) { crate2 = true; if (crate1) { if (badgebook.Complete("helping_others_light_fire")) { helpingUnlocked++; } } } if (helpingUnlocked == NUMBER_OF_QUESTS) { badgebook.Complete("helping_others"); } showAppropriateQuestArrows(); }; }
public override bool checkIfCompleted() { Badgebook badgebook = GameObject.Find("Badgebook").GetComponent <Badgebook>(); return(badgebook.IsComplete("helping_others_light_fire")); }
public override bool checkIfCompleted() { Badgebook badgebook = GameObject.Find("Badgebook").GetComponent <Badgebook>(); return(badgebook.IsComplete("collecting_objects_staff")); }