示例#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
        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();
            }
        }
示例#3
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();
     }
 }
示例#4
0
 public void SubworldTestScript()
 {
     Maps.TestMap map = new Maps.TestMap();
     if (map.Register())
     {
         map.Enter();
     }
     else
     {
         GuardianMouseOverAndDialogueInterface.SetDialogue("*Something went wrong.*");
     }
 }
示例#5
0
 /// <summary>
 /// Shows a message and resets dialogue options, but doesn't adds any option.
 /// </summary>
 /// <param name="Text">The message the speaker says.</param>
 /// <param name="Speaker">The companion who speakes this. Leaving as null picks the last speaker.</param>
 public static void ShowDialogueOnly(string Text, 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();
 }
示例#6
0
 public static void ShowDialogueTimed(string Text, TerraGuardian Speaker = null, int Time = 0)
 {
     if (Speaker == null)
     {
         Speaker = LastSpeaker;
     }
     Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().IsTalkingToAGuardian    = true;
     Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().TalkingGuardianPosition = Speaker.WhoAmID;
     PlayerFaceGuardian(Speaker);
     GuardianMouseOverAndDialogueInterface.SetDialogue(Text, Speaker);
     GuardianMouseOverAndDialogueInterface.Options.Clear();
     if (Time == 0)
     {
         Time = 300 + Text.Length;
     }
     Time = (int)(Time / 60) + 1;
     while (Time-- > 0)
     {
         Thread.Sleep(1000);
     }
 }
示例#7
0
 private void Message(string Mes)
 {
     GuardianMouseOverAndDialogueInterface.SetDialogue(Mes);
 }
