Server.Items.Spellbook.OnDragDrop C# (CSharp) Method

OnDragDrop() public method

public OnDragDrop ( Mobile from, Item dropped ) : bool
from Mobile
dropped Item
return bool
        public override bool OnDragDrop( Mobile from, Item dropped )
        {
            if ( dropped is SpellScroll && dropped.Amount == 1 )
            {
                SpellScroll scroll = (SpellScroll)dropped;

                SpellbookType type = GetTypeForSpell( scroll.SpellID );

                if ( type != this.SpellbookType )
                {
                    return false;
                }
                else if ( HasSpell( scroll.SpellID ) )
                {
                    from.SendLocalizedMessage( 500179 ); // That spell is already present in that spellbook.
                    return false;
                }
                else
                {
                    int val = scroll.SpellID - BookOffset;

                    if ( val >= 0 && val < BookCount )
                    {
                        m_Content |= (ulong)1 << val;
                        ++m_Count;

                        InvalidateProperties();

                        scroll.Delete();

                        from.Send( new PlaySound( 0x249, GetWorldLocation() ) );
                        return true;
                    }

                    return false;
                }
            }
            else
            {
                return false;
            }
        }

Usage Example

コード例 #1
0
ファイル: Spellbook.cs プロジェクト: jicomub/Temrael
        private static void AllSpells_OnTarget(Mobile from, object obj)
        {
            if (obj is Spellbook)
            {
                Spellbook book = (Spellbook)obj;

                //if ( book.BookCount == 64 )
                //    book.Content = ulong.MaxValue;
                //else
                //    book.Content = (1ul << book.BookCount) - 1;

                //from.SendMessage( "The spellbook has been filled." );

                //CommandLogging.WriteLine( from, "{0} {1} filling spellbook {2}", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( book ) );

                for (int i = 0; i <= 1000; i++)
                {
                    book.OnDragDrop(from, new SpellScroll(i, 0));
                }

                from.SendMessage("The spellbook has been filled.");
            }
            else
            {
                from.BeginTarget(-1, false, TargetFlags.None, new TargetCallback(AllSpells_OnTarget));
                from.SendMessage("That is not a spellbook. Try again.");
            }
        }