Beispiel #1
0
        public static void UpdateShop()
        {
            if (!ShopOpen)
            {
                return;
            }
            for (int r = 0; r < Main.numAvailableRecipes; r++)
            {
                Main.availableRecipeY[r] = 2000;
            }
            PlayerMod pm = MainPlayer.GetModPlayer <PlayerMod>();

            if (!Main.playerInventory)
            {
                GuardianMouseOverAndDialogueInterface.CloseDialogue();
                //MainPlayer.GetModPlayer<PlayerMod>().IsTalkingToAGuardian = false;
                ShopOpen = false;
                return;
            }
        }
Beispiel #2
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);
     }
 }
 private void FailResult()
 {
     GuardianMouseOverAndDialogueInterface.CloseDialogue();
     ChangeStep(202);
 }
 private void Message(string Mes)
 {
     GuardianMouseOverAndDialogueInterface.SetDialogue(Mes);
 }
Beispiel #5
0
 private static void EndDialogueButtonAction()
 {
     GuardianMouseOverAndDialogueInterface.CloseDialogueButtonAction();
     ProceedButtonPressed = true;
 }
Beispiel #6
0
 public static void CloseDialogue()
 {
     GuardianMouseOverAndDialogueInterface.CloseDialogue(LastSpeaker);
 }
Beispiel #7
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);
 }
        public static void BlueWhenListeningToHerRequest()
        {
            ZacksOutfitQuestData data = (ZacksOutfitQuestData)Data;
            const int            BlueSlot = 0, ZacksSlot = 1;
            bool ZacksInTheTeam = PlayerMod.HasGuardianSummoned(Main.player[Main.myPlayer], GuardianBase.Zacks);

            if (ZacksInTheTeam)
            {
                Dialogue.AddParticipant(PlayerMod.GetPlayerSummonedGuardian(Main.player[Main.myPlayer], GuardianBase.Zacks));
            }
            Dialogue.SetImportantDialogue();
            Dialogue.GatherAroundGuardian(Dialogue.GetParticipant(BlueSlot));
            Dialogue.ShowDialogueWithContinue("*I'm glad for Zacks back into my life, but I think we should do something about his wounds.*");
            //After this point, Dialogue.GetParticipant breaks.
            if (ZacksInTheTeam)
            {
                Dialogue.ShowDialogueWithContinue("*I'm fine, those wounds doesn't hurt or anything.*", Dialogue.GetParticipant(ZacksSlot));
                Dialogue.ShowDialogueWithContinue("*It may not be hurting, but isn't the greatest thing to look at, even more at that hole in your chest.*", Dialogue.GetParticipant(BlueSlot));
                Dialogue.ShowDialogueWithContinue("*Oh, yeah... This is really a nasty thing to look at.*", Dialogue.GetParticipant(ZacksSlot));
                Dialogue.ShowDialogueWithContinue("*We need to patch up the wounds on your arms and feet, and wash the blood in your paws... Is that even your blood?*", Dialogue.GetParticipant(BlueSlot));
                Dialogue.ShowDialogueWithContinue("*I... Don't think... It is?*", Dialogue.GetParticipant(ZacksSlot));
                Dialogue.ShowDialogueWithContinue("*We definitelly have to wash that off.*", Dialogue.GetParticipant(BlueSlot));
            }
            Dialogue.ShowDialogueWithContinue("*We need something to patch up his wounds, and I think the Nurse may help us with that.*", Dialogue.GetParticipant(BlueSlot));
            Dialogue.ShowDialogueWithContinue("*Then we will need to visit the Clothier, and see if we can find something to cover the hole on his chest.*");
            if (Dialogue.ShowDialogueWithOptions("*Can you help me with this?*", new string[] { "Yes", "No" }) == 1)
            {
                if (ZacksInTheTeam)
                {
                    Dialogue.ShowDialogueWithContinue("*I guess [nickname] isn't feeling like helping you with that right now.*", Dialogue.GetParticipant(ZacksSlot));
                    Dialogue.ShowEndDialogueMessage("*It's fine. I still want to do this some time, so if you feel like helping me, just speak to me about that.*", false, Dialogue.GetParticipant(BlueSlot));
                }
                else
                {
                    Dialogue.ShowEndDialogueMessage("*Oh... I'll leave this open for when you decide to help me with this.*", false);
                }
                return;
            }
            Dialogue.ShowDialogueWithContinue("*Thank you, [nickname].*", Dialogue.GetParticipant(BlueSlot));
            if (ZacksInTheTeam)
            {
                Dialogue.ShowDialogueWithContinue("*That actually sounds like a good plan, I like it.*", Dialogue.GetParticipant(ZacksSlot));
                Dialogue.ChangeSpeaker(BlueSlot);
                data.QuestStep = 3;
            }
            else
            {
                data.QuestStep = 2;
            }
            QuestStartedNotification(data);
            Dialogue.ShowDialogueWithContinue("*For this to work, we need to go see those people ourselves.*", Dialogue.GetParticipant(BlueSlot));
            if (!PlayerMod.PlayerHasGuardianSummoned(Main.player[Main.myPlayer], GuardianBase.Blue))
            {
                Dialogue.ShowDialogueOnly("*And by \"we\", that means I need to come too.*");
                GuardianMouseOverAndDialogueInterface.GetDefaultOptions();
            }
            else
            {
                Dialogue.ShowEndDialogueMessage("*So, shall we go?*", true);
            }
        }
