예제 #1
0
        /// <summary>
        /// Branches to another dialog chain based on the story choice.
        /// If the matching dialog chain parameter is null, then does nothing.
        /// </summary>
        public static Action BranchStoryChoice(DialogChain choice1, DialogChain choice2, DialogChain choice3, bool force = false)
        {
            return(() =>
            {
                switch (GameScript.choice)
                {
                case 1:
                    if (choice1 != null && (force || choice1.TriggerCondition == null ||
                                            choice1.TriggerCondition(InstanceTracker.GameScript.GetFieldValue <int>("curB"))))
                    {
                        DialogChains.InitiateDialog(choice1);
                    }
                    break;

                case 2:
                    if (choice2 != null && (force || choice2.TriggerCondition == null ||
                                            choice2.TriggerCondition(InstanceTracker.GameScript.GetFieldValue <int>("curB"))))
                    {
                        DialogChains.InitiateDialog(choice2);
                    }
                    break;

                case 3:
                    if (choice3 != null && (force || choice3.TriggerCondition == null ||
                                            choice3.TriggerCondition(InstanceTracker.GameScript.GetFieldValue <int>("curB"))))
                    {
                        DialogChains.InitiateDialog(choice3);
                    }
                    break;
                }
            });
        }
예제 #2
0
 /// <summary>
 /// Initiates dialog for the given chain.
 /// </summary>
 public static void InitiateDialog(this DialogChain chain)
 {
     activeChain = chain;
     if (!GameScript.talking)
     {
         InstanceTracker.GameScript.StartCoroutine(InstanceTracker.GameScript.EnterTalking());
     }
     InstanceTracker.GameScript.Talk(chain.NPCID, 0, -1);
 }
예제 #3
0
 /// <summary>
 /// Branches to another dialog chain as long as the chain's trigger condition is met.
 /// This chain does not need to have been registered with <see cref="DialogChains.RegisterDialogChain(DialogChain)"/>
 /// </summary>
 public static Action BranchDialog(DialogChain chain)
 {
     return(() =>
     {
         if (chain.TriggerCondition == null || chain.TriggerCondition(InstanceTracker.GameScript.GetFieldValue <int>("curB")))
         {
             DialogChains.InitiateDialog(chain);
         }
     });
 }
예제 #4
0
 /// <summary>
 /// Registers a new dialog chain.
 /// </summary>
 public static DialogChain RegisterDialogChain(this DialogChain chain)
 {
     if (dialogChains.TryGetValue(chain.NPCID, out List <DialogChain> list))
     {
         list.Add(chain);
     }
     else
     {
         dialogChains.Add(chain.NPCID, new List <DialogChain> {
             chain
         });
     }
     return(chain);
 }
예제 #5
0
 /// <summary>
 /// Activates the story choice menu, with specified description and choice texts, as well as an optional dialog chain to start after a choice is selected.
 /// </summary>
 public static Action StoryChoiceMenu(string desc, string choice1, string choice2, string choice3 = null, DialogChain afterChoice = null, bool force = false, Action <int> afterChoiceEvent = null)
 {
     return(() =>
     {
         storyChoiceOverrideDesc = desc;
         storyChoiceOverrideChoice1 = choice1;
         storyChoiceOverrideChoice2 = choice2;
         storyChoiceOverrideChoice3 = choice3;
         InstanceTracker.GameScript.StartCoroutine(InstanceTracker.GameScript.ExitTalking());
         InstanceTracker.GameScript.MenuStory();
         autoDialogAfterChoice = afterChoice;
         autoDialogForce = force;
         afterChoiceAction = afterChoiceEvent;
     });
 }