Exemplo n.º 1
0
        public void CreateRandomBonusBasedOnClass(int ClassID, string ClassModID = "")
        {
            ClassModID = MainMod.mod.Name;
            ClassBase cb = MainMod.GetClass(ClassID, ClassModID);

            if (cb.SkillList.Count == 0)
            {
                return;
            }
            ClassSkillInfo csi = cb.SkillList[Main.rand.Next(cb.SkillList.Count)];

            SkillID         = csi.SkillID;
            SkillModID      = csi.SkillMod;
            SkillLevelBonus = Main.rand.Next(1, MaxSkillLevelBonus + 1);
        }
Exemplo n.º 2
0
        public void OnBookUsed(Player player)
        {
            if (player.whoAmI != Main.myPlayer || LoreAlreadyUnlocked)
            {
                return;
            }
            ClassUnlockLoreBase ClassBase = GetBase;

            if (IsComplete || MainMod.DebugMode)
            {
                if (!LoreAlreadyUnlocked)
                {
                    MainMod.AddClassUnlocked(ClassID, ClassModID);
                    Main.NewText("You unlocked [" + GetClassName + "] class.", Microsoft.Xna.Framework.Color.LightBlue);
                }
                return;
            }
            for (int o = 0; o < ClassBase.Objectives.Count; o++)
            {
                if (!LoreInternalProgress[o].Complete)
                {
                    switch (ClassBase.Objectives[o].objectivetype)
                    {
                    case ClassUnlockLoreBase.ObjectiveType.GatherItem:
                    {
                        ClassUnlockLoreBase.GatherItemObjective gio = (ClassUnlockLoreBase.GatherItemObjective)ClassBase.Objectives[o];
                        for (int i = 0; i < 58; i++)
                        {
                            if (player.inventory[i].type == gio.ItemID)
                            {
                                int StackToReduce = gio.Stack - (int)LoreInternalProgress[o].StepValue;
                                if (player.inventory[i].stack < StackToReduce)
                                {
                                    StackToReduce = player.inventory[i].stack;
                                }
                                LoreInternalProgress[o].StepValue += StackToReduce;
                                player.inventory[i].stack         -= StackToReduce;
                            }
                        }
                    }
                    break;
                    }
                    break;
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// This is actually to get possible targets from Terraria, includding also targets from other mods.
        /// </summary>
        public TargetTranslator.Translator[] GetPossibleTargets(bool Allies, bool SelfIncluded = false, Vector2 Position = default(Vector2), float Distance = 0f, int MaxTargets = 0)
        {
            List <TargetTranslator.Translator> Targets = new List <TargetTranslator.Translator>();
            Player me = Main.player[Owner];

            for (int i = 0; i < 255; i++)
            {
                if (Main.player[i].active && (SelfIncluded || i != Owner))
                {
                    bool IsAlly = !Main.player[i].hostile || (me.team != 0 && me.team == Main.player[i].team);
                    if ((Allies && IsAlly) || (!Allies && !IsAlly))
                    {
                        Targets.Add(new TargetTranslator.PlayerTarget(Main.player[i]));
                    }
                }
                if (i < 200 && Main.npc[i].active)
                {
                    bool IsAlly = (Main.npc[i].townNPC || Main.npc[i].friendly);
                    if ((Allies && IsAlly) || (!Allies && !IsAlly))
                    {
                        Targets.Add(new TargetTranslator.NpcTarget(Main.npc[i]));
                    }
                }
            }
            Targets.AddRange(MainMod.GetOtherModTargets(me, Allies));
            if (Position != default(Vector2) && Distance > 0)
            {
                for (int t = 0; t < Targets.Count; t++)
                {
                    if ((Targets[t].Center - Position).Length() >= Distance) //Doesn't seems to work correctly with infos acquired from other mods.
                    {
                        Targets.RemoveAt(t);
                    }
                }
            }
            if (MaxTargets > 0)
            {
                while (Targets.Count > MaxTargets)
                {
                    Targets.RemoveAt(MaxTargets);
                }
            }
            return(Targets.ToArray());
        }
Exemplo n.º 4
0
        public TargetTranslator.Translator[] GetPossibleTargets(bool Allies, Rectangle rectangle, bool SelfIncluded = false, int MaxTargets = 0)
        {
            List <TargetTranslator.Translator> Targets = new List <TargetTranslator.Translator>();
            Player me = Main.player[Owner];

            for (int i = 0; i < 255; i++)
            {
                if (Main.player[i].active && (SelfIncluded || i != Owner))
                {
                    bool IsAlly = !Main.player[i].hostile || (me.team != 0 && me.team == Main.player[i].team);
                    if ((Allies && IsAlly) || (!Allies && !IsAlly))
                    {
                        Targets.Add(new TargetTranslator.PlayerTarget(Main.player[i]));
                    }
                }
                if (i < 200 && Main.npc[i].active)
                {
                    bool IsAlly = (Main.npc[i].townNPC || Main.npc[i].friendly);
                    if ((Allies && IsAlly) || (!Allies && !IsAlly))
                    {
                        Targets.Add(new TargetTranslator.NpcTarget(Main.npc[i]));
                    }
                }
            }
            Targets.AddRange(MainMod.GetOtherModTargets(me, Allies));
            for (int t = Targets.Count - 1; t >= 0; t--)
            {
                if (!Targets[t].GetRectangle.Intersects(rectangle))
                {
                    Targets.RemoveAt(t);
                }
            }
            if (MaxTargets > 0)
            {
                while (Targets.Count > MaxTargets)
                {
                    Targets.RemoveAt(MaxTargets);
                }
            }
            return(Targets.ToArray());
        }
Exemplo n.º 5
0
        }                                                                             //GetClass.GetLevelExp(Level); } }

        public void ChangeClass(int ClassID, string ClassModID = "")
        {
            if (ClassModID == "")
            {
                ClassModID = "TerraClasses";
            }
            this.ClassID    = ClassID;
            this.ClassModID = ClassModID;
            Skills.Clear();
            foreach (ClassSkillInfo skill in GetClass.SkillList)
            {
                SkillData sd = MainMod.GetSkill(skill.SkillID, skill.SkillMod).GetSkillData;
                sd.ID    = skill.SkillID;
                sd.ModID = skill.SkillMod;
                sd.Level = skill.FreeLevel;
                if (sd.Level > sd.MaxLevel)
                {
                    sd.Level = sd.MaxLevel;
                }
                Skills.Add(sd);
            }
        }
Exemplo n.º 6
0
        public static bool DrawLevelInfo()
        {
            ClassData cd           = Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().GetLastClass;
            Vector2   Offset       = new Vector2(Main.screenWidth * ExpBarOffset.X, Main.screenHeight * ExpBarOffset.Y);
            Vector2   DrawPosition = new Vector2(48f, Main.screenHeight - 50 + 10) + Offset;
            string    ClassName    = cd.Name;
            bool      MaxedClass   = cd.Level >= cd.MaxLevel;

            if (MaxedClass)
            {
                ClassName += " Master";
            }
            Vector2 TextDimension = Utils.DrawBorderString(Main.spriteBatch, ClassName, DrawPosition, (MaxedClass ? Color.Yellow : Color.White) * Main.cursorAlpha);

            DrawPosition.Y -= 10;
            bool MouseOver = false;

            if (!MaxedClass)
            {
                DrawPosition.X  = 4;
                DrawPosition.Y += 25;
                float LevelDist = Utils.DrawBorderString(Main.spriteBatch, cd.Level.ToString(), DrawPosition, Color.White * Main.cursorAlpha).X;
                DrawPosition.X += 150 + LevelDist + 4;
                Utils.DrawBorderString(Main.spriteBatch, (cd.Level + 1).ToString(), DrawPosition, Color.White * Main.cursorAlpha);
                DrawPosition.X -= 150 + 2;
                DrawPosition.Y += 5;
                Main.spriteBatch.Draw(LevelArrowTexture, DrawPosition, new Rectangle(0, 0, 150, 12), Color.White);
                DrawPosition.X += 2;
                DrawPosition.Y += 2;
                MouseOver       = Main.mouseX >= DrawPosition.X && Main.mouseX < DrawPosition.X + 150 &&
                                  Main.mouseY >= DrawPosition.Y && Main.mouseY < DrawPosition.Y + 12;
                if (cd.Exp > 0)
                {
                    int BarFill = (int)(144 * ((float)cd.Exp / cd.MaxExp));
                    if (BarFill > 144)
                    {
                        BarFill = 144;
                    }
                    Main.spriteBatch.Draw(LevelArrowTexture, DrawPosition, new Rectangle(152, 2, BarFill, 8), Color.Green * Main.cursorAlpha);
                }
            }
            if (MouseOver)
            {
                string  Text         = "Exp [" + cd.Exp + "/" + cd.MaxExp + "]";
                Vector2 TextPosition = new Vector2(Main.mouseX + 18, Main.mouseY + 18);
                if (TextPosition.Y >= Main.screenHeight - 22)
                {
                    TextPosition.Y = Main.screenHeight - 22;
                }
                Utils.DrawBorderString(Main.spriteBatch, Text, TextPosition, Color.White * Main.cursorAlpha);
            }
            Vector2 SkillInfoStartPosition = new Vector2(Main.screenWidth * 0.5f - 128 * 2, Main.screenHeight - 22);

            if (ClassSelectionInterface.Active)
            {
                SkillInfoStartPosition.Y -= ClassSelectionInterface.Height;
            }
            if (Main.playerInventory)
            {
                SkillInfoStartPosition.Y -= 32;
                if (!ClassSelectionInterface.Active)
                {
                    SkillInfoStartPosition.X -= Main.screenWidth * 0.2f;
                }
            }
            PlayerMod playerMod = Main.player[Main.myPlayer].GetModPlayer <PlayerMod>();

            if (playerMod.ActiveSkillsUnlocked && ClassSelectionInterface.ShowHud)
            {
                for (int s = 0; s < 4; s++)
                {
                    Color     c        = Color.White;
                    Color     barColor = Color.Black;
                    SkillData sd       = playerMod.GetSkillInfo(playerMod.ActiveSkill[s]);
                    float     Charge   = 1f;
                    if (sd != null)
                    {
                        if (sd.Active)
                        {
                            c      = Color.Gray;
                            Charge = 1f;
                        }
                        else if (sd.Cooldown > 0)
                        {
                            c        = Color.Gray;
                            Charge   = 1f - (float)sd.Cooldown / sd.GetBase.Cooldown;
                            barColor = Color.Red;
                        }
                        else
                        {
                            barColor = Color.Green;
                        }
                    }
                    Main.spriteBatch.Draw(Main.blackTileTexture, new Rectangle((int)SkillInfoStartPosition.X - 4, (int)SkillInfoStartPosition.Y, (int)(120 * Charge), 18), barColor);
                    DrawTextBorder(SkillInfoStartPosition, 128 - 16, Color.Yellow);
                    if ((Main.playerInventory && ClassSelectionInterface.Active) || SkillChangeSlot > -1)
                    {
                        if (Main.mouseX >= SkillInfoStartPosition.X && Main.mouseX < SkillInfoStartPosition.X + 128 &&
                            Main.mouseY >= SkillInfoStartPosition.Y && Main.mouseY < SkillInfoStartPosition.Y + 24)
                        {
                            playerMod.player.mouseInterface = true;
                            c = Color.Yellow;
                            if (Main.mouseLeft && Main.mouseLeftRelease)
                            {
                                if (SkillChangeSlot == s)
                                {
                                    SkillChangeSlot = -1;
                                }
                                else
                                {
                                    SkillChangeSlot      = s;
                                    Main.playerInventory = false;
                                }
                            }
                        }
                    }
                    string Text = "Active#" + s;
                    if (playerMod.ActiveSkill[s].ClassPosition > -1)
                    {
                        Text = playerMod.Classes[playerMod.ActiveSkill[s].ClassPosition].Skills[playerMod.ActiveSkill[s].SkillPosition].Name;
                    }
                    Utils.DrawBorderString(Main.spriteBatch, Text, SkillInfoStartPosition, c);
                    SkillInfoStartPosition.X += 128;
                }
                SkillInfoStartPosition.Y -= 24;
            }
            SkillInfoStartPosition.X = Main.screenWidth * 0.5f - 128 * 0.5f;
            if (Main.playerInventory)
            {
                if (!ClassSelectionInterface.Active)
                {
                    SkillInfoStartPosition.X -= Main.screenWidth * 0.20f;
                }
            }
            if (playerMod.CombatSkillsUnlocked)
            {
                Color     c      = Color.White;
                SkillData sd     = playerMod.GetSkillInfo(playerMod.CombatSkill);
                float     Charge = 1f;
                Main.spriteBatch.Draw(Main.blackTileTexture, new Rectangle((int)SkillInfoStartPosition.X - 4, (int)SkillInfoStartPosition.Y, 120, 18), Color.Black);
                DrawTextBorder(SkillInfoStartPosition, 128 - 16, Color.Red);
                if ((Main.playerInventory && ClassSelectionInterface.Active) || SkillChangeSlot > -1)
                {
                    if (Main.mouseX >= SkillInfoStartPosition.X && Main.mouseX < SkillInfoStartPosition.X + 128 &&
                        Main.mouseY >= SkillInfoStartPosition.Y && Main.mouseY < SkillInfoStartPosition.Y + 24)
                    {
                        c = Color.Yellow;
                        playerMod.player.mouseInterface = true;
                        if (Main.mouseLeft && Main.mouseLeftRelease)
                        {
                            if (SkillChangeSlot == 4)
                            {
                                SkillChangeSlot = -1;
                            }
                            else
                            {
                                SkillChangeSlot      = 4;
                                Main.playerInventory = false;
                            }
                        }
                    }
                }
                Utils.DrawBorderString(Main.spriteBatch, (playerMod.CombatSkill.ClassPosition > -1 ? playerMod.Classes[playerMod.CombatSkill.ClassPosition].Skills[playerMod.CombatSkill.SkillPosition].Name : "Combat Skill"), SkillInfoStartPosition, c);
            }
            if (SkillChangeSlot > -1)
            {
                Enum.SkillTypes Types = Enum.SkillTypes.Active;
                if (SkillChangeSlot == 4)
                {
                    Types = Enum.SkillTypes.Attack;
                }
                List <KeyValuePair <int, int> > AbleSkills = new List <KeyValuePair <int, int> >();
                for (int c = 0; c < playerMod.Classes.Count; c++)
                {
                    Vector2 SkillStartPosition = new Vector2(Main.screenWidth * 0.5f - (128 * playerMod.Classes.Count * 0.5f) + 128 * c, Main.screenHeight - 75);
                    for (int s = 0; s < playerMod.Classes[c].Skills.Count; s++)
                    {
                        SkillData sd = playerMod.Classes[c].Skills[s];
                        if (sd.SkillTypes == Types && sd.Level > 0)
                        {
                            Color color = Color.White;
                            if (Main.mouseX >= SkillStartPosition.X && Main.mouseX < SkillStartPosition.X + 128 &&
                                Main.mouseY >= SkillStartPosition.Y && Main.mouseY < SkillStartPosition.Y + 25)
                            {
                                color = Color.Yellow;
                                playerMod.player.mouseInterface = true;
                                if (Main.mouseLeft && Main.mouseLeftRelease)
                                {
                                    if (SkillChangeSlot == 4)
                                    {
                                        playerMod.CombatSkill.ClassPosition = c;
                                        playerMod.CombatSkill.SkillPosition = s;
                                    }
                                    else
                                    {
                                        playerMod.ActiveSkill[SkillChangeSlot].ClassPosition = c;
                                        playerMod.ActiveSkill[SkillChangeSlot].SkillPosition = s;
                                    }
                                    SkillChangeSlot = -1;
                                }
                            }
                            MainMod.DrawTextBorder(SkillStartPosition, 128 - 16, Color.White);
                            Utils.DrawBorderString(Main.spriteBatch, sd.Name, SkillStartPosition, color);
                            SkillStartPosition.Y -= 25;
                        }
                    }
                    SkillStartPosition.Y -= 3;
                    Utils.DrawBorderString(Main.spriteBatch, playerMod.Classes[c].Name, SkillStartPosition, Color.White, 1.2f);
                }
            }
            SkillInfoStartPosition.X += 128;
            if (!Main.playerInventory)
            {
                Vector2 Position  = new Vector2(Main.screenWidth * 0.5f, Main.screenHeight * 0.15f + 25f);
                int     StarCount = (int)Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().DifficultyLevel;
                Position.X -= (14 * StarCount) * 0.5f;
                for (int i = 0; i < StarCount; i++)
                {
                    Main.spriteBatch.Draw(StarTexture, Position, Color.White);
                    Position.X += 14;
                }
                //Utils.DrawBorderString(Main.spriteBatch, "Difficulty: "+ Main.player[Main.myPlayer].GetModPlayer<PlayerMod>().DifficultyLevel, Position, Color.Yellow, 0.85f, 0.5f);
            }
            DrawClassInfoInterface();
            return(true);
        }
Exemplo n.º 7
0
        public string GetBonusInfo()
        {
            string Text = MainMod.GetSkill(SkillID, SkillModID).Name + " Lv +" + SkillLevelBonus;

            return("[" + Text + "]");
        }
        public static void UpdateAndDraw()
        {
            if (!Main.playerInventory)
            {
                if (!ShowHud)
                {
                    ShowHud = true;
                }
                if (Active)
                {
                    Close();
                }
                return;
            }
            if (!ShowHud)
            {
                return;
            }
            Vector2 SkillInterfacePos = new Vector2(Main.screenWidth * 0.5f - Width * 0.5f, Main.screenHeight - Height);

            if (Active)
            {
                if (Main.mouseX >= SkillInterfacePos.X && Main.mouseX < SkillInterfacePos.X + Width &&
                    Main.mouseY >= SkillInterfacePos.Y && Main.mouseY < SkillInterfacePos.Y + Height)
                {
                    Main.player[Main.myPlayer].mouseInterface = true;
                }
                Main.spriteBatch.Draw(Main.blackTileTexture, new Rectangle((int)SkillInterfacePos.X - 2, (int)SkillInterfacePos.Y - 2, Width + 4, Height + 2), Color.Black);
                Main.spriteBatch.Draw(Main.blackTileTexture, new Rectangle((int)SkillInterfacePos.X, (int)SkillInterfacePos.Y, Width, Height), Color.OrangeRed);
                //Wiki page
                if (Active && SelectedClass > -1 && SelectedClass < Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().Classes.Count)
                {
                    Vector2 WikiPageButtonPosition = new Vector2(Main.screenWidth * 0.5f + Width * 0.5f - 2, Main.screenHeight - Height);
                    Color   color = Color.White;
                    if (Main.mouseX >= WikiPageButtonPosition.X - 40 && Main.mouseX < WikiPageButtonPosition.X &&
                        Main.mouseY >= WikiPageButtonPosition.Y + 2 && Main.mouseY < WikiPageButtonPosition.Y + 20)
                    {
                        color = Color.Yellow;
                        if (Main.mouseLeft && Main.mouseLeftRelease)
                        {
                            string WikiLink = "";
                            if (CheckedSkillID > -1)
                            {
                                SkillBase sb = MainMod.GetSkill(CheckedSkillID, CheckedSkillModID);
                                if (sb.WikiPage != null)
                                {
                                    WikiLink = sb.WikiPage;
                                }
                                else
                                {
                                    WikiLink = sb.Name;
                                }
                            }
                            else if (CheckedClassID > -1)
                            {
                                ClassBase sb = MainMod.GetClass(CheckedClassID, CheckedClassModID);
                                if (sb.WikiPage != null)
                                {
                                    WikiLink = sb.WikiPage;
                                }
                                else
                                {
                                    WikiLink = sb.Name;
                                }
                            }
                            else if (SelectedClass > -1)
                            {
                                ClassBase c = Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().Classes[SelectedClass].GetClass;
                                if (SelectedSkill > -1)
                                {
                                    SkillBase b = MainMod.GetSkill(c.SkillList[SelectedSkill].SkillID, c.SkillList[SelectedSkill].SkillMod);
                                    if (c.WikiPage != null)
                                    {
                                        WikiLink = b.WikiPage;
                                    }
                                    else
                                    {
                                        WikiLink = b.Name;
                                    }
                                }
                                else
                                {
                                    if (c.WikiPage != null)
                                    {
                                        WikiLink = c.WikiPage;
                                    }
                                    else
                                    {
                                        WikiLink = c.Name;
                                    }
                                }
                            }
                            if (WikiLink != "")
                            {
                                WikiLink = "https://nakano15-mods.fandom.com/wiki/" + WikiLink;
                                System.Diagnostics.Process.Start(WikiLink);
                            }
                        }
                    }
                    Utils.DrawBorderString(Main.spriteBatch, "Wiki", WikiPageButtonPosition, color, 0.75f, 1);
                }
                if (CheckedClassID > -1)
                {
                    SkillInterfacePos.X += 4;
                    SkillInterfacePos.Y += 4;
                    ClassBase cb = MainMod.GetClass(CheckedClassID, CheckedClassModID);
                    Utils.DrawBorderString(Main.spriteBatch, cb.Name, SkillInterfacePos, Color.White, 1.2f);
                    SkillInterfacePos.Y += 25;
                    Utils.DrawBorderString(Main.spriteBatch, "Type: " + cb.ClassType.ToString(), SkillInterfacePos, Color.White, 1.2f);
                    SkillInterfacePos.Y += 25;
                    Utils.DrawBorderString(Main.spriteBatch, "Max Level: " + cb.MaxLevel, SkillInterfacePos, Color.White);
                    SkillInterfacePos.Y += 22;
                    if (CheckedSkillID > -1)
                    {
                        SkillBase sb = MainMod.GetSkill(CheckedSkillID, CheckedSkillModID);
                        Utils.DrawBorderString(Main.spriteBatch, sb.Name, SkillInterfacePos, Color.White, 1.2f);
                        SkillInterfacePos.Y += 25;
                        Utils.DrawBorderString(Main.spriteBatch, "Type: " + sb.skillType.ToString(), SkillInterfacePos, Color.White, 1);
                        SkillInterfacePos.Y += 22;
                        string[] Desc = sb.Description.Split('\n');
                        foreach (string desc in Desc)
                        {
                            Utils.DrawBorderString(Main.spriteBatch, desc, SkillInterfacePos, Color.White, 0.8f);
                            SkillInterfacePos.Y += 18;
                        }
                        Vector2 ButtonPosition = new Vector2(Main.screenWidth * 0.5f - Width * 0.5f + 4 + Width - 68f, Main.screenHeight - 22);
                        Color   color          = Color.White;
                        if (Main.mouseX >= ButtonPosition.X && Main.mouseX < ButtonPosition.X + 68 && Main.mouseY >= ButtonPosition.Y && Main.mouseY < ButtonPosition.Y + 22)
                        {
                            color = Color.Yellow;
                            if (Main.mouseLeft && Main.mouseLeftRelease)
                            {
                                CheckedSkillID       = -1;
                                CheckedSkillModID    = "";
                                AskIfShouldResetThis = false;
                            }
                        }
                        Utils.DrawBorderString(Main.spriteBatch, "Return", ButtonPosition, color);
                    }
                    else
                    {
                        bool CanChangeClass = true;
                        if (cb.ClassType == ClassBase.ClassTypes.Aspect && Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().Classes.Any(x => x.GetClass.ClassType == ClassBase.ClassTypes.Aspect))
                        {
                            CanChangeClass = false;
                            Utils.DrawBorderString(Main.spriteBatch, "You can only have one Aspect class on your character.", SkillInterfacePos, Color.White, 0.85f);
                            SkillInterfacePos.Y += 22f;
                        }
                        string[] DescriptionConcat = cb.Description.Split('\n');
                        foreach (string s in DescriptionConcat)
                        {
                            Utils.DrawBorderString(Main.spriteBatch, s, SkillInterfacePos, Color.White, 0.8f);
                            SkillInterfacePos.Y += 18;
                        }
                        const int SkillColumns = 2;
                        int       SkillRows    = (int)((Main.screenHeight - SkillInterfacePos.Y) / 20);
                        for (int row = 0; row < SkillRows; row++)
                        {
                            for (int column = 0; column < SkillColumns; column++)
                            {
                                int            SkillIndex = column + SkillColumns * (row + ScrollY);
                                string         SkillName  = "Skill#" + SkillIndex;
                                SkillBase      sb         = null;
                                ClassSkillInfo csi;
                                if (SkillIndex < cb.SkillList.Count)
                                {
                                    csi       = cb.SkillList[SkillIndex];
                                    sb        = MainMod.GetSkill(csi.SkillID, csi.SkillMod);
                                    SkillName = sb.Name;
                                }
                                else
                                {
                                    continue;
                                }
                                Vector2 SkillPosition = new Vector2(128f * column, row * 25) + SkillInterfacePos;
                                Color   c             = Color.White;
                                if (Main.mouseX >= SkillPosition.X && Main.mouseX < SkillPosition.X + 128 &&
                                    Main.mouseY >= SkillPosition.Y && Main.mouseY < SkillPosition.Y + 25)
                                {
                                    c = Color.Cyan;
                                    if (Main.mouseLeft && Main.mouseLeftRelease)
                                    {
                                        CheckedSkillID       = csi.SkillID;
                                        CheckedSkillModID    = csi.SkillMod;
                                        AskIfShouldResetThis = false;
                                    }
                                }
                                Utils.DrawBorderString(Main.spriteBatch, SkillName, SkillPosition, c);
                            }
                        }
                        //
                        Vector2 ButtonPosition = new Vector2(Main.screenWidth * 0.5f - Width * 0.5f + 4, Main.screenHeight - 22);
                        Color   color          = Color.White;
                        if (Main.mouseX >= ButtonPosition.X && Main.mouseX < ButtonPosition.X + 86 && Main.mouseY >= ButtonPosition.Y && Main.mouseY < ButtonPosition.Y + 22)
                        {
                            color = Color.Yellow;
                            if (CanChangeClass && Main.mouseLeft && Main.mouseLeftRelease)
                            {
                                Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().AddClass(CheckedClassID, CheckedClassModID);
                                Main.NewText("You changed into " + cb.Name + " class!");
                                CheckedClassID    = -1;
                                CheckedClassModID = "";
                                Close();
                                AskIfShouldResetThis = false;
                            }
                        }
                        Utils.DrawBorderString(Main.spriteBatch, "Change Class", ButtonPosition, color);
                        //
                        ButtonPosition.X += Width - 68f;
                        color             = Color.Red;
                        if (Main.mouseX >= ButtonPosition.X && Main.mouseX < ButtonPosition.X + 68 && Main.mouseY >= ButtonPosition.Y && Main.mouseY < ButtonPosition.Y + 22)
                        {
                            color = Color.Yellow;
                            if (Main.mouseLeft && Main.mouseLeftRelease)
                            {
                                CheckedClassID    = -1;
                                CheckedClassModID = "";
                                Close();
                            }
                        }
                        Utils.DrawBorderString(Main.spriteBatch, "Close", ButtonPosition, color);
                    }
                    return;
                }
                if (SelectedSkill > -1)
                {
                    if (SelectedClass == -1)
                    {
                        SelectedSkill = -1;
                        return;
                    }
                    SkillInterfacePos.X += 4;
                    SkillInterfacePos.Y += 4;
                    ClassData cd = Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().Classes[SelectedClass];
                    SkillData sd = cd.Skills[SelectedSkill];
                    SkillBase sb = sd.GetBase;
                    Utils.DrawBorderString(Main.spriteBatch, sb.Name, SkillInterfacePos, Color.White, 1.2f);
                    SkillInterfacePos.Y += 25;
                    string t = "";
                    if (sd.Level == 0)
                    {
                        t = "Spend Skill Point to Unlock.";
                    }
                    else if (sd.Level > sb.MaxLevel)
                    {
                        t = "Overlevel " + (sd.Level - sb.MaxLevel);
                    }
                    else if (sd.Level == sb.MaxLevel)
                    {
                        t = "Mastered";
                    }
                    else
                    {
                        t = "Level [" + sd.Level + "/" + sb.MaxLevel + "]";
                    }
                    Color textColor = Color.White;
                    if (sd.Level < sb.MaxLevel && Main.mouseX >= SkillInterfacePos.X && Main.mouseX < SkillInterfacePos.X + 128 &&
                        Main.mouseY >= SkillInterfacePos.Y && Main.mouseY < SkillInterfacePos.Y + 20)
                    {
                        textColor = Color.Yellow;
                        if (Main.mouseLeft && Main.mouseLeftRelease && cd.SkillPoint > 0)
                        {
                            cd.SpendPointOnSkill(SelectedSkill);
                        }
                    }
                    Utils.DrawBorderString(Main.spriteBatch, t, SkillInterfacePos, textColor, 0.9f);
                    SkillInterfacePos.Y += 20;
                    Utils.DrawBorderString(Main.spriteBatch, sb.skillType.ToString(), SkillInterfacePos, Color.White, 0.9f);
                    SkillInterfacePos.Y += 26;
                    string[] DescriptionConcat = sb.Description.Split('\n');
                    foreach (string s in DescriptionConcat)
                    {
                        Utils.DrawBorderString(Main.spriteBatch, s, SkillInterfacePos, Color.White, 0.9f);
                        SkillInterfacePos.Y += 20;
                    }
                    SkillInterfacePos.Y += 26;
                    if (sd.Level == 0)
                    {
                        foreach (ClassSkillInfo csi in cd.GetClass.SkillList)
                        {
                            if (csi.SkillID == sd.ID && csi.SkillMod == sd.ModID)
                            {
                                for (int sqreq = 0; sqreq < 3; sqreq++)
                                {
                                    if (csi.SkillReqPosition[sqreq] == -1)
                                    {
                                        continue;
                                    }
                                    SkillData sdtwo = cd.Skills[csi.SkillReqPosition[sqreq]];
                                    if (sdtwo.Level < csi.SkillLevel[sqreq])
                                    {
                                        string T = "Requires " + MainMod.GetSkill(sdtwo.ID, sdtwo.ModID).Name + " Level " + csi.SkillLevel[sqreq];
                                        Utils.DrawBorderString(Main.spriteBatch, T, SkillInterfacePos, Color.Gray, 0.9f);
                                        SkillInterfacePos.Y += 21f;
                                    }
                                }
                            }
                        }
                    }
                    Vector2 SkillPointsPosition = new Vector2(Main.screenWidth * 0.5f - Width * 0.5f, Main.screenHeight - 22);
                    Utils.DrawBorderString(Main.spriteBatch, "Skill Points: " + cd.SkillPoint, SkillPointsPosition, Color.White);
                    SkillPointsPosition.X += Width - 56;
                    textColor              = Color.White;
                    if (Main.mouseX >= SkillPointsPosition.X && Main.mouseX < SkillPointsPosition.X + 56 && Main.mouseY >= SkillPointsPosition.Y && Main.mouseY < SkillPointsPosition.Y + 25)
                    {
                        textColor = Color.Red;
                        if (Main.mouseLeft && Main.mouseLeftRelease)
                        {
                            SelectedSkill = -1;
                        }
                    }
                    Utils.DrawBorderString(Main.spriteBatch, "Close", SkillPointsPosition, textColor);
                    //
                    if (sd.Level > 0)
                    {
                        SkillPointsPosition.X = Main.screenWidth * 0.5f;
                        if (AskIfShouldResetThis)
                        {
                            SkillPointsPosition.X -= 10;
                            textColor              = Color.White;
                            if (Main.mouseX >= SkillPointsPosition.X - 40 && Main.mouseX < SkillPointsPosition.X && Main.mouseY >= SkillPointsPosition.Y && Main.mouseY < SkillPointsPosition.Y + 22)
                            {
                                textColor = Color.Yellow;
                                if (Main.mouseLeft && Main.mouseLeftRelease)
                                {
                                    if (!Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().ResetSkill(SelectedClass, SelectedSkill))
                                    {
                                        Main.NewText("Something went wrong.");
                                    }
                                    AskIfShouldResetThis = false;
                                }
                            }
                            Utils.DrawBorderString(Main.spriteBatch, "Yes", SkillPointsPosition, textColor, 1f, 1f);

                            SkillPointsPosition.X = Main.screenWidth * 0.5f + 10;
                            textColor             = Color.White;
                            if (Main.mouseX >= SkillPointsPosition.X && Main.mouseX < SkillPointsPosition.X + 40 && Main.mouseY >= SkillPointsPosition.Y && Main.mouseY < SkillPointsPosition.Y + 22)
                            {
                                textColor = Color.Yellow;
                                if (Main.mouseLeft && Main.mouseLeftRelease)
                                {
                                    AskIfShouldResetThis = false;
                                }
                            }
                            Utils.DrawBorderString(Main.spriteBatch, "No", SkillPointsPosition, textColor, 1f, 0);
                            SkillPointsPosition.X -= 10;
                            SkillPointsPosition.Y -= 25;
                            Utils.DrawBorderString(Main.spriteBatch, "Are you sure that want to reset this skill?", SkillPointsPosition, Color.White, 1f, 0.5f);
                        }
                        else
                        {
                            textColor = Color.White;
                            if (Main.mouseX >= SkillPointsPosition.X - 30 && Main.mouseX < SkillPointsPosition.X + 30 && Main.mouseY >= SkillPointsPosition.Y && Main.mouseY < SkillPointsPosition.Y + 22)
                            {
                                textColor = Color.Yellow;
                                if (Main.mouseLeft && Main.mouseLeftRelease)
                                {
                                    AskIfShouldResetThis = true;
                                }
                            }
                            Utils.DrawBorderString(Main.spriteBatch, "Reset Skill", SkillPointsPosition, textColor, 1f, 0.5f);
                        }
                    }
                    return;
                }
                Main.spriteBatch.Draw(Main.blackTileTexture, new Rectangle((int)SkillInterfacePos.X + 4, (int)SkillInterfacePos.Y + 4, 128, Height - 8), Color.Goldenrod);
                bool          LastClassIsMaxed = false;
                List <string> ClassList        = new List <string>();
                bool          First            = true;
                foreach (ClassData c in Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().Classes)
                {
                    LastClassIsMaxed = c.Level >= c.MaxLevel;
                    if (First)
                    {
                        First = false;
                        continue;
                    }
                    ClassList.Add((LastClassIsMaxed ? "*" : "") + c.Name);
                }
                if (LastClassIsMaxed && Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().ClassChangeUnlocked&& ClassList.Count < MainMod.MaxClasses + 1)
                {
                    ClassList.Add("New Class");
                }
                int MaxClasses = Height / 25;
                if (ClassList.Count < MaxClasses)
                {
                    MaxClasses = ClassList.Count;
                }
                for (int i = 0; i < MaxClasses; i++)
                {
                    int     Index             = i + 1;
                    Vector2 ClassNamePosition = SkillInterfacePos + new Vector2(4, 4 + i * 25f);
                    bool    MouseOver         = Main.mouseX >= ClassNamePosition.X && Main.mouseX < ClassNamePosition.X + 96 && Main.mouseY >= ClassNamePosition.Y && Main.mouseY < ClassNamePosition.Y + 25;
                    Color   color             = Color.White;
                    bool    IsSelected        = SelectedClass == Index;
                    if (IsSelected)
                    {
                        color = Color.Yellow;
                    }
                    if (MouseOver)
                    {
                        color = Color.Cyan;
                        if (Main.mouseLeft && Main.mouseLeftRelease)
                        {
                            SelectedSkill = -1;
                            if (IsSelected)
                            {
                                SelectedClass = -1;
                            }
                            else
                            {
                                SelectedClass = Index;
                            }
                        }
                    }
                    Utils.DrawBorderString(Main.spriteBatch, ClassList[i], ClassNamePosition, color);
                }
                SkillInterfacePos.X += 128 + 12f;
                if (SelectedClass > -1)
                {
                    List <ClassData> classes = Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().Classes;
                    if (SelectedClass >= classes.Count)
                    {
                        Utils.DrawBorderString(Main.spriteBatch, "Class Advancement Disponible.", SkillInterfacePos, Color.White);
                        SkillInterfacePos.Y += 25f;
                        int Rows = 2, Columns = (Height - 25) / 25;
                        for (int c = 0; c < Columns; c++)
                        {
                            for (int r = 0; r < Rows; r++)
                            {
                                int Index = r + c * Rows;
                                if (Index >= MainMod.UnlockedClasses.Count)
                                {
                                    continue;
                                }
                                Vector2 Position      = SkillInterfacePos + new Vector2(r * 128, 25 * c);
                                Color   color         = Color.White;
                                int     ClassID       = MainMod.UnlockedClasses[Index].Key;
                                string  ClassModID    = MainMod.UnlockedClasses[Index].Value;
                                string  ClassName     = MainMod.GetClass(ClassID, ClassModID).Name;//"Class#" + Index;
                                bool    RepeatedClass = classes.Any(x => x.ClassID == ClassID && x.ClassModID == ClassModID);
                                if (RepeatedClass)
                                {
                                    color = Color.Gray;
                                }
                                else
                                {
                                    if (Main.mouseX >= Position.X && Main.mouseX < Position.X + 128 &&
                                        Main.mouseY >= Position.Y && Main.mouseY < Position.Y + 25)
                                    {
                                        color = Color.Yellow;
                                        if (Main.mouseLeft && Main.mouseLeftRelease)
                                        {
                                            CheckedClassID    = ClassID;
                                            CheckedClassModID = ClassModID;
                                        }
                                    }
                                }
                                Utils.DrawBorderString(Main.spriteBatch, ClassName, Position, color);
                            }
                        }
                    }
                    else
                    {
                        ClassData c = classes[SelectedClass];
                        Utils.DrawBorderString(Main.spriteBatch, c.Name, SkillInterfacePos, Color.White);
                        SkillInterfacePos.Y += 25f;
                        Utils.DrawBorderString(Main.spriteBatch, (c.Level < c.MaxLevel ? "Level: " + c.Level + "  Exp [" + c.Exp + "/" + c.MaxExp + "]" : "Mastered"), SkillInterfacePos, Color.White, 0.85f);
                        SkillInterfacePos.Y += 22f;
                        const int SkillColumns = 2;
                        int       SkillRows    = (int)((Main.screenHeight - SkillInterfacePos.Y) / 25 - (AskIfShouldResetThis ? 2 : 1));
                        for (int row = 0; row < SkillRows; row++)
                        {
                            for (int column = 0; column < SkillColumns; column++)
                            {
                                int    SkillIndex = column + SkillColumns * (row + ScrollY);
                                string SkillName  = "Skill#" + SkillIndex;
                                if (SkillIndex < c.Skills.Count)
                                {
                                    SkillName = c.Skills[SkillIndex].GetBase.Name;
                                }
                                else
                                {
                                    continue;
                                }
                                Vector2 SkillPosition = new Vector2(128f * column, row * 25) + SkillInterfacePos;
                                Color   color         = Color.White;
                                if (Main.mouseX >= SkillPosition.X && Main.mouseX < SkillPosition.X + 128 &&
                                    Main.mouseY >= SkillPosition.Y && Main.mouseY < SkillPosition.Y + 25)
                                {
                                    color = Color.Cyan;
                                    if (Main.mouseLeft && Main.mouseLeftRelease)
                                    {
                                        SelectedSkill = SkillIndex;
                                    }
                                }
                                Utils.DrawBorderString(Main.spriteBatch, SkillName, SkillPosition, color);
                            }
                        }
                        //
                        Vector2 SkillResetPos = new Vector2(Main.screenWidth * 0.5f, Main.screenHeight - 22);
                        Color   textColor;
                        if (AskIfShouldResetThis)
                        {
                            SkillResetPos.X -= 10;
                            textColor        = Color.White;
                            if (Main.mouseX >= SkillResetPos.X - 40 && Main.mouseX < SkillResetPos.X && Main.mouseY >= SkillResetPos.Y && Main.mouseY < SkillResetPos.Y + 22)
                            {
                                textColor = Color.Red;
                                if (Main.mouseLeft && Main.mouseLeftRelease)
                                {
                                    if (!Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().DeleteClass(SelectedClass))
                                    {
                                        Main.NewText("Something went wrong.");
                                    }
                                    else
                                    {
                                        SelectedClass = SelectedSkill = -1;
                                    }
                                    AskIfShouldResetThis = false;
                                }
                            }
                            Utils.DrawBorderString(Main.spriteBatch, "Yes", SkillResetPos, textColor, 1f, 1f);

                            SkillResetPos.X = Main.screenWidth * 0.5f + 10;
                            textColor       = Color.White;
                            if (Main.mouseX >= SkillResetPos.X && Main.mouseX < SkillResetPos.X + 40 && Main.mouseY >= SkillResetPos.Y && Main.mouseY < SkillResetPos.Y + 22)
                            {
                                textColor = Color.Yellow;
                                if (Main.mouseLeft && Main.mouseLeftRelease)
                                {
                                    AskIfShouldResetThis = false;
                                }
                            }
                            Utils.DrawBorderString(Main.spriteBatch, "No", SkillResetPos, textColor, 1f, 0);
                            SkillResetPos.X -= 10;
                            SkillResetPos.Y -= 25;
                            Utils.DrawBorderString(Main.spriteBatch, "Do you really want to delete this class?", SkillResetPos, Color.White, 1f, 0.5f);
                        }
                        else
                        {
                            textColor = Color.White;
                            if (Main.mouseX >= SkillResetPos.X - 30 && Main.mouseX < SkillResetPos.X + 30 && Main.mouseY >= SkillResetPos.Y && Main.mouseY < SkillResetPos.Y + 22)
                            {
                                textColor = Color.Red;
                                if (Main.mouseLeft && Main.mouseLeftRelease)
                                {
                                    AskIfShouldResetThis = true;
                                }
                            }
                            Utils.DrawBorderString(Main.spriteBatch, "Delete Class", SkillResetPos, textColor, 1f, 0.5f);
                        }
                    }
                }
                else
                {
                    SkillInterfacePos.X += (156 * 0.5f);
                    SkillInterfacePos.Y += (128 * 0.5f);
                    Utils.DrawBorderString(Main.spriteBatch, "No class selected.", SkillInterfacePos, Color.White, 1, 0.5f, 0.5f);
                }
            }
            {
                Vector2 ButtonPosition = new Vector2(Main.screenWidth * 0.5f - Width * 0.5f - 2, Main.screenHeight);
                if (Active)
                {
                    ButtonPosition.Y -= Height + 32;
                }
                else
                {
                    ButtonPosition.Y -= 32;
                }
                if (Main.mouseX >= ButtonPosition.X && Main.mouseX < ButtonPosition.X + 96 &&
                    Main.mouseY >= ButtonPosition.Y && Main.mouseY < ButtonPosition.Y + 32)
                {
                    Main.player[Main.myPlayer].mouseInterface = true;
                    if (Main.mouseLeft && Main.mouseLeftRelease)
                    {
                        if (Active)
                        {
                            Close();
                        }
                        else
                        {
                            Open();
                        }
                    }
                }
                Main.spriteBatch.Draw(MainMod.ClassButtonTexture, ButtonPosition, Color.White);
            }
        }
Exemplo n.º 9
0
 public override void Initialize()
 {
     MainMod.LoadLoreDatas();
 }
Exemplo n.º 10
0
 public override Terraria.ModLoader.IO.TagCompound Save()
 {
     MainMod.SaveLoreDatas();
     return(base.Save());
 }