IEnumerator OpenChestRoutine(InteractionUser user) { // Suspend interactions SceneLoader.Instance.currentSceneController.SetBusy(); // TODO factor out dialogue stuff to some other class // HACK this feels dirty bool wait = true; UnityEngine.Events.UnityAction continueAction = () => wait = false; System.Func <bool> waitP = () => { return(wait); }; dialogue.SetTitle("Treasure Chest"); dialogue.ClearButtons(); dialogue.AddButton("Next", continueAction); dialogue.SetPortrait(treasureImage); dialogue.ShowBox(); if (contents.Count > 0) { internalGlow.Play(); animator.SetTrigger("Opening"); dialogue.SetDialogue("It was full of treasure!"); yield return(new WaitWhile(waitP)); wait = true; dialogue.SetDialogue("You found:\n" + ContentsText()); dialogue.ClearButtons(); dialogue.AddButton("Exit", continueAction); dialogue.RebuildLayout(); // Add items to inventory foreach (RPGItems.Item item in contents) { GameController.Instance.inventory.Add(Instantiate(item)); } EmptyChest(); trigger.Triggered = true; trigger.Save(); yield return(new WaitWhile(waitP)); } else { dialogue.SetDialogue("The chest was empty"); dialogue.ClearButtons(); dialogue.AddButton("Exit", continueAction); dialogue.RebuildLayout(); yield return(new WaitWhile(waitP)); } dialogue.ClearButtons(); dialogue.HideBox(); SceneLoader.Instance.currentSceneController.ClearBusy(); }
IEnumerator TryBreakRoadblockRoutine(InteractionUser user) { SceneLoader.Instance.currentSceneController.SetBusy(); // HACK this feels dirty bool wait = true; UnityEngine.Events.UnityAction continueAction = () => wait = false; System.Func <bool> waitP = () => { return(wait); }; dialogue.SetTitle("Roadblock"); dialogue.ClearButtons(); dialogue.AddButton("Next", continueAction); dialogue.SetPortrait(roadblockImage); dialogue.ShowBox(); dialogue.SetDialogue("A pile of objects blocks your path out of the town"); yield return(new WaitWhile(waitP)); wait = true; // HACK for testing if (forceAllow) { dialogue.SetDialogue("Your party breaks down the roadblock"); yield return(new WaitWhile(waitP)); trigger.enabled = false; EndDialogue(user); yield return(RoadblockFallRoutine()); } else if (!(SceneLoader.Instance.CheckBool("06 Barracks_Interior", "knight_battle"))) { dialogue.SetDialogue("You need a strong knight to move these objects!"); yield return(new WaitWhile(waitP)); EndDialogue(user); } else if (!(SceneLoader.Instance.CheckBool("04 Town", "rogue_battle"))) { dialogue.SetDialogue("You need an expert in breaking and entering for this job."); yield return(new WaitWhile(waitP)); EndDialogue(user); } else if (!(SceneLoader.Instance.CheckBool("05 Tavern_Interior", "bard_battle"))) { dialogue.SetDialogue("You can't work without musical accompaniment!"); yield return(new WaitWhile(waitP)); EndDialogue(user); } else { dialogue.SetDialogue("Your party breaks down the roadblock"); yield return(new WaitWhile(waitP)); trigger.enabled = false; EndDialogue(user); yield return(RoadblockFallRoutine()); } }