本文整理汇总了C#中PlayerCharacter.PutMessageIntoMyQueue方法的典型用法代码示例。如果您正苦于以下问题:C# PlayerCharacter.PutMessageIntoMyQueue方法的具体用法?C# PlayerCharacter.PutMessageIntoMyQueue怎么用?C# PlayerCharacter.PutMessageIntoMyQueue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerCharacter
的用法示例。
在下文中一共展示了PlayerCharacter.PutMessageIntoMyQueue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: handlePM
private void handlePM(PlayerCharacter pc, IncommingMessage msg)
{
if (pc.LoginState == PlayerCharacterLoginState.LoginSuccesfull)
{
SendPMIncommingMessage msgSendPM = (SendPMIncommingMessage)msg;
PlayerCharacter sendToPlayer = getPlayerByName(msgSendPM.RecipientName);
if (sendToPlayer == null)
{
RawTextOutgoingMessage msgToSender =
(RawTextOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.RAW_TEXT);
msgToSender.Color = PredefinedColor.Blue1;
msgToSender.Channel = PredefinedChannel.CHAT_LOCAL;
msgToSender.Text = "The one you seek is not here...";
pc.PutMessageIntoMyQueue(msgToSender);
}
else
{
RawTextOutgoingMessage msgToSender =
(RawTextOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.RAW_TEXT);
msgToSender.Color = PredefinedColor.Purple1;
msgToSender.Channel = PredefinedChannel.CHAT_PERSONAL;
msgToSender.Text = "[PM to " + sendToPlayer.Name + ": " + msgSendPM.Text + "]";
pc.PutMessageIntoMyQueue(msgToSender);
RawTextOutgoingMessage msgToRecipient =
(RawTextOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.RAW_TEXT);
msgToRecipient.Color = PredefinedColor.Purple1;
msgToRecipient.Channel = PredefinedChannel.CHAT_PERSONAL;
msgToRecipient.Text = "[PM from " + pc.Name + ": " + msgSendPM.Text + "]";
sendToPlayer.PutMessageIntoMyQueue(msgToRecipient);
}
}
}
示例2: handleRawText
private void handleRawText(PlayerCharacter pc, IncommingMessage msg)
{
if (pc.LoginState == PlayerCharacterLoginState.LoginSuccesfull)
{
RawTextIncommingMessage msgRawText = (RawTextIncommingMessage)msg;
// Handling for different types of raw text
// TODO: Rewrite - add a separate module for handling server commands
switch (msgRawText.Text[0])
{
case('#'):
if (msgRawText.Text.ToLower() == "#save")
{
RawTextOutgoingMessage msgRawTextOut =
(RawTextOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.RAW_TEXT);
msgRawTextOut.Channel = PredefinedChannel.CHAT_LOCAL;
try
{
pc.Serialize(pcSerializer);
msgRawTextOut.Text = "Another page in Book of Life is filled...";
msgRawTextOut.Color = PredefinedColor.Blue1;
}
catch (Exception ex)
{
logger.LogError(LogSource.World, "Failed to serialize player " + pc.Name, ex);
msgRawTextOut.Text = "Your page in Book of Life remains blank...";
msgRawTextOut.Color = PredefinedColor.Red2;
}
pc.PutMessageIntoMyQueue(msgRawTextOut);
return;
}
if (msgRawText.Text.ToLower() == "#list_commands")
{
RawTextOutgoingMessage msgRawTextOut =
(RawTextOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.RAW_TEXT);
msgRawTextOut.Channel = PredefinedChannel.CHAT_LOCAL;
msgRawTextOut.Color = PredefinedColor.Green3;
msgRawTextOut.Text = "Available commands: list_commands, save, follow, stop_following, release_followers, list_skills";
pc.PutMessageIntoMyQueue(msgRawTextOut);
return;
}
if (msgRawText.Text.ToLower() == "#stop_following")
{
pc.FollowingStopFollowing();
return;
}
if (msgRawText.Text.ToLower() == "#release_followers")
{
pc.FollowingReleaseFollowers();
return;
}
if (msgRawText.Text.ToLower().IndexOf("#follow") == 0)
{
RawTextOutgoingMessage msgRawTextOut =
(RawTextOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.RAW_TEXT);
msgRawTextOut.Channel = PredefinedChannel.CHAT_LOCAL;
string[] tokens = msgRawText.Text.Split(' ');
if (tokens.Length != 2)
{
msgRawTextOut.Color = PredefinedColor.Red2;
msgRawTextOut.Text = "You are replied by silence...";
pc.PutMessageIntoMyQueue(msgRawTextOut);
return;
}
// Does character exist
PlayerCharacter pcTakenByHand = getPlayerByName(tokens[1]);
if (pcTakenByHand == null)
{
msgRawTextOut.Color = PredefinedColor.Blue1;
msgRawTextOut.Text = "The one you seek is not here...";
pc.PutMessageIntoMyQueue(msgRawTextOut);
return;
}
pc.FollowingFollow(pcTakenByHand);
return;
}
if ((msgRawText.Text.ToLower().IndexOf("#change_health") != -1) &&
serverConfiguration.EnableTestCommands)
{
string[] tokens = msgRawText.Text.Split(' ');
short changeVal = Convert.ToInt16(tokens[1]);
pc.EnergiesUpdateHealth(changeVal);
return;
}
if ((msgRawText.Text.ToLower().IndexOf("#resurrect") != -1) &&
serverConfiguration.EnableTestCommands)
{
pc.EnergiesResurrect();
return;
}
if ((msgRawText.Text.ToLower().IndexOf("#add_item") != -1) &&
serverConfiguration.EnableTestCommands)
{
//.........这里部分代码省略.........
示例3: handleCreateChar
private PlayerCharacterSerializer pcSerializer = null; // Used for storing pc data
#endregion Fields
#region Methods
private void handleCreateChar(PlayerCharacter pc, IncommingMessage msg)
{
if (pc.LoginState == PlayerCharacterLoginState.ClientVersionCorrect)
{
CreateCharIncommingMessage msgCreateChar = (CreateCharIncommingMessage)msg;
// Is acceptable character name
if (!pcAuthentication.IsAcceptablePlayerName(msgCreateChar.UserName))
{
CreateCharNotOkOutgoingMessage msgCreateCharNotOk =
(CreateCharNotOkOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.CREATE_CHAR_NOT_OK);
msgCreateCharNotOk.Message = "This character name is not acceptable.";
pc.PutMessageIntoMyQueue(msgCreateCharNotOk);
return;
}
// Does character exist?
if (pcAuthentication.Exists(msgCreateChar.UserName))
{
// Character already exists
CreateCharNotOkOutgoingMessage msgCreateCharNotOk =
(CreateCharNotOkOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.CREATE_CHAR_NOT_OK);
msgCreateCharNotOk.Message = "A character with that name already exists.";
pc.PutMessageIntoMyQueue(msgCreateCharNotOk);
return;
}
// TODO: Add check for appearace values
// All ok. Create a character
try
{
pcAuthentication.Create(msgCreateChar.UserName, msgCreateChar.Password);
}
catch (Exception ex)
{
logger.LogError(LogSource.World, "Failed to create player " + pc.Name, ex);
CreateCharNotOkOutgoingMessage msgCreateCharNotOk =
(CreateCharNotOkOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.CREATE_CHAR_NOT_OK);
msgCreateCharNotOk.Message = "Server could not create the character.";
pc.PutMessageIntoMyQueue(msgCreateCharNotOk);
return;
}
// Clear character (current state of character is undefined!)
pc.ClearEntityImplementation();
EntityAppearance appearance = new EntityAppearance(msgCreateChar.Type);
appearance.Head = msgCreateChar.Head;
appearance.Skin = msgCreateChar.Skin;
appearance.Hair = msgCreateChar.Hair;
appearance.Shirt = msgCreateChar.Shirt;
appearance.Pants = msgCreateChar.Pants;
appearance.Boots = msgCreateChar.Boots;
pc.Name = msgCreateChar.UserName;
pc.CreateSetInitialAppearance(appearance);
EntityLocation location = new EntityLocation();
short deviation = mapManager.StartPointDeviation;
location.X = (short)(mapManager.StartPointX + (sbyte)WorldRNG.Next(-deviation, deviation));
location.Y = (short)(mapManager.StartPointY + (sbyte)WorldRNG.Next(-deviation, deviation));
location.Z = 0;
location.Rotation = 0;
location.CurrentMap = mapManager.StartPointMap;
pc.CreateSetInitialLocation(location);
// TODO: Apply race specific factors
// Add bonus items
ItemDefinition itmDef = null;
// Royals
itmDef = ItemDefinitionCache.GetItemDefinitionByID(5);
if (itmDef != null)
{
Item itm = new Item(itmDef);
itm.Quantity = 100;
pc.InventoryUpdateItem(itm);
}
// Recalculate enerigies
pc.CreateRecalculateInitialEnergies();
// Store data
try
{
pc.ForceSerialization();
pc.Serialize(pcSerializer);
}
catch (Exception ex)
{
logger.LogError(LogSource.World, "Failed to serialize player " + pc.Name, ex);
CreateCharNotOkOutgoingMessage msgCreateCharNotOk =
//.........这里部分代码省略.........
示例4: handleSendVersion
private void handleSendVersion(PlayerCharacter pc, IncommingMessage msg)
{
if (pc.LoginState == PlayerCharacterLoginState.NotInitialized)
{
SendVersionIncommingMessage svMsg = (SendVersionIncommingMessage)msg;
if (serverConfiguration.CheckProtocolVersion)
{
if (svMsg.ProtocolVersionFirstDigit == ProtocolVersion.FirstDigit &&
svMsg.ProtocolVersionSecondDigit == ProtocolVersion.SecondDigit)
{
pc.LoginState = PlayerCharacterLoginState.ClientVersionCorrect;
}
else
{
// Wrong version
pc.LoginState = PlayerCharacterLoginState.ClientVersionIncorrect;
pc.PutMessageIntoMyQueue(msgStdWrongClientVersion);
pc.LoginState = PlayerCharacterLoginState.LoggingOff; // Start purging procedure
}
}
else
{
// Always correct
pc.LoginState = PlayerCharacterLoginState.ClientVersionCorrect;
}
}
}
示例5: handleSendOpeningScreen
private void handleSendOpeningScreen(PlayerCharacter pc, IncommingMessage msg)
{
if (pc.LoginState == PlayerCharacterLoginState.ClientVersionCorrect ||
pc.LoginState == PlayerCharacterLoginState.LoginSuccesfull)
{
// Send opening message
pc.PutMessageIntoMyQueue(msgStdOpeningMessage);
}
}
示例6: handleLogIn
private void handleLogIn(PlayerCharacter pc, IncommingMessage msg)
{
if (pc.LoginState == PlayerCharacterLoginState.ClientVersionCorrect)
{
LogInIncommingMessage msgLogIn = (LogInIncommingMessage)msg;
// Is acceptable character name
if (!pcAuthentication.IsAcceptablePlayerName(msgLogIn.UserName))
{
LogInNotOkOutgoingMessage msgLogInNotOk =
(LogInNotOkOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.LOG_IN_NOT_OK);
msgLogInNotOk.Message = "This character name is not acceptable.";
pc.PutMessageIntoMyQueue(msgLogInNotOk);
return;
}
// Does character exist
if (!pcAuthentication.Exists(msgLogIn.UserName))
{
pc.PutMessageIntoMyQueue(msgStdYouDontExist);
return;
}
try
{
// Check the password
if (!pcAuthentication.Authenticate(msgLogIn.UserName, msgLogIn.Password))
{
LogInNotOkOutgoingMessage msgLogInNotOk =
(LogInNotOkOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.LOG_IN_NOT_OK);
msgLogInNotOk.Message = "The password is wrong!";
pc.PutMessageIntoMyQueue(msgLogInNotOk);
return;
}
}
catch (Exception ex)
{
logger.LogError(LogSource.World, "Failed to authenticate player: " + pc.Name, ex);
LogInNotOkOutgoingMessage msgLogInNotOk =
(LogInNotOkOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.LOG_IN_NOT_OK);
msgLogInNotOk.Message = "Server could not load the character!";
pc.PutMessageIntoMyQueue(msgLogInNotOk);
return;
}
// Check if already logged in
if (getPlayerByName(msgLogIn.UserName) != null)
{
LogInNotOkOutgoingMessage msgLogInNotOk =
(LogInNotOkOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.LOG_IN_NOT_OK);
msgLogInNotOk.Message = "You are already logged in!";
pc.PutMessageIntoMyQueue(msgLogInNotOk);
return;
}
// Clear character (current state of character is undefined!)
pc.ClearEntityImplementation();
pc.Name = msgLogIn.UserName; // Temporary setting user name so that deserialization may work
// Deserialize user data
try
{
pc.Deserialize(pcDeserializer);
}
catch (Exception ex)
{
logger.LogError(LogSource.World, "Failed to deserialize player: " + pc.Name, ex);
LogInNotOkOutgoingMessage msgLogInNotOk =
(LogInNotOkOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.LOG_IN_NOT_OK);
msgLogInNotOk.Message = "Server could not load the character!";
pc.PutMessageIntoMyQueue(msgLogInNotOk);
return;
}
try
{
// Add to dictionaries / Get EntityID
addEntityImplementationToWorld(pc);
}
catch (Exception ex)
{
logger.LogError(LogSource.World, "Failed to register player: " + pc.Name, ex);
LogInNotOkOutgoingMessage msgLogInNotOk =
(LogInNotOkOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.LOG_IN_NOT_OK);
msgLogInNotOk.Message = "Server could not register the character!";
pc.PutMessageIntoMyQueue(msgLogInNotOk);
return;
}
// TODO: Send initial data to client
// New Minute
NewMinuteOutgoingMessage msgNewMinute =
(NewMinuteOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.NEW_MINUTE);
msgNewMinute.MinuteOfTheDay = calendar.MinuteOfTheDay;
pc.PutMessageIntoMyQueue(msgNewMinute);
// You Are
//.........这里部分代码省略.........