示例#8
0
        public override void Update(TerraGuardian guardian)
        {
            ProceedIdleAIDuringDialogue = true;
            NpcCanFacePlayer            = false;
            guardian.AddDrawMomentToPlayer(Target);
            const int BuffRefreshTime = 10 * 60;

            if (Time >= BuffRefreshTime && Time % BuffRefreshTime == 0)
            {
                int Stack = Time / BuffRefreshTime;
                if (Stack > 3)
                {
                    Stack = 3;
                }
                Target.AddBuff(ModContent.BuffType <Buffs.WellBeing>(), 3600 * 30 * Stack);
                PlayerMod pm = Target.GetModPlayer <PlayerMod>();
                if (pm.ControllingGuardian)
                {
                    pm.Guardian.AddBuff(ModContent.BuffType <Buffs.WellBeing>(), 3600 * 30 * Stack);
                }
            }
            VladimirBase.VladimirData data = (VladimirBase.VladimirData)guardian.Data;
            bool End = Target.controlJump;

            //if (PlayerMod.PlayerHasGuardianSummoned(player, guardian.ID, guardian.ModID))
            //    End = true;
            if (Main.bloodMoon)
            {
                End = false;
            }
            if (End)
            {
                InUse         = false;
                Target.Bottom = guardian.Position;
                if (guardian.BodyAnimationFrame == guardian.Base.ChairSittingFrame)
                {
                    Target.position.Y -= guardian.SpriteHeight - guardian.Base.SittingPoint.Y * guardian.Scale;
                }
                PlayerMod pm = Target.GetModPlayer <PlayerMod>();
                if (pm.ControllingGuardian)
                {
                    pm.Guardian.Position = guardian.Position;
                }
                guardian.SaySomething(((Companions.VladimirBase)guardian.Base).GetEndHugMessage(guardian));
            }
            else
            {
                if (Target.mount.Active)
                {
                    Target.mount.Dismount(Target);
                }
                PlayerMod pm       = Target.GetModPlayer <PlayerMod>();
                bool      FaceBear = (guardian.BodyAnimationFrame != 20 && guardian.BodyAnimationFrame != 21) || guardian.BodyAnimationFrame == 25;
                if (pm.ControllingGuardian)
                {
                    pm.Guardian.Position    = guardian.GetGuardianShoulderPosition;
                    pm.Guardian.Position.Y += guardian.Height * 0.5f;
                    pm.Guardian.Velocity.Y  = -pm.Guardian.Mass;
                    if (data.CarrySomeone)
                    {
                        pm.Guardian.Position.X -= 6 * guardian.Direction;
                    }
                    pm.Guardian.FallStart = (int)pm.Guardian.Position.Y / 16;
                    if (pm.Guardian.ItemAnimationTime == 0 && !pm.Guardian.MoveLeft && !pm.Guardian.MoveRight)
                    {
                        pm.Guardian.FaceDirection((guardian.Direction * (FaceBear ? -1 : 1)) == -1);
                    }
                    pm.Guardian.AddBuff(ModContent.BuffType <Buffs.Hug>(), 5, true);
                    if (pm.Guardian.KnockedOut)
                    {
                        pm.Guardian.ReviveBoost += 3;
                    }
                    if (!Main.bloodMoon)
                    {
                        pm.Guardian.ImmuneTime    = 3;
                        pm.Guardian.ImmuneNoBlink = true;
                    }
                }
                else
                {
                    Target.gfxOffY    = 0;
                    Target.Center     = guardian.GetGuardianShoulderPosition;
                    Target.velocity.Y = -Player.defaultGravity;
                    Target.fallStart  = (int)Target.Center.Y / 16;
                    if (data.CarrySomeone)
                    {
                        Target.position.X -= 6 * guardian.Direction;
                    }
                    if (Target.itemAnimation == 0 && !Target.controlLeft && !Target.controlRight)
                    {
                        Target.ChangeDir(guardian.Direction * (FaceBear ? -1 : 1));
                    }
                    Target.AddBuff(ModContent.BuffType <Buffs.Hug>(), 5);
                    if (pm.KnockedOut)
                    {
                        pm.ReviveBoost += 3;
                    }
                    if (!Main.bloodMoon)
                    {
                        Target.immuneTime    = 3;
                        Target.immuneNoBlink = true;
                    }
                }
                if ((guardian.MessageTime == 0 || Main.bloodMoon) && (Target.controlLeft || Target.controlRight || Target.controlUp || Target.controlDown || (Main.bloodMoon && Target.controlJump)))
                {
                    if (Main.bloodMoon)
                    {
                        Target.controlJump = false;
                        bool Defeated = false, Hurt = false;
                        if (pm.ControllingGuardian)
                        {
                            pm.Guardian.FriendlyDuelDefeat = true;
                            Hurt = 0 != pm.Guardian.Hurt((int)(pm.Guardian.MHP * 0.22f), guardian.Direction, false, true, " were crushed by " + guardian.Name + "'s arms.");
                            if (pm.Guardian.Downed)
                            {
                                Defeated = true;
                            }
                        }
                        else
                        {
                            Target.GetModPlayer <PlayerMod>().FriendlyDuelDefeat = true;
                            Hurt = 0 != Target.Hurt(Terraria.DataStructures.PlayerDeathReason.ByCustomReason(Target.name + " were crushed by " + guardian.Name + "'s arms."), (int)(Target.statLifeMax2 * 0.22f), guardian.Direction);
                            if (Target.dead)
                            {
                                Defeated = true;
                            }
                        }
                        if (Hurt)
                        {
                            if (!Defeated)
                            {
                                if (guardian.BodyAnimationFrame == guardian.Base.ChairSittingFrame)
                                {
                                    switch (Main.rand.Next(5))
                                    {
                                    case 0:
                                        guardian.SaySomething("*I'll crush you if you move again!*");
                                        break;

                                    case 1:
                                        guardian.SaySomething("*I'll hurt you worser than those monsters would If you keep moving!*");
                                        break;

                                    case 2:
                                        guardian.SaySomething("*I can crush you with my arms or my legs, you pick!*");
                                        break;

                                    case 3:
                                        guardian.SaySomething("*Want me to turn your bones to dust?*");
                                        break;

                                    case 4:
                                        guardian.SaySomething("*You are angering me, more than this night does!*");
                                        break;
                                    }
                                }
                                else
                                {
                                    switch (Main.rand.Next(5))
                                    {
                                    case 0:
                                        guardian.SaySomething("*Stay quiet!*");
                                        break;

                                    case 1:
                                        guardian.SaySomething("*I'll crush your bones If you continue doing that!*");
                                        break;

                                    case 2:
                                        guardian.SaySomething("*I have my arms around you, I can pull them against my body, and you wont like it!*");
                                        break;

                                    case 3:
                                        guardian.SaySomething("*Want to try that again?*");
                                        break;

                                    case 4:
                                        guardian.SaySomething("*This is what you want?*");
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                switch (Main.rand.Next(5))
                                {
                                case 0:
                                    guardian.SaySomething("*Finally! You got quiet!*");
                                    break;

                                case 1:
                                    guardian.SaySomething("*See what you made me do?!*");
                                    break;

                                case 2:
                                    guardian.SaySomething("*My mood is already bad, you didn't helped either!*");
                                    break;

                                case 3:
                                    guardian.SaySomething("*At least you stopped moving around!*");
                                    break;

                                case 4:
                                    guardian.SaySomething("*You behave better when unconscious!*");
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        guardian.SaySomething("*Press Jump button If that's enough.*");
                    }
                }
                if (Target.whoAmI == Main.myPlayer)
                {
                    MainMod.FocusCameraPosition    = guardian.CenterPosition;
                    MainMod.FocusCameraPosition.X -= Main.screenWidth * 0.5f;
                    MainMod.FocusCameraPosition.Y -= Main.screenHeight * 0.5f;
                    ChatTime--;
                    const int InitialTime = 300;
                    if (ChatTime == -1)
                    {
                        ChatTime = InitialTime;
                    }
                    else if (ChatTime < 1)
                    {
                        ChatTime = 60 * 10; // + Main.rand.Next(InitialTime)
                        FriendshipPoints++;
                        if (FriendshipPoints >= 10 + guardian.FriendshipLevel / 3)
                        {
                            FriendshipPoints = 0;
                            guardian.IncreaseFriendshipProgress(1);
                        }
                        string Message = GuardianMouseOverAndDialogueInterface.MessageParser(Main.rand.Next(10) == 0 ? guardian.Base.TalkMessage(Target, guardian) : guardian.Base.NormalMessage(Target, guardian), guardian);
                        //if (Target.talkNPC > -1 && Main.npc[Target.talkNPC].type == ModContent.NPCType<GuardianNPC.List.BearNPC>())
                        //PlayerMod pm = Target.GetModPlayer<PlayerMod>();
                        if (pm.IsTalkingToAGuardian && pm.TalkingGuardianPosition == guardian.WhoAmID)
                        {
                            GuardianMouseOverAndDialogueInterface.SetDialogue(Message);
                        }
                        else
                        {
                            //guardian.SaySomething(Message);
                        }
                    }
                    else
                    {
                    }
                }
            }
        }