示例#1
0
        public static int ShowDialogueWithOptions(string Text, string[] Options, TerraGuardian Speaker = null)
        {
            if (Speaker == null)
            {
                Speaker = LastSpeaker;
            }
            Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().IsTalkingToAGuardian    = true;
            Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().TalkingGuardianPosition = Speaker.WhoAmID;
            PlayerFaceGuardian(Speaker);
            ProceedButtonPressed = false;
            GuardianMouseOverAndDialogueInterface.SetDialogue(Text, Speaker);
            GuardianMouseOverAndDialogueInterface.Options.Clear();
            int SelectedOption = 0;

            for (int o = 0; o < Options.Length; o++)
            {
                string OptionText = Options[o];
                if (OptionText == null || OptionText == "")
                {
                    continue;
                }
                int ThisOption = o;
                GuardianMouseOverAndDialogueInterface.AddOption(OptionText, delegate()
                {
                    SelectedOption       = ThisOption;
                    ProceedButtonPressed = true;
                }, Thread.CurrentThread == DialogueThread);
            }
            while (!ProceedButtonPressed)
            {
                Thread.Sleep(100);
            }
            return(SelectedOption);
        }
示例#2
0
 /// <summary>
 /// Shows a message dialogue, with only End as option.
 /// </summary>
 /// <param name="Text">The message the speaker says.</param>
 /// <param name="CloseDialogue">Set to true, will close the dialogue with this companion. Setting to false, returns to the default dialogue and options of the companion.</param>
 /// <param name="Speaker">The companion who speakes this. Leaving as null picks the last speaker.</param>
 public static void ShowEndDialogueMessage(string Text, bool CloseDialogue = true, TerraGuardian Speaker = null, string CloseOptionText = "End")
 {
     if (Speaker == null)
     {
         Speaker = LastSpeaker;
     }
     Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().IsTalkingToAGuardian    = true;
     Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().TalkingGuardianPosition = Speaker.WhoAmID;
     PlayerFaceGuardian(Speaker);
     ProceedButtonPressed = false;
     GuardianMouseOverAndDialogueInterface.SetDialogue(Text, Speaker);
     GuardianMouseOverAndDialogueInterface.Options.Clear();
     if (CloseDialogue)
     {
         GuardianMouseOverAndDialogueInterface.AddOption(CloseOptionText, EndDialogueButtonAction);
     }
     else
     {
         //GuardianMouseOverAndDialogueInterface.AddOption("Return", delegate(TerraGuardian tg)
         //{
         GuardianMouseOverAndDialogueInterface.Options.Clear();
         GuardianMouseOverAndDialogueInterface.GetDefaultOptions();
         ProceedButtonPressed = true;
         //});
     }
     if (Thread.CurrentThread == DialogueThread)
     {
         while (!ProceedButtonPressed)
         {
             Thread.Sleep(100);
         }
         ProceedButtonPressed = false;
         DialogueThread.Interrupt();
     }
 }
示例#3
0
        public static void ShowDialogueWithOptions(string Text, DialogueOption[] Options, TerraGuardian Speaker = null)
        {
            if (Speaker == null)
            {
                Speaker = LastSpeaker;
            }
            Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().IsTalkingToAGuardian    = true;
            Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().TalkingGuardianPosition = Speaker.WhoAmID;
            PlayerFaceGuardian(Speaker);
            ProceedButtonPressed = false;
            GuardianMouseOverAndDialogueInterface.SetDialogue(Text, Speaker);
            GuardianMouseOverAndDialogueInterface.Options.Clear();
            int Selected = 0;

            for (int o = 0; o < Options.Length; o++)
            {
                int ThisOption = o;
                GuardianMouseOverAndDialogueInterface.AddOption(Options[o].Text, delegate()
                {
                    Selected             = ThisOption;
                    ProceedButtonPressed = true;
                });
            }
            if (Thread.CurrentThread == DialogueThread)
            {
                while (!ProceedButtonPressed)
                {
                    Thread.Sleep(100);
                }
                Options[Selected].Action();
            }
        }
示例#4
0
 /// <summary>
 /// Adds an option to the dialogue.
 /// </summary>
 /// <param name="Text">The text of the option, displayed on the list.</param>
 /// <param name="OptionAction">The action of the option. The TerraGuardian attribute in the action is the speaker.</param>
 public static void AddOption(string Text, Action OptionAction, bool Threaded = false)
 {
     GuardianMouseOverAndDialogueInterface.AddOption(Text, OptionAction, Threaded);
 }