Ejemplo n.º 1
0
        /// <summary>Raised after drawing the HUD (item toolbar, clock, etc) to the sprite batch, but before it's rendered to the screen. The vanilla HUD may be hidden at this point (e.g. because a menu is open).</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        public static void onRenderedHud(object sender, RenderedHudEventArgs e)
        {
            if (Game1.activeClickableMenu != null || Game1.eventUp || Game1.player.getMaxMana() == 0)
            {
                return;
            }

            SpriteBatch b = e.SpriteBatch;

            Vector2 manaPos = new Vector2(20, Game1.viewport.Height - manaBg.Height * 4 - 20);

            b.Draw(manaBg, manaPos, new Rectangle(0, 0, manaBg.Width, manaBg.Height), Color.White, 0, new Vector2(), 4, SpriteEffects.None, 1);
            if (Game1.player.getCurrentMana() > 0)
            {
                Rectangle targetArea = new Rectangle(3, 13, 6, 41);
                float     perc       = Game1.player.getCurrentMana() / (float)Game1.player.getMaxMana();
                int       h          = (int)(targetArea.Height * perc);
                targetArea.Y     += targetArea.Height - h;
                targetArea.Height = h;

                targetArea.X      *= 4;
                targetArea.Y      *= 4;
                targetArea.Width  *= 4;
                targetArea.Height *= 4;
                targetArea.X      += (int)manaPos.X;
                targetArea.Y      += (int)manaPos.Y;
                b.Draw(manaFg, targetArea, new Rectangle(0, 0, 1, 1), Color.White);

                if ((double)Game1.getOldMouseX() >= (double)targetArea.X && (double)Game1.getOldMouseY() >= (double)targetArea.Y && (double)Game1.getOldMouseX() < (double)targetArea.X + targetArea.Width && Game1.getOldMouseY() < targetArea.Y + targetArea.Height)
                {
                    Game1.drawWithBorder(Math.Max(0, (int)Game1.player.getCurrentMana()).ToString() + "/" + Game1.player.getMaxMana(), Color.Black * 0.0f, Color.White, new Vector2(Game1.getOldMouseX(), Game1.getOldMouseY() - 32));
                }
            }

            bool hasFifthSpellSlot = Game1.player.HasCustomProfession(Skill.ProfessionFifthSpellSlot);

            int spotYAffector = -1;

            if (hasFifthSpellSlot)
            {
                spotYAffector = 0;
            }
            Point[] spots =
                new Point[5]/*
                             * {
                             * new Point((int)manaPos.X + manaBg.Width * 4 + 20 + 40, Game1.viewport.Height - 20 - 50 - 30 - 50 - 25),
                             * new Point((int)manaPos.X + manaBg.Width * 4 + 20 + 50 + 30, Game1.viewport.Height - 20 - 50 - 40 - 25),
                             * new Point((int)manaPos.X + manaBg.Width * 4 + 20 + 40, Game1.viewport.Height - 20 - 50 - 25 ),
                             * new Point((int)manaPos.X + manaBg.Width * 4 + 20, Game1.viewport.Height - 20 - 50 - 40 - 25 ),
                             * };*/
            {
                new Point((int)manaPos.X + manaBg.Width * 4 + 20 + 60 * 0, Game1.viewport.Height - 20 - 50 - 60 * (4 + spotYAffector)),
                new Point((int)manaPos.X + manaBg.Width * 4 + 20 + 60 * 0, Game1.viewport.Height - 20 - 50 - 60 * (3 + spotYAffector)),
                new Point((int)manaPos.X + manaBg.Width * 4 + 20 + 60 * 0, Game1.viewport.Height - 20 - 50 - 60 * (2 + spotYAffector)),
                new Point((int)manaPos.X + manaBg.Width * 4 + 20 + 60 * 0, Game1.viewport.Height - 20 - 50 - 60 * (1 + spotYAffector)),
                new Point((int)manaPos.X + manaBg.Width * 4 + 20 + 60 * 0, Game1.viewport.Height - 20 - 50 - 60 * (0 + spotYAffector)),
            };

            SpellBook book = Game1.player.getSpellBook();

            if (book == null || book.selectedPrepared >= book.prepared.Length)
            {
                return;
            }
            PreparedSpell[] prepared = book.getPreparedSpells();

            for (int i = 0; i < (hasFifthSpellSlot ? 5 : 4); ++i)
            {
                b.Draw(spellBg, new Rectangle(spots[i].X, spots[i].Y, 50, 50), Color.White);
            }

            string prepStr = (book.selectedPrepared + 1) + "/" + book.prepared.Length;

            b.DrawString(Game1.dialogueFont, prepStr, new Vector2(spots[Game1.down].X + 25 + 2, spots[Game1.up].Y - 35 + 0), Color.Black, 0, new Vector2(Game1.dialogueFont.MeasureString(prepStr).X / 2, 0), 0.6f, SpriteEffects.None, 0);
            b.DrawString(Game1.dialogueFont, prepStr, new Vector2(spots[Game1.down].X + 25 - 2, spots[Game1.up].Y - 35 + 0), Color.Black, 0, new Vector2(Game1.dialogueFont.MeasureString(prepStr).X / 2, 0), 0.6f, SpriteEffects.None, 0);
            b.DrawString(Game1.dialogueFont, prepStr, new Vector2(spots[Game1.down].X + 25 + 0, spots[Game1.up].Y - 35 + 2), Color.Black, 0, new Vector2(Game1.dialogueFont.MeasureString(prepStr).X / 2, 0), 0.6f, SpriteEffects.None, 0);
            b.DrawString(Game1.dialogueFont, prepStr, new Vector2(spots[Game1.down].X + 25 + 0, spots[Game1.up].Y - 35 - 2), Color.Black, 0, new Vector2(Game1.dialogueFont.MeasureString(prepStr).X / 2, 0), 0.6f, SpriteEffects.None, 0);
            b.DrawString(Game1.dialogueFont, prepStr, new Vector2(spots[Game1.down].X + 25, spots[Game1.up].Y - 35), Color.White, 0, new Vector2(Game1.dialogueFont.MeasureString(prepStr).X / 2, 0), 0.6f, SpriteEffects.None, 0);

            for (int i = 0; i < (hasFifthSpellSlot ? 5 : 4); ++i)
            {
                if (i >= prepared.Length)
                {
                    break;
                }

                PreparedSpell prep = prepared[i];
                if (prep == null)
                {
                    continue;
                }

                Spell spell = SpellBook.get(prep.SpellId);
                if (spell == null || spell.Icons.Length <= prep.Level || spell.Icons[prep.Level] == null)
                {
                    continue;
                }

                b.Draw(spell.Icons[prep.Level], new Rectangle(spots[i].X, spots[i].Y, 50, 50), Game1.player.canCastSpell(spell, prep.Level) ? Color.White : new Color(128, 128, 128));
            }
        }
