本文整理匯總了C#中Zepheus.World.Networking.WorldClient.CreateCharacter方法的典型用法代碼示例。如果您正苦於以下問題:C# WorldClient.CreateCharacter方法的具體用法?C# WorldClient.CreateCharacter怎麽用?C# WorldClient.CreateCharacter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zepheus.World.Networking.WorldClient
的用法示例。
在下文中一共展示了WorldClient.CreateCharacter方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CreateCharHandler
public static void CreateCharHandler(WorldClient client, Packet packet)
{
string name;
byte slot, jobGender, hair, color, style;
if (!packet.TryReadByte(out slot) || !packet.TryReadString(out name, 16) ||
!packet.TryReadByte(out jobGender) || !packet.TryReadByte(out hair) ||
!packet.TryReadByte(out color) || !packet.TryReadByte(out style))
{
Log.WriteLine(LogLevel.Warn, "Error reading create char for {0}", client.Username);
return;
}
if (DatabaseChecks.IsCharNameUsed(name))
{
SendCharCreationError(client, CreateCharError.NameTaken);
return;
}
else if (DataProvider.Instance.IsBadName(name))
{
SendCharCreationError(client, CreateCharError.NameInUse);
return;
}
byte isMaleByte = (byte)((jobGender >> 7) & 0x01);
byte classIDByte = (byte)((jobGender >> 2) & 0x1F);
Job job = (Job)classIDByte;
switch (job)
{
case Job.Archer:
case Job.Cleric:
case Job.Fighter:
case Job.Mage:
case Job.Trickster:
case Job.Crusader:
//create character here
try
{
WorldCharacter wchar = client.CreateCharacter(name, slot, hair, color, style, job, Convert.ToBoolean(isMaleByte));
SendCharOKResponse(client, wchar);
}
catch (Exception ex)
{
Log.WriteLine(LogLevel.Exception, "Error creating character for {0}: {1}", client.Username, ex.InnerException.ToString());
SendCharCreationError(client, CreateCharError.FailedToCreate);
return;
}
break;
default:
SendCharCreationError(client, CreateCharError.WrongClass);
Log.WriteLine(LogLevel.Warn, "Invalid job ID at char creation from {0}", client.Username);
break;
}
}