本文整理汇总了C#中InputManager.KeyState方法的典型用法代码示例。如果您正苦于以下问题:C# InputManager.KeyState方法的具体用法?C# InputManager.KeyState怎么用?C# InputManager.KeyState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InputManager
的用法示例。
在下文中一共展示了InputManager.KeyState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleChatInput
public bool HandleChatInput(InputManager inputManager)
{
if (IsChatting) {
if (inputManager.KeyState(Keys.Tab) == ButtonState.Pressed) {
string[] split = ChatBuffer.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (split.Length > 0) {
List<Player> found = new List<Player>();
foreach (KeyValuePair<int, Player> kvp in Players) {
if (kvp.Value.Name.Length >= split[split.Length - 1].Length && kvp.Value.Name.Substring(0, split[split.Length - 1].Length).ToLower() == split[split.Length - 1].ToLower()) {
found.Add(kvp.Value);
}
}
if (found.Count == 1) {
ChatBuffer = ChatBuffer.Substring(0, ChatBuffer.Length - split[split.Length - 1].Length);
string toAdd = found[0].Name;
if (ChatBuffer.Length == 0 && (IsAllChatting || found[0].Team == LocalPlayer.Team))
toAdd += ": ";
else
toAdd += " ";
ChatBuffer += toAdd;
}
}
}
if (inputManager.KeyState(Keys.Backspace) == ButtonState.Pressed && ChatBuffer.Length > 0)
ChatBuffer = ChatBuffer.Substring(0, ChatBuffer.Length - 1);
foreach (char c in inputManager.GetTextInput()) {
ChatBuffer = ChatBuffer + c;
}
if (inputManager.KeyState(Keys.Escape) == ButtonState.Pressed) {
ChatBuffer = "";
IsChatting = false;
}
if (inputManager.KeyState(Keys.Enter) == ButtonState.Pressed) {
if (IsAllChatting)
SendAllChat(ChatBuffer);
else
SendTeamChat(ChatBuffer);
ChatBuffer = "";
IsChatting = false;
}
return true;
}
else {
if (inputManager.KeyState(Keys.Enter) == ButtonState.Pressed) {
if (inputManager.IsShiftKeyDown) {
// All chat
IsAllChatting = true;
}
else {
// Team chat
IsAllChatting = false;
}
IsChatting = true;
}
}
return false;
}