Ejemplo n.º 2
0
        /// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private static void onButtonPressed(object sender, ButtonPressedEventArgs e)
        {
            bool hasFifthSpellSlot = Game1.player.HasCustomProfession(Skill.ProfessionFifthSpellSlot);

            if (e.Button == Config.Key_Cast)
            {
                castPressed = true;
            }

            if (Data == null || Game1.activeClickableMenu != null)
            {
                return;
            }
            if (e.Button == Config.Key_SwapSpells)
            {
                Game1.player.getSpellBook().swapPreparedSet();
            }
            else if (castPressed &&
                     (e.Button == Config.Key_Spell1 || e.Button == Config.Key_Spell2 ||
                      e.Button == Config.Key_Spell3 || e.Button == Config.Key_Spell4 ||
                      (e.Button == Config.Key_Spell5 && hasFifthSpellSlot)))
            {
                int slot = 0;
                if (e.Button == Config.Key_Spell1)
                {
                    slot = 0;
                }
                else if (e.Button == Config.Key_Spell2)
                {
                    slot = 1;
                }
                else if (e.Button == Config.Key_Spell3)
                {
                    slot = 2;
                }
                else if (e.Button == Config.Key_Spell4)
                {
                    slot = 3;
                }
                else if (e.Button == Config.Key_Spell5)
                {
                    slot = 4;
                }

                Magic.inputHelper.Suppress(e.Button);

                SpellBook       book     = Game1.player.getSpellBook();
                PreparedSpell[] prepared = book.getPreparedSpells();
                if (prepared[slot] == null)
                {
                    return;
                }
                PreparedSpell prep = prepared[slot];

                Spell toCast = SpellBook.get(prep.SpellId);
                if (toCast == null)
                {
                    return;
                }

                //Log.trace("MEOW " + prep.SpellId + " " + prep.Level + " " + Game1.player.canCastSpell(toCast, prep.Level));
                if (Game1.player.canCastSpell(toCast, prep.Level))
                {
                    Log.trace("Casting " + prep.SpellId);

                    IActiveEffect effect = Game1.player.castSpell(toCast, prep.Level);
                    if (effect != null)
                    {
                        activeEffects.Add(effect);
                    }
                    Game1.player.addMana(-toCast.getManaCost(Game1.player, prep.Level));
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>Raised after drawing the HUD (item toolbar, clock, etc) to the sprite batch, but before it's rendered to the screen. The vanilla HUD may be hidden at this point (e.g. because a menu is open).</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        public static void onRenderedHud(object sender, RenderedHudEventArgs e)
        {
            if (Game1.activeClickableMenu != null || Game1.eventUp || Game1.player.getMaxMana() == 0)
            {
                return;
            }

            SpriteBatch b = e.SpriteBatch;

            Vector2 manaPos = new Vector2(20, Game1.viewport.Height - 56 * 4 - 20);

            bool hasFifthSpellSlot = Game1.player.HasCustomProfession(Skill.ProfessionFifthSpellSlot);

            int spotYAffector = -1;

            if (hasFifthSpellSlot)
            {
                spotYAffector = 0;
            }
            Point[] spots =
                new Point[5]/*
                             * {
                             * new Point((int)manaPos.X + manaBg.Width * 4 + 20 + 40, Game1.viewport.Height - 20 - 50 - 30 - 50 - 25),
                             * new Point((int)manaPos.X + manaBg.Width * 4 + 20 + 50 + 30, Game1.viewport.Height - 20 - 50 - 40 - 25),
                             * new Point((int)manaPos.X + manaBg.Width * 4 + 20 + 40, Game1.viewport.Height - 20 - 50 - 25 ),
                             * new Point((int)manaPos.X + manaBg.Width * 4 + 20, Game1.viewport.Height - 20 - 50 - 40 - 25 ),
                             * };*/
            {
                new Point((int)manaPos.X + manaBg.Width * 4 + 20 + 60 * 0, Game1.viewport.Height - 20 - 50 - 60 * (4 + spotYAffector)),
                new Point((int)manaPos.X + manaBg.Width * 4 + 20 + 60 * 0, Game1.viewport.Height - 20 - 50 - 60 * (3 + spotYAffector)),
                new Point((int)manaPos.X + manaBg.Width * 4 + 20 + 60 * 0, Game1.viewport.Height - 20 - 50 - 60 * (2 + spotYAffector)),
                new Point((int)manaPos.X + manaBg.Width * 4 + 20 + 60 * 0, Game1.viewport.Height - 20 - 50 - 60 * (1 + spotYAffector)),
                new Point((int)manaPos.X + manaBg.Width * 4 + 20 + 60 * 0, Game1.viewport.Height - 20 - 50 - 60 * (0 + spotYAffector)),
            };

            SpellBook book = Game1.player.getSpellBook();

            if (book == null || book.selectedPrepared >= book.prepared.Length)
            {
                return;
            }
            PreparedSpell[] prepared = book.getPreparedSpells();

            for (int i = 0; i < (hasFifthSpellSlot ? 5 : 4); ++i)
            {
                b.Draw(spellBg, new Rectangle(spots[i].X, spots[i].Y, 50, 50), Color.White);
            }

            string prepStr = (book.selectedPrepared + 1) + "/" + book.prepared.Length;

            b.DrawString(Game1.dialogueFont, prepStr, new Vector2(spots[Game1.down].X + 25 + 2, spots[Game1.up].Y - 35 + 0), Color.Black, 0, new Vector2(Game1.dialogueFont.MeasureString(prepStr).X / 2, 0), 0.6f, SpriteEffects.None, 0);
            b.DrawString(Game1.dialogueFont, prepStr, new Vector2(spots[Game1.down].X + 25 - 2, spots[Game1.up].Y - 35 + 0), Color.Black, 0, new Vector2(Game1.dialogueFont.MeasureString(prepStr).X / 2, 0), 0.6f, SpriteEffects.None, 0);
            b.DrawString(Game1.dialogueFont, prepStr, new Vector2(spots[Game1.down].X + 25 + 0, spots[Game1.up].Y - 35 + 2), Color.Black, 0, new Vector2(Game1.dialogueFont.MeasureString(prepStr).X / 2, 0), 0.6f, SpriteEffects.None, 0);
            b.DrawString(Game1.dialogueFont, prepStr, new Vector2(spots[Game1.down].X + 25 + 0, spots[Game1.up].Y - 35 - 2), Color.Black, 0, new Vector2(Game1.dialogueFont.MeasureString(prepStr).X / 2, 0), 0.6f, SpriteEffects.None, 0);
            b.DrawString(Game1.dialogueFont, prepStr, new Vector2(spots[Game1.down].X + 25, spots[Game1.up].Y - 35), Color.White, 0, new Vector2(Game1.dialogueFont.MeasureString(prepStr).X / 2, 0), 0.6f, SpriteEffects.None, 0);

            for (int i = 0; i < (hasFifthSpellSlot ? 5 : 4); ++i)
            {
                if (i >= prepared.Length)
                {
                    break;
                }

                PreparedSpell prep = prepared[i];
                if (prep == null)
                {
                    continue;
                }

                Spell spell = SpellBook.get(prep.SpellId);
                if (spell == null || spell.Icons.Length <= prep.Level || spell.Icons[prep.Level] == null)
                {
                    continue;
                }

                b.Draw(spell.Icons[prep.Level], new Rectangle(spots[i].X, spots[i].Y, 50, 50), Game1.player.canCastSpell(spell, prep.Level) ? Color.White : new Color(128, 128, 128));
            }
        }
Ejemplo n.º 4
0
        private static void onAnalyze(object sender, AnalyzeEventArgs e)
        {
            var farmer = sender as Farmer;

            if (farmer != Game1.player)
            {
                return;
            }

            List <string> spellsLearnt = new List <string>();

            if (farmer.CurrentItem != null)
            {
                if (farmer.CurrentTool != null)
                {
                    if (farmer.CurrentTool is StardewValley.Tools.Axe || farmer.CurrentTool is StardewValley.Tools.Pickaxe)
                    {
                        spellsLearnt.Add("toil:cleardebris");
                    }
                    else if (farmer.CurrentTool is StardewValley.Tools.Hoe)
                    {
                        spellsLearnt.Add("toil:till");
                    }
                    else if (farmer.CurrentTool is StardewValley.Tools.WateringCan)
                    {
                        spellsLearnt.Add("toil:water");
                    }
                }
                else if (farmer.CurrentItem is StardewValley.Objects.Boots)
                {
                    spellsLearnt.Add("life:evac");
                }
                else if (farmer.ActiveObject != null)
                {
                    if (!farmer.ActiveObject.bigCraftable.Value)
                    {
                        int index = farmer.ActiveObject.ParentSheetIndex;
                        if (index == 395) // Coffee
                        {
                            spellsLearnt.Add("life:haste");
                        }
                        else if (index == 773) // Life elixir
                        {
                            spellsLearnt.Add("life:heal");
                        }
                        else if (index == 86) // Earth crystal
                        {
                            spellsLearnt.Add("nature:shockwave");
                        }
                        else if (index == 82) // Fire quartz
                        {
                            spellsLearnt.Add("elemental:fireball");
                        }
                        else if (index == 161) // Ice Pip
                        {
                            spellsLearnt.Add("elemental:frostbolt");
                        }
                    }
                }
            }
            foreach (var lightSource in farmer.currentLocation.sharedLights.Values)
            {
                if (Utility.distance(e.TargetX, lightSource.position.X, e.TargetY, lightSource.position.Y) < lightSource.radius.Value * Game1.tileSize)
                {
                    spellsLearnt.Add("nature:lantern");
                    break;
                }
            }
            var tilePos = new Vector2(e.TargetX / Game1.tileSize, e.TargetY / Game1.tileSize);

            if (farmer.currentLocation.terrainFeatures.ContainsKey(tilePos) && farmer.currentLocation.terrainFeatures[tilePos] is StardewValley.TerrainFeatures.HoeDirt hd)
            {
                if (hd.crop != null)
                {
                    spellsLearnt.Add("nature:tendrils");
                }
            }
            // TODO: Add proper tilesheet check
            var tile = farmer.currentLocation.map.GetLayer("Buildings").Tiles[(int)tilePos.X, (int)tilePos.Y];

            if (tile != null && tile.TileIndex == 173)
            {
                spellsLearnt.Add("elemental:descend");
            }
            if (farmer.currentLocation is Farm farm)
            {
                foreach (var clump in farm.resourceClumps)
                {
                    if (clump.parentSheetIndex.Value == 622 && new Rectangle((int)clump.tile.Value.X, (int)clump.tile.Value.Y, clump.width.Value, clump.height.Value).Contains((int)tilePos.X, (int)tilePos.Y))
                    {
                        spellsLearnt.Add("eldritch:meteor");
                    }
                }
            }
            if (farmer.currentLocation.doesTileHaveProperty((int)tilePos.X, (int)tilePos.Y, "Action", "Buildings") == "EvilShrineLeft")
            {
                spellsLearnt.Add("eldritch:lucksteal");
            }
            if (farmer.currentLocation is StardewValley.Locations.MineShaft ms && ms.mineLevel == 100 && ms.waterTiles[(int)tilePos.X, (int)tilePos.Y])
            {
                spellsLearnt.Add("eldritch:bloodmana");
            }

            for (int i = spellsLearnt.Count - 1; i >= 0; --i)
            {
                if (farmer.knowsSpell(spellsLearnt[i], 0))
                {
                    spellsLearnt.RemoveAt(i);
                }
            }
            if (spellsLearnt.Count > 0)
            {
                Game1.playSound("secret1");
                foreach (var spell in spellsLearnt)
                {
                    Log.debug("Player learnt spell: " + spell);
                    farmer.learnSpell(spell, 0, true);
                    //Game1.drawObjectDialogue(Mod.instance.Helper.Translation.Get("spell.learn", new { spellName = Mod.instance.Helper.Translation.Get("spell." + spell + ".name") }));
                    Game1.addHUDMessage(new HUDMessage(Mod.instance.Helper.Translation.Get("spell.learn", new { spellName = SpellBook.get(spell).getTranslatedName() })));
                }
            }

            // Temporary - 0.3.0 will add dungeons to get these
            bool knowsAll = true;

            foreach (var schoolId in School.getSchoolList())
            {
                var school = School.getSchool(schoolId);

                bool knowsAllSchool = true;
                foreach (var spell in school.GetSpellsTier1())
                {
                    if (!farmer.knowsSpell(spell, 0))
                    {
                        knowsAll = knowsAllSchool = false;
                        break;
                    }
                }
                foreach (var spell in school.GetSpellsTier2())
                {
                    if (!farmer.knowsSpell(spell, 0))
                    {
                        knowsAll = knowsAllSchool = false;
                        break;
                    }
                }

                // Have to know all other spells for the arcane one
                if (schoolId == SchoolId.Arcane)
                {
                    continue;
                }

                var ancientSpell = school.GetSpellsTier3()[0];
                if (knowsAllSchool && !farmer.knowsSpell(ancientSpell, 0))
                {
                    Log.debug("Player learnt ancient spell: " + ancientSpell);
                    farmer.learnSpell(ancientSpell, 0, true);
                    Game1.addHUDMessage(new HUDMessage(Mod.instance.Helper.Translation.Get("spell.learn.ancient", new { spellName = ancientSpell.getTranslatedName() })));
                }
            }

            var rewindSpell = School.getSchool(SchoolId.Arcane).GetSpellsTier3()[0];

            if (knowsAll && !farmer.knowsSpell(rewindSpell, 0))
            {
                Log.debug("Player learnt ancient spell: " + rewindSpell);
                farmer.learnSpell(rewindSpell, 0, true);
                Game1.addHUDMessage(new HUDMessage(Mod.instance.Helper.Translation.Get("spell.learn.ancient", new { spellName = rewindSpell.getTranslatedName() })));
            }
        }
Ejemplo n.º 5
0
 public static IActiveEffect castSpell(this Farmer player, string spellId, int level, int x = int.MinValue, int y = int.MinValue)
 {
     return(castSpell(player, SpellBook.get(spellId), level, x, y));
 }
Ejemplo n.º 6
0
 public static bool canCastSpell(this Farmer player, string spellId, int level)
 {
     return(SpellBook.get(spellId).canCast(player, level));
 }
Ejemplo n.º 7
0
        private static void onKeyPress(object sender, EventArgsInput args)
        {
            if (args.Button == Config.Key_Cast)
            {
                castPressed = true;
            }

            if (Data == null || Game1.activeClickableMenu != null)
            {
                return;
            }
            if (args.Button == Config.Key_SwapSpells)
            {
                Game1.player.getSpellBook().swapPreparedSet();
            }
            else if (castPressed &&
                     (args.Button == Config.Key_Spell1 || args.Button == Config.Key_Spell2 ||
                      args.Button == Config.Key_Spell3 || args.Button == Config.Key_Spell4))
            {
                int slot = 0;
                if (args.Button == Config.Key_Spell1)
                {
                    slot = 0;
                }
                else if (args.Button == Config.Key_Spell2)
                {
                    slot = 1;
                }
                else if (args.Button == Config.Key_Spell3)
                {
                    slot = 2;
                }
                else if (args.Button == Config.Key_Spell4)
                {
                    slot = 3;
                }

                args.SuppressButton();

                SpellBook       book     = Game1.player.getSpellBook();
                PreparedSpell[] prepared = book.getPreparedSpells();
                if (prepared[slot] == null)
                {
                    return;
                }
                PreparedSpell prep = prepared[slot];

                Spell toCast = SpellBook.get(prep.SpellId);
                if (toCast == null)
                {
                    return;
                }

                //Log.trace("MEOW " + prep.SpellId + " " + prep.Level + " " + Game1.player.canCastSpell(toCast, prep.Level));
                if (Game1.player.canCastSpell(toCast, prep.Level))
                {
                    Log.trace("Casting " + prep.SpellId);
                    Game1.player.castSpell(toCast, prep.Level);
                    Game1.player.addMana(-toCast.getManaCost(Game1.player, prep.Level));
                }
            }
        }
Ejemplo n.º 8
0
        public static void renderHud(object sender, EventArgs args)
        {
            if (Game1.activeClickableMenu != null || Game1.eventUp)
            {
                return;
            }
            if (Game1.player.getMaxMana() == 0)
            {
                return;
            }
            SpriteBatch b = Game1.spriteBatch;

            Vector2 manaPos = new Vector2(20, Game1.viewport.Height - manaBg.Height * 4 - 20);

            b.Draw(manaBg, manaPos, new Rectangle(0, 0, manaBg.Width, manaBg.Height), Color.White, 0, new Vector2(), 4, SpriteEffects.None, 1);
            if (Game1.player.getCurrentMana() > 0)
            {
                Rectangle targetArea = new Rectangle(3, 13, 6, 41);
                float     perc       = Game1.player.getCurrentMana() / (float)Game1.player.getMaxMana();
                int       h          = (int)(targetArea.Height * perc);
                targetArea.Y     += targetArea.Height - h;
                targetArea.Height = h;

                targetArea.X      *= 4;
                targetArea.Y      *= 4;
                targetArea.Width  *= 4;
                targetArea.Height *= 4;
                targetArea.X      += (int)manaPos.X;
                targetArea.Y      += (int)manaPos.Y;
                b.Draw(manaFg, targetArea, new Rectangle(0, 0, 1, 1), Color.White);
            }

            Point[] spots =
                new Point[4]/*
                             * {
                             * new Point((int)manaPos.X + manaBg.Width * 4 + 20 + 40, Game1.viewport.Height - 20 - 50 - 30 - 50 - 25),
                             * new Point((int)manaPos.X + manaBg.Width * 4 + 20 + 50 + 30, Game1.viewport.Height - 20 - 50 - 40 - 25),
                             * new Point((int)manaPos.X + manaBg.Width * 4 + 20 + 40, Game1.viewport.Height - 20 - 50 - 25 ),
                             * new Point((int)manaPos.X + manaBg.Width * 4 + 20, Game1.viewport.Height - 20 - 50 - 40 - 25 ),
                             * };*/
            {
                new Point((int)manaPos.X + manaBg.Width * 4 + 20 + 60 * 0, Game1.viewport.Height - 20 - 50 - 60 * 3),
                new Point((int)manaPos.X + manaBg.Width * 4 + 20 + 60 * 0, Game1.viewport.Height - 20 - 50 - 60 * 2),
                new Point((int)manaPos.X + manaBg.Width * 4 + 20 + 60 * 0, Game1.viewport.Height - 20 - 50 - 60 * 1),
                new Point((int)manaPos.X + manaBg.Width * 4 + 20 + 60 * 0, Game1.viewport.Height - 20 - 50 - 60 * 0),
            };

            SpellBook book = Game1.player.getSpellBook();

            if (book == null || book.selectedPrepared >= book.prepared.Length)
            {
                return;
            }
            PreparedSpell[] prepared = book.getPreparedSpells();

            for (int i = 0; i < spots.Length; ++i)
            {
                b.Draw(spellBg, new Rectangle(spots[i].X, spots[i].Y, 50, 50), Color.White);
            }

            string prepStr = (book.selectedPrepared + 1) + "/" + book.prepared.Length;

            b.DrawString(Game1.dialogueFont, prepStr, new Vector2(spots[Game1.down].X + 25 + 2, spots[Game1.up].Y - 35 + 0), Color.Black, 0, new Vector2(Game1.dialogueFont.MeasureString(prepStr).X / 2, 0), 0.6f, SpriteEffects.None, 0);
            b.DrawString(Game1.dialogueFont, prepStr, new Vector2(spots[Game1.down].X + 25 - 2, spots[Game1.up].Y - 35 + 0), Color.Black, 0, new Vector2(Game1.dialogueFont.MeasureString(prepStr).X / 2, 0), 0.6f, SpriteEffects.None, 0);
            b.DrawString(Game1.dialogueFont, prepStr, new Vector2(spots[Game1.down].X + 25 + 0, spots[Game1.up].Y - 35 + 2), Color.Black, 0, new Vector2(Game1.dialogueFont.MeasureString(prepStr).X / 2, 0), 0.6f, SpriteEffects.None, 0);
            b.DrawString(Game1.dialogueFont, prepStr, new Vector2(spots[Game1.down].X + 25 + 0, spots[Game1.up].Y - 35 - 2), Color.Black, 0, new Vector2(Game1.dialogueFont.MeasureString(prepStr).X / 2, 0), 0.6f, SpriteEffects.None, 0);
            b.DrawString(Game1.dialogueFont, prepStr, new Vector2(spots[Game1.down].X + 25, spots[Game1.up].Y - 35), Color.White, 0, new Vector2(Game1.dialogueFont.MeasureString(prepStr).X / 2, 0), 0.6f, SpriteEffects.None, 0);

            for (int i = 0; i < Math.Min(spots.Length, prepared.Length); ++i)
            {
                PreparedSpell prep = prepared[i];
                if (prep == null)
                {
                    continue;
                }

                Spell spell = SpellBook.get(prep.SpellId);
                if (spell == null || spell.Icons.Length <= prep.Level || spell.Icons[prep.Level] == null)
                {
                    continue;
                }

                b.Draw(spell.Icons[prep.Level], new Rectangle(spots[i].X, spots[i].Y, 50, 50), Game1.player.canCastSpell(spell, prep.Level) ? Color.White : new Color(128, 128, 128));
            }
        }
Ejemplo n.º 9
0
 public static void castSpell(this SFarmer player, string spellId, int level, int x = int.MinValue, int y = int.MinValue)
 {
     castSpell(player, SpellBook.get(spellId), level, x, y);
 }