Beispiel #9
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
                    {
                    }
                }
            }
        }
Beispiel #10
0
 public override void Update(TerraGuardian guardian)
 {
     if ((guardian.Position - Target.Position).Length() < 20)
     {
         guardian.WalkMode = true;
     }
     if (guardian.UsingFurniture)
     {
         guardian.LeaveFurniture(true);
     }
     guardian.StuckTimer = 0;
     if (guardian.IsBeingPulledByPlayer)
     {
         guardian.SaySomething("*Alright, I'm coming, I'm coming.*");
         InUse = false;
         return;
     }
     guardian.MoveLeft = guardian.MoveRight = false;
     Sleuthing         = false;
     if (!Target.KnockedOut && !Target.IsSleeping)
     {
         if (SleuthPercent > 70)
         {
             guardian.SaySomething("*...So close...*");
         }
         else
         {
             guardian.SaySomething(Target.GetMessage(GuardianBase.MessageIDs.AlexanderSleuthingFail, "*I... Was just checking if you were fine.*"));
         }
         InUse = false;
         return;
     }
     if (Target.Downed)
     {
         InUse = false;
         guardian.SaySomething("*...I should have helped instead...*");
         return;
     }
     if (Math.Abs(guardian.Position.X - Target.Position.X) < 8f)
     {
         if (guardian.Velocity.X == 0 && guardian.Velocity.Y == 0)
         {
             Sleuthing            = true;
             guardian.LookingLeft = (Target.Position.X < guardian.Position.X);
             float LastSleuthPercent = SleuthPercent;
             float FillSpeed         = guardian.IsSleeping ? 0.07f : 0.2f;
             SleuthPercent += Main.rand.NextFloat() * FillSpeed;
             if (SleuthPercent >= 100)
             {
                 AlexanderBase.AlexanderData data = (AlexanderBase.AlexanderData)guardian.Data;
                 data.AddIdentifiedGuardian(Target.MyID);
                 InUse = false;
                 guardian.SaySomething(GuardianMouseOverAndDialogueInterface.MessageParser(Target.GetMessage(GuardianBase.MessageIDs.AlexanderSleuthingProgressFinished, "*Okay, so that's how you work.*"), guardian));
                 guardian.UpdateStatus = true;
             }
             else if (SleuthPercent >= 70 && LastSleuthPercent < 70)
             {
                 guardian.SaySomething(GuardianMouseOverAndDialogueInterface.MessageParser(Target.GetMessage(GuardianBase.MessageIDs.AlexanderSleuthingProgressNearlyDone, "*Hm... Interesting...*"), guardian));
             }
             else if (SleuthPercent >= 35 && LastSleuthPercent < 35)
             {
                 guardian.SaySomething(GuardianMouseOverAndDialogueInterface.MessageParser(Target.GetMessage(GuardianBase.MessageIDs.AlexanderSleuthingProgress, "*Uh huh...*"), guardian));
             }
             else if (SleuthPercent > 0 && LastSleuthPercent <= 0)
             {
                 guardian.SaySomething(GuardianMouseOverAndDialogueInterface.MessageParser(Target.GetMessage(GuardianBase.MessageIDs.AlexanderSleuthingStart, "*Let's see how you work...*"), guardian));
             }
         }
     }
     else
     {
         if (Target.Position.X < guardian.Position.X)
         {
             guardian.MoveLeft = true;
         }
         else
         {
             guardian.MoveRight = true;
         }
     }
 }
