本文整理汇总了C#中Server.Items.BaseBook类的典型用法代码示例。如果您正苦于以下问题:C# BaseBook类的具体用法?C# BaseBook怎么用?C# BaseBook使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BaseBook类属于Server.Items命名空间,在下文中一共展示了BaseBook类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PublishedBook
public PublishedBook(BaseBook book) : base(book.ItemID, book.Title, book.Author, book.PagesCount, book.Writable)
{
// copy book
Weight = book.Weight;
Name = book.Name;
Hue = book.Hue;
for(int i = 0; i < Pages.Length; i++)
Pages[i] = book.Pages[i];
RePublish();
m_LastPublished = m_FirstPublished;
}
示例2: IsEmpty
public static bool IsEmpty( BaseBook book )
{
foreach ( BookPageInfo page in book.Pages )
{
foreach ( string line in page.Lines )
{
if ( line.Trim().Length != 0 )
return false;
}
}
return true;
}
示例3: Copy
public static void Copy( BaseBook bookSrc, BaseBook bookDst )
{
bookDst.Title = bookSrc.Title;
bookDst.Author = bookSrc.Author;
BookPageInfo[] pagesSrc = bookSrc.Pages;
BookPageInfo[] pagesDst = bookDst.Pages;
for ( int i = 0; i < pagesSrc.Length && i < pagesDst.Length; i++ )
{
BookPageInfo pageSrc = pagesSrc[i];
BookPageInfo pageDst = pagesDst[i];
int length = pageSrc.Lines.Length;
pageDst.Lines = new string[length];
for ( int j = 0; j < length; j++ )
pageDst.Lines[j] = pageSrc.Lines[j];
}
}
示例4: SetUser
private static void SetUser( BaseBook book, Mobile mob )
{
m_UseTable[book] = mob;
}
示例5: BookPageDetails
public BookPageDetails(BaseBook book)
: base(0x66)
{
this.EnsureCapacity(256);
this.m_Stream.Write((int)book.Serial);
this.m_Stream.Write((ushort)book.PagesCount);
for (int i = 0; i < book.PagesCount; ++i)
{
BookPageInfo page = book.Pages[i];
this.m_Stream.Write((ushort)(i + 1));
this.m_Stream.Write((ushort)page.Lines.Length);
for (int j = 0; j < page.Lines.Length; ++j)
{
byte[] buffer = Utility.UTF8.GetBytes(page.Lines[j]);
this.m_Stream.Write(buffer, 0, buffer.Length);
this.m_Stream.Write((byte)0);
}
}
}
示例6: InternalTargetDst
public InternalTargetDst( BaseBook bookSrc ) : base ( 3, false, TargetFlags.None )
{
m_BookSrc = bookSrc;
}
示例7: BookPageDetailsForTheIlliterate
public BookPageDetailsForTheIlliterate( BaseBook book )
: base(0x66)
{
EnsureCapacity( 256 );
m_Stream.Write( (int) book.Serial );
m_Stream.Write( (ushort) 1 ); // All burns must fit on one page
string[] lines = {
"Hello,",
"prime",
"minister"
};
m_Stream.Write( (ushort) (1) );
m_Stream.Write( (ushort) lines.Length );
for ( int j = 0; j < lines.Length; ++j )
{
byte[] buffer = Utility.UTF8.GetBytes( lines[j] );
m_Stream.Write( buffer, 0, buffer.Length );
m_Stream.Write( (byte) 0 );
}
}
示例8: BookHeader
public BookHeader(Mobile from, BaseBook book)
: base(0xD4)
{
string title = book.Title == null ? "" : book.Title;
string author = book.Author == null ? "" : book.Author;
byte[] titleBuffer = Utility.UTF8.GetBytes(title);
byte[] authorBuffer = Utility.UTF8.GetBytes(author);
this.EnsureCapacity(15 + titleBuffer.Length + authorBuffer.Length);
this.m_Stream.Write((int)book.Serial);
this.m_Stream.Write((bool)true);
this.m_Stream.Write((bool)book.Writable && from.InRange(book.GetWorldLocation(), 1));
this.m_Stream.Write((ushort)book.PagesCount);
this.m_Stream.Write((ushort)(titleBuffer.Length + 1));
this.m_Stream.Write(titleBuffer, 0, titleBuffer.Length);
this.m_Stream.Write((byte)0); // terminate
this.m_Stream.Write((ushort)(authorBuffer.Length + 1));
this.m_Stream.Write(authorBuffer, 0, authorBuffer.Length);
this.m_Stream.Write((byte)0); // terminate
}
示例9: CopyFromBook
public bool CopyFromBook(BaseBook book)
{
if (IsFull)
{
return false;
}
m_Author = book.Author;
m_Title = book.Title;
m_Pages = (BookPageInfo[])book.Pages.Clone();
InvalidateProperties();
return true;
}
示例10: Copy
public static void Copy( BaseBook bookSrc, BaseBook bookDst, Mobile from )
{
bookDst.Title = bookSrc.Title;
bookDst.Author = bookSrc.Author;
BookPageInfo[] pagesSrc = bookSrc.Pages;
BookPageInfo[] pagesDst = bookDst.Pages;
for ( int i = 0; i < pagesSrc.Length && i < pagesDst.Length; i++ )
{
BookPageInfo pageSrc = pagesSrc[i];
BookPageInfo pageDst = pagesDst[i];
int length = pageSrc.Lines.Length;
pageDst.Lines = new string[length];
for ( int j = 0; j < length; j++ )
pageDst.Lines[j] = pageSrc.Lines[j];
}
/* mod */
if ( bookSrc is HTMLBook && bookDst is HTMLBook )
{
HTMLBook bookSource = bookSrc as HTMLBook;
HTMLBook bookDestination = bookDst as HTMLBook;
if ( bookSource.CharactersPerLineMax == bookDestination.CharactersPerLineMax &&
bookSource.MaxLines == bookDestination.MaxLines )
{
if ( bookSource.RequiresFormatting )
{
bookSource.FixContent();
bookSource.RequiresFormatting = false;
}
/* copy all html style-related data to the target book
members are not cloned, but that's irrelevant, because we never modify them anywhere */
bookDestination.HTMLContent.WordsTable = new Dictionary<int, List<HTMLTag>>( bookSource.HTMLContent.WordsTable );
bookDestination.HTMLContent.LinesTable = new Dictionary<int, List<HTMLTag>>( bookSource.HTMLContent.LinesTable );
bookDestination.HTMLContent.PagesTable = new Dictionary<int, List<HTMLTag>>( bookSource.HTMLContent.PagesTable );
bookDestination.HTMLContent.Body = new List<HTMLTag>( bookSource.HTMLContent.Body );
bookDestination.HTMLContent.HTMLPage = new Dictionary<int, int>( bookSource.HTMLContent.HTMLPage );
bookDestination.HTMLContent.HTMLLines = new Dictionary<int, int>( bookSource.HTMLContent.HTMLLines );
bookDestination.FixContent();
bookDestination.FixStyling();
bookDestination.HTMLContent.UpdateCache();
bookDestination.RequiresFormatting = false;
bookDestination.Writable = bookSource.Writable;
if ( bookDestination.Writable == false )
bookDestination.SealedBy = from;
bookDestination.Cypher = bookSource.Cypher;
bookDestination.Language = bookSource.Language;
}
else
{
bookDestination.FixContent();
from.SendMessage( "Because the books have different page dimensions, you've been able to copy the content, but not the styles." );
}
}
else if ( bookDst is HTMLBook ) // copying from normal -> htmlbook
{
((HTMLBook)bookDst).RequiresFormatting = true;
}
/* mod end */
}
示例11: BookGump
public BookGump( Mobile from, BaseBook book )
: base( 150, 200 )
{
if ( book != null )
{
m_Book = book;
AddBackground();
AddTitlePage();
AddText();
}
}
示例12: BaseReadBook
public BaseReadBook(ReadBookInfo bookInfo, int pageCount, String title, String author, BaseBook sourceBook)
: base(bookInfo.ItemID)
{
m_Background = bookInfo.BackgroundID;
m_CustomArt = bookInfo.CustomArt;
m_BigBook = bookInfo.BigBook;
BookContent content = this.DefaultContent;
if (sourceBook != null)
{
m_Author = sourceBook.Author;
m_Title = sourceBook.Title;
m_Pages = (BookPageInfo[])sourceBook.Pages.Clone();
m_Full = true;
}
else
{
if (content == null)
{
m_Pages = new BookPageInfo[pageCount];
for (int i = 0; i < m_Pages.Length; ++i)
m_Pages[i] = new BookPageInfo();
}
else
{
m_Title = content.Title;
m_Author = content.Author;
m_Pages = content.Copy();
}
}
if (author != null)
{
m_Author = author;
}
if (title != null)
{
m_Title = title;
}
if ((author != null) && (title != null))
{
m_Full = true;
}
Weight = BookWeight;
}
示例13: GetUser
public static Mobile GetUser( BaseBook book )
{
Mobile m;
m_UseTable.TryGetValue( book, out m );
return m;
}
示例14: StartCS
private static void StartCS( Mobile from, BaseBook book )
{
from.SendMessage( "Writing book to C# file..." );
try
{
string writetitle = String.Format( "Book{0}", book.Serial );
if ( !Directory.Exists( "CSBooks/" ) )
Directory.CreateDirectory( "CSBooks/" );
string filepath = Path.Combine( String.Format( "CSBooks/{0}.cs", writetitle ) );
if ( File.Exists( filepath ) )
from.SendMessage( "File already exists for this book. Dupe this item to change its serial." );
else
{
using ( StreamWriter op = new StreamWriter( filepath ) )
{
op.WriteLine("using System;" );
op.WriteLine("using Server;" );
op.WriteLine();
op.WriteLine("namespace Server.Items" );
op.WriteLine("{" );
op.WriteLine(" public class {0} : BaseBook", writetitle );
op.WriteLine(" {" );
op.WriteLine(" public static readonly BookContent Content = new BookContent" );
op.WriteLine(" (" );
op.WriteLine(" \"{0}\", \"{1}\",", book.Title, String.IsNullOrEmpty( book.Author ) ? "unknown" : book.Author );
BookPageInfo[] pages = book.Pages;
int lastpage = 0;
for ( int i = pages.Length-1;i >= 0; i-- )
{
if ( pages[i].Lines.Length > 0 ) //This page has something on it
{
lastpage = i;
break;
}
}
for ( int i = 0;i < lastpage; i++ )
{
BookPageInfo pageinfo = pages[i];
op.WriteLine(" new BookPageInfo" );
op.WriteLine(" (" );
for ( int j = 0; j < pageinfo.Lines.Length; j++ )
op.WriteLine(" \"{0}\"{1}", pageinfo.Lines[j], j < pageinfo.Lines.Length-1 ? "," : "" );
op.WriteLine(" ){0}", i < pages.Length-1 ? "," : "" );
}
op.WriteLine(" );" );
op.WriteLine();
op.WriteLine(" public override BookContent DefaultContent{ get{ return Content; } }" );
op.WriteLine();
op.WriteLine(" [Constructable]" );
op.WriteLine(" public {0}() : base( {1}, false )", writetitle, book.ItemID );
op.WriteLine(" {" );
op.WriteLine(" LootType = LootType.Blessed;" );
op.WriteLine(" {" );
op.WriteLine(" public {0}( Serial serial ) : base( serial )", writetitle );
op.WriteLine(" {" );
op.WriteLine(" }" );
op.WriteLine();
op.WriteLine(" public override void Serialize( GenericWriter writer )" );
op.WriteLine(" {" );
op.WriteLine(" base.Serialize( writer );");
op.WriteLine(" writer.WriteEncodedInt( (int)0 ); // version");
op.WriteLine(" }" );
op.WriteLine();
op.WriteLine(" public override void Deserialize( GenericReader reader )" );
op.WriteLine(" {" );
op.WriteLine(" base.Deserialize( reader );" );
op.WriteLine(" int version = reader.ReadEncodedInt();" );
op.WriteLine(" }" );
op.WriteLine(" }" );
op.WriteLine("}" );
}
from.SendMessage( "finished." );
}
}
catch ( Exception e )
{
from.SendMessage( "failed. {0}", e.ToString() );
}
}
示例15: Publish
private void Publish(Mobile contributor, BaseBook book)
{
PublishedBook publishedBook = book as PublishedBook;
if(publishedBook != null)
{
publishedBook.AddContributor(contributor.Name);
Republish(contributor, publishedBook);
return;
}
// change into published book
publishedBook = new PublishedBook(book);
publishedBook.AddContributor(contributor.Name);
if(!publishedBook.IsPublishable())
{
publishedBook.Delete();
this.SayTo(contributor, "You might want to try writing something of interest first.");
}
else if(XmlBook.Save(publishedBook))
{
switch (Utility.Random( 3 ) )
{
case 0:
{
contributor.AddToBackpack(new Gold(1500, 3000));
this.SayTo(contributor, "This seems to be a excellent material. Let me see... hm... here - your royalty. You should see the story soon. I am sure it will sell well.");
contributor.SendMessage("You receive a good amount of gold.");
if (m_Sound)
Effects.PlaySound(contributor.Location, contributor.Map, 0x2E5);
contributor.AddToBackpack(publishedBook);
book.Delete();
break;
}
case 1:
{
contributor.AddToBackpack(new Gold(1000, 1250));
this.SayTo(contributor, "This seems to be decent material. Let me see... hm... here - your royalty. You should see the story soon. I hope it will sell well.");
contributor.SendMessage("You receive a decent amount of gold.");
if (m_Sound)
Effects.PlaySound(contributor.Location, contributor.Map, 0x2E5);
contributor.AddToBackpack(publishedBook);
book.Delete();
break;
}
case 2:
{
contributor.AddToBackpack(new Gold(100, 500));
this.SayTo(contributor, "I don't know if this is good enough to be sold, but let me see... hm... here - I can't give you more for this. I am not sure it will sell at all.");
contributor.SendMessage("You receive some gold.");
if (m_Sound)
Effects.PlaySound(contributor.Location, contributor.Map, 0x2E5);
contributor.AddToBackpack(publishedBook);
book.Delete();
break;
}
}
}
else
{
publishedBook.Delete();
this.SayTo(contributor, "Our machines are not working right. Check back later.");
}
}