本文整理汇总了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;
}
}