Beispiel #11
0
        public static void DrawShop()
        {
            if (!ShopOpen)
            {
                return;
            }
            Main.craftingHide = true;
            for (int i = 0; i < Main.availableRecipeY.Length; i++)
            {
                Main.availableRecipeY[i] = Main.screenHeight * 2;
            }
            TerraGuardian tg           = MainMod.ActiveGuardians[MainPlayer.GetModPlayer <PlayerMod>().TalkingGuardianPosition];
            Vector2       DrawPosition = ShopStartPosition;
            Color         color        = new Color(200, 200, 200, 200);

            GuardianMouseOverAndDialogueInterface.DrawBackgroundPanel(DrawPosition, 464, 32, color);
            if (Main.mouseX >= DrawPosition.X && Main.mouseX < DrawPosition.X + 464 && Main.mouseY >= DrawPosition.Y && Main.mouseY < DrawPosition.Y + 32 + 60 * 6)
            {
                MainPlayer.mouseInterface = true;
            }
            DrawPosition.X += 16;
            DrawPosition.Y += 16;
            tg.DrawHead(DrawPosition);
            DrawPosition.X += 16;
            Utils.DrawBorderString(Main.spriteBatch, LastStoreMessage, DrawPosition, Color.White * Main.cursorAlpha, 1f, 0, 0.5f);
            DrawPosition.Y += 16;
            DrawPosition.X -= 32;
            GuardianMouseOverAndDialogueInterface.DrawBackgroundPanel(DrawPosition, 464, 60 * 6, color);
            GuardianShopHandler.GuardianShopItem[] Items = ItemsForSale;
            int NewSelectedItem = -1;

            for (int x = 0; x < 1; x++)
            {
                for (int y = 0; y < 6; y++)
                {
                    int     Index        = y + x * 6 + Scroll;
                    Vector2 SlotPosition = DrawPosition;
                    //if (x == 1)
                    //    SlotPosition.X += 256;
                    SlotPosition.Y += 60 * y;
                    if (Index < Items.Length)
                    {
                        if (y > 0)
                        {
                            Rectangle rect = new Rectangle((int)SlotPosition.X + 4, (int)SlotPosition.Y - 1, 456, 2);
                            Main.spriteBatch.Draw(Main.blackTileTexture, rect, null, Color.LightBlue);
                        }
                        GuardianShopHandler.GuardianShopItem Item = Items[Index];
                        Texture2D ItemTexture = Main.itemTexture[Item.ItemID];
                        float     ItemScale   = 1f;
                        if (ItemTexture.Width > ItemTexture.Height)
                        {
                            ItemScale = 48 / (float)ItemTexture.Width;
                        }
                        else
                        {
                            ItemScale = 48 / (float)ItemTexture.Height;
                        }
                        if (ItemScale > 1f)
                        {
                            ItemScale = 1f;
                        }
                        Vector2 ItemPosition = SlotPosition;
                        GuardianMouseOverAndDialogueInterface.DrawBackgroundPanel(ItemPosition - new Vector2(2, 2), 60, 60, Color.Black);
                        GuardianMouseOverAndDialogueInterface.DrawBackgroundPanel(ItemPosition, 56, 56, Color.LightBlue);
                        ItemPosition.X += 28;
                        ItemPosition.Y += 28;
                        Main.spriteBatch.Draw(ItemTexture, ItemPosition, null, Color.White, 0f, new Vector2(ItemTexture.Width, ItemTexture.Height) * 0.5f, ItemScale, SpriteEffects.None, 0f);
                        SlotPosition.X += 56;
                        bool   CanBuy    = Item.IsItemDisponible() && Item.Stack != 0;
                        Color  itemcolor = CanBuy ? Color.White : Color.Red;
                        string ItemName  = Item.ItemName;
                        if (Item.SellStack > 1)
                        {
                            ItemName += "x" + Item.SellStack;
                        }
                        if (Item.Stack > -1)
                        {
                            ItemName += " (" + Item.Stack + " more)";
                        }
                        if (Item.disponibility == GuardianShopHandler.GuardianShopItem.DisponibilityTime.Timed)
                        {
                            int h = 0, m = 0, s = Item.TimedSaleTime / 60;
                            if (s >= 60)
                            {
                                m += s / 60;
                                s -= m * 60;
                            }
                            if (m >= 60)
                            {
                                h += m / 60;
                                m -= h * 60;
                            }
                            if (h > 0)
                            {
                                ItemName += " " + h + " Hours left.";
                            }
                            else if (m > 0)
                            {
                                ItemName += " " + m + " Minutes left.";
                            }
                            else if (s > 0)
                            {
                                ItemName += " " + s + " Seconds left.";
                            }
                        }
                        Utils.DrawBorderString(Main.spriteBatch, ItemName, SlotPosition, itemcolor, 1f);
                        SlotPosition.Y += 30;
                        string PriceText = "";
                        int    Price     = Item.Price;
                        bool   IsSale    = false;
                        if (Item.SaleTime > 0 && Item.SaleFactor > 0)
                        {
                            IsSale = true;
                            Price -= (int)(Price * Item.SaleFactor);
                        }
                        if (Item.SellStack > 0)
                        {
                            Price *= Item.SellStack;
                        }
                        {
                            int p = 0, g = 0, s = 0, c = Price;
                            if (c >= 100)
                            {
                                s += c / 100;
                                c -= s * 100;
                            }
                            if (s >= 100)
                            {
                                g += s / 100;
                                s -= g * 100;
                            }
                            if (g >= 100)
                            {
                                p += g / 100;
                                g -= p * 100;
                            }
                            bool First = true;
                            if (p > 0)
                            {
                                PriceText += p + "p";
                                First      = false;
                            }
                            if (g > 0)
                            {
                                if (!First)
                                {
                                    PriceText += " ";
                                }
                                PriceText += g + "g";
                                First      = false;
                            }
                            if (s > 0)
                            {
                                if (!First)
                                {
                                    PriceText += " ";
                                }
                                PriceText += s + "s";
                                First      = false;
                            }
                            if (c > 0)
                            {
                                if (!First)
                                {
                                    PriceText += " ";
                                }
                                PriceText += c + "c";
                                First      = false;
                            }
                        }
                        if (IsSale)
                        {
                            PriceText += " | (" + Math.Round(Item.SaleFactor * 100) + "% Off) ";
                            int h = 0, m = 0, s = Item.SaleTime / 60;
                            if (s >= 60)
                            {
                                m += s / 60;
                                s -= m * 60;
                            }
                            if (m >= 60)
                            {
                                h += m / 60;
                                m -= h * 60;
                            }
                            bool First = true;
                            if (h > 0)
                            {
                                PriceText += h + " hours left.";
                                First      = false;
                            }
                            else if (m > 0)
                            {
                                if (First)
                                {
                                    PriceText += ", ";
                                }
                                if (!First && m < 10)
                                {
                                    PriceText += '0';
                                }
                                PriceText += m + " minutes left.";
                                First      = false;
                            }
                            else if (s > 0)
                            {
                                if (First)
                                {
                                    PriceText += ", ";
                                }
                                if (!First && s < 10)
                                {
                                    PriceText += '0';
                                }
                                PriceText += s + " seconds left.";
                                First      = false;
                            }
                        }
                        Utils.DrawBorderString(Main.spriteBatch, PriceText, SlotPosition, itemcolor, 1f, 0, 0);
                        SlotPosition.X += 336f;
                        Vector2 Dim = Utils.DrawBorderString(Main.spriteBatch, (Item.Stack == 0 ? "Sold Out" : (CanBuy ? "Buy" : "Indisponible")), SlotPosition, SelectedItem == Index ? Color.Yellow : Color.White, 1f, 0, 0.5f);
                        if (Main.mouseX >= SlotPosition.X && Main.mouseX < SlotPosition.X + Dim.X &&
                            Main.mouseY >= SlotPosition.Y - Dim.Y * 0.5f && Main.mouseY < SlotPosition.Y + Dim.Y * 0.5f)
                        {
                            NewSelectedItem = Index;
                            if (CanBuy && Main.mouseLeft && Main.mouseLeftRelease)
                            {
                                if (!MainPlayer.inventory.Take(50).Any(f => f.type == 0))
                                {
                                    LastStoreMessage = tg.Base.GetSpecialMessage(GuardianBase.MessageIDs.StoreFullInventoryMessage);
                                    if (LastStoreMessage == "")
                                    {
                                        LastStoreMessage = "*Your inventory is full.*";
                                    }
                                }
                                else if (!MainPlayer.BuyItem(Price))
                                {
                                    LastStoreMessage = tg.Base.GetSpecialMessage(GuardianBase.MessageIDs.StoreNoCoinsMessage);
                                    if (LastStoreMessage == "")
                                    {
                                        LastStoreMessage = "*You can't pay for that.*";
                                    }
                                }
                                else
                                {
                                    //Buy Item :D
                                    Item item = new Item();
                                    item.SetDefaults(Item.ItemID, true);
                                    if (Item.SellStack > 0)
                                    {
                                        item.stack = Item.SellStack;
                                    }
                                    if (Item.ItemName != item.Name)
                                    {
                                        item.SetNameOverride(Item.ItemName);
                                    }
                                    MainPlayer.GetItem(MainPlayer.whoAmI, item);
                                    LastStoreMessage = tg.Base.GetSpecialMessage(GuardianBase.MessageIDs.StoreBuyMessage);
                                    if (LastStoreMessage == "")
                                    {
                                        LastStoreMessage = "*Thank you.*";
                                    }
                                }
                            }
                        }
                    }
                }
            }
            SelectedItem = NewSelectedItem;
        }
Beispiel #12
0
 public void GetRandomTip()
 {
     Dialogue.ShowDialogueOnly(GuardianSpawnTip.GetRandomTip());
     GuardianMouseOverAndDialogueInterface.GetDefaultOptions();
 }