コード例 #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 - 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));
            }
        }
コード例 #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));
                }
            }
        }
コード例 #3
0
ファイル: Extensions.cs プロジェクト: ZaRx485/smapi-mod-dump
 public static bool knowsSpell(this Farmer player, Spell spell, int level)
 {
     return(knowsSpell(player, spell.FullId, level));
 }
コード例 #4
0
ファイル: Extensions.cs プロジェクト: ZaRx485/smapi-mod-dump
 public static bool canCastSpell(this Farmer player, Spell spell, int level)
 {
     return(spell.canCast(player, level));
 }
コード例 #5
0
ファイル: Extensions.cs プロジェクト: ZaRx485/smapi-mod-dump
 public static void forgetSpell(this Farmer player, Spell spell, int level, bool sync = true)
 {
     forgetSpell(player, spell.FullId, level, sync);
 }
コード例 #6
0
ファイル: Extensions.cs プロジェクト: ZaRx485/smapi-mod-dump
 public static void learnSpell(this Farmer player, Spell spell, int level, bool free = false)
 {
     learnSpell(player, spell.FullId, level, free);
 }
コード例 #7
0
ファイル: Extensions.cs プロジェクト: ZaRx485/smapi-mod-dump
 public static int knowsSpellLevel(this Farmer player, Spell spell)
 {
     return(knowsSpellLevel(player, spell.FullId));
 }