本文整理匯總了C#中Server.Mobiles.PlayerMobile.DefaultMobileInit方法的典型用法代碼示例。如果您正苦於以下問題:C# PlayerMobile.DefaultMobileInit方法的具體用法?C# PlayerMobile.DefaultMobileInit怎麽用?C# PlayerMobile.DefaultMobileInit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Server.Mobiles.PlayerMobile
的用法示例。
在下文中一共展示了PlayerMobile.DefaultMobileInit方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Convert_OnCommand
public static void Convert_OnCommand( CommandEventArgs e )
{
e.Mobile.SendMessage( "Converting all players to PlayerMobile. You will be disconnected. Please Restart the server after the world has finished saving." );
List<Mobile> mobs = new List<Mobile>( World.Mobiles.Values );
int count = 0;
foreach ( Mobile m in mobs )
{
if ( m.Player && !(m is PlayerMobile ) )
{
count++;
if ( m.NetState != null )
m.NetState.Dispose();
PlayerMobile pm = new PlayerMobile( m.Serial );
pm.DefaultMobileInit();
List<Item> copy = new List<Item>( m.Items );
for (int i=0;i<copy.Count;i++)
pm.AddItem( copy[i] );
CopyProps( pm, m );
for (int i=0;i<m.Skills.Length;i++)
{
pm.Skills[i].Base = m.Skills[i].Base;
pm.Skills[i].SetLockNoRelay( m.Skills[i].Lock );
}
World.Mobiles[m.Serial] = pm;
}
}
if ( count > 0 )
{
NetState.ProcessDisposedQueue();
World.Save();
Console.WriteLine( "{0} players have been converted to PlayerMobile. {1}.", count, Core.Service ? "The server is now restarting" : "Press any key to restart the server" );
if ( !Core.Service )
Console.ReadKey( true );
Core.Kill( true );
}
else
{
e.Mobile.SendMessage( "Couldn't find any Players to convert." );
}
}
示例2: Convert_OnCommand
public static void Convert_OnCommand( CommandEventArgs e )
{
e.Mobile.SendMessage( "Converting all players to PlayerMobile. You will be disconnected. Please Restart the server after the world has finished saving." );
ArrayList mobs = new ArrayList( World.Mobiles.Values );
int count = 0;
foreach ( Mobile m in mobs )
{
if ( m.Player && !(m is PlayerMobile ) )
{
count++;
if ( m.NetState != null )
m.NetState.Dispose();
PlayerMobile pm = new PlayerMobile( m.Serial );
pm.DefaultMobileInit();
ArrayList copy = new ArrayList( m.Items );
for (int i=0;i<copy.Count;i++)
pm.AddItem( (Item)copy[i] );
CopyProps( pm, m );
for (int i=0;i<m.Skills.Length;i++)
{
pm.Skills[i].Base = m.Skills[i].Base;
pm.Skills[i].SetLockNoRelay( m.Skills[i].Lock );
}
World.Mobiles[m.Serial] = pm;
}
}
if ( count > 0 )
{
NetState.ProcessDisposedQueue();
World.Save();
log.InfoFormat("{0} players have been converted to PlayerMobile. Restarting the server.",
count);
Core.Shutdown(true);
}
else
{
log.Info( "Couldn't find any Players to convert." );
}
}