本文整理汇总了C#中KeyCode类的典型用法代码示例。如果您正苦于以下问题:C# KeyCode类的具体用法?C# KeyCode怎么用?C# KeyCode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KeyCode类属于命名空间,在下文中一共展示了KeyCode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Awake
void Awake()
{
//TODO: use GetComponent to set rb to the rigidbody
//rb = ...
// look through all children of the player game object
// find the one with the "Fist" tag
foreach(Transform t in GetComponentsInChildren<Transform>()) {
if (t.CompareTag("Fist")) {
fist = t;
break;
}
}
//be paranoid: make a fuss if we didn't find a transform with the "Fist" tag
Assert.IsTrue(fist != null, "oh no. we didn't find our fist transform!");
//hide the fist
//TODO: set the fist's game object to inactive
if (isPlayerOne) {
horizontal = "Horizontal";
jumpKey = KeyCode.W;
punchKey = KeyCode.E;
} else {
// TODO: if this is player two
// set horizontal to "Horizontal2"
// set jumpKey to I
// punchKey to E
}
}
示例2: RestoreToFactorySettings
/// <summary>
/// Restores all settings to the default set by the creator.
/// </summary>
public void RestoreToFactorySettings () {
APPLY_ALL = KeyCode.H;
APPLY_SINGLE = KeyCode.G;
ROTATE_TARGET = KeyCode.X;
CHANGEBLOCK_STYLE = KeyCode.V;
PICK_TILE = KeyCode.I;
ENABLE_CHUNK = KeyCode.F10;
ENABLE_FILEMANAGER = KeyCode.F12;
ENABLE_SWATCH = KeyCode.F9;
ENABLE_MODE = KeyCode.F1;
SET_MODE_TO_SELECT = KeyCode.Alpha1;
SET_MODE_TO_MOVE = KeyCode.Alpha2;
SET_MODE_TO_EDIT = KeyCode.Alpha3;
SET_MODE_TO_PAINT = KeyCode.Alpha4;
SET_MODE_TO_REMOVE = KeyCode.Alpha5;
SHOW_GRID = KeyCode.F5;
SWATCH_ENABLE_SEARCH = KeyCode.F2;
SWATCH_ITEM_DECREASE = KeyCode.Keypad8;
SWATCH_ITEM_INCREASE = KeyCode.Keypad2;
SWATCH_SELECT_CATEGORY_DECREASE = KeyCode.Keypad4;
SWATCH_SELECT_CATEGORY_INCREASE = KeyCode.Keypad6;
}
示例3: GetPlayerInput
public static InputItem GetPlayerInput(KeyCode key)
{
switch (key)
{
case KeyCode.A:
case KeyCode.JoystickButton2:
return InputItem.X;
case KeyCode.S:
case KeyCode.JoystickButton0:
return InputItem.A;
case KeyCode.W:
case KeyCode.JoystickButton3:
return InputItem.Y;
case KeyCode.D:
case KeyCode.JoystickButton1:
return InputItem.B;
case KeyCode.UpArrow:
return InputItem.Up;
case KeyCode.DownArrow:
return InputItem.Down;
case KeyCode.LeftArrow:
return InputItem.Left;
case KeyCode.RightArrow:
return InputItem.Right;
}
return InputItem.None;
}
示例4: OnGUI
void OnGUI()
{
if (curInput != Event.current.keyCode && Event.current.keyCode != KeyCode.None)
{
curInput = Event.current.keyCode;
}
}
示例5: Reset
//
protected void Reset()
{
MouseOrbitButton = KeyCode.Mouse2; // middle mouse by default (probably should not use right mouse since it doesn't work well in browsers)
AllowScreenEdgeMove = true;
ScreenEdgeMoveBreaksFollow = true;
ScreenEdgeBorderWidth = 4;
MoveSpeed = 30f;
AllowPan = true;
PanBreaksFollow = true;
PanSpeed = 50f;
PanKey1 = KeyCode.LeftShift;
PanKey2 = KeyCode.RightShift;
AllowRotate = true;
RotateSpeed = 360f;
AllowTilt = true;
TiltSpeed = 200f;
AllowZoom = true;
ZoomSpeed = 500f;
RotateInputAxis = "Mouse X";
TiltInputAxis = "Mouse Y";
ZoomInputAxis = "Mouse ScrollWheel";
}
示例6: Update
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown (KeyCode.G))
dimension = (dimension == 1) ? 3 : 1;
if (gStatus == 100) {// this is the "antistuck" state, if user refuses to let go,
if(Input.GetKeyUp(antiStuck)) gStatus = 0;
return;
}
if(Input.GetKey(KeyCode.R)) //resume
{
gStatus = -1;
}
if (Input.GetKey (KeyCode.P)) { //pause
gStatus = 0;
}
if (gStatus != -1) {
if (Input.GetKey (KeyCode.Comma)) { gStatus = 1; antiStuck = KeyCode.Comma; } // rewind
else
if (Input.GetKey (KeyCode.Period)) { gStatus = 2; antiStuck = KeyCode.Period;} // forward
else gStatus = 0; // stops moving them when no longer pressed
}
}
示例7: newPatternPlayer2
public KeyCode[] newPatternPlayer2(){
KeyCode[] pattern = new KeyCode[4];
for (int i = 0; i < 4; i++) {
pattern[i] = pattern2[Random.Range(0,4)];
}
return pattern;
}
示例8: keyToInt
int keyToInt (KeyCode keyTest){
if (Input.GetKey (keyTest)) {
return 1;
} else {
return 0;
}
}
示例9: ProcessControlGroupSelection
private void ProcessControlGroupSelection(KeyCode keyCode, int i)
{
string unitToSelect = SettingsManager.ControlGroupSettlers[i];
ALivingEntity settler = WorldManager.getInstance().PlayerFaction.units.OfType<APlayableEntity>().Where(x => x.isAlive()).First(x => x.unitName == unitToSelect);
if (settler == null || !settler.isAlive()) {
SettingsManager.ControlGroupSettlers[i] = string.Empty;
return;
}
if (WorldManager.getInstance().PlayerFaction.firstPersonUnit != null) {
return;
}
MonoBehaviour selectedObject = WorldManager.getInstance().PlayerFaction.selectedObject;
bool openSettlerWindow = selectedObject != null &&
selectedObject.gameObject.tag == "ControllableUnit" &&
AManager<GUIManager>.getInstance().settlerWindow.isOpen((APlayableEntity)selectedObject);
WorldManager.getInstance().PlayerFaction.SelectObject(settler.transform, openSettlerWindow);
if (DoubleTapDelayArray[i] > 0 && NumberOfTapsArray[i] == 1) {
WorldManager.getInstance().PlayerFaction.MoveToPosition(settler.coordinate.world);
} else {
ResetDobuleTap(i);
}
}
示例10: Update
void Update()
{
foreach (var keyToCheck in keysToCheck)
{
if (Input.GetKeyDown(keyToCheck))
{
if (lastPressedButton == keyToCheck)
{
Warp(lastPressedButton);
lastPressedButton = KeyCode.None;
}
else
{
lastPressedButton = keyToCheck;
pressedTimer = 0;
}
}
}
pressedTimer += Time.deltaTime;
if (pressedTimer >= 0.5f)
{
lastPressedButton = KeyCode.None;
}
cooldownTimer += Time.deltaTime;
}
示例11: WaitForKeyUp
public WaitForKeyUp(KeyCode key)
{
if (key == KeyCode.None)
throw new ArgumentException("keyCode could not be equal to None.");
this._keyCode = key;
}
示例12: Awake
void Awake()
{
rb = GetComponentInChildren<Rigidbody>();
foreach(Transform t in GetComponentsInChildren<Transform>()) {
if (t.CompareTag("Fist")) {
fist = t;
fistMesh = fist.GetComponentInChildren<Collider>();
break;
}
}
Assert.IsTrue(fist != null, "oh no. we didn't find our fist transform!");
fist.gameObject.SetActive(false);
if (isPlayerOne) {
horizontal = "Horizontal";
jumpKey = KeyCode.W;
punchKey = KeyCode.E;
otherGuysControls = GameObject.Find("PlayerTwo").GetComponent<PlayerControls>();
} else {
horizontal = "Horizontal2";
jumpKey = KeyCode.I;
punchKey = KeyCode.O;
otherGuysControls = GameObject.Find("PlayerOne").GetComponent<PlayerControls>();
}
Assert.IsTrue(otherGuysControls != null, "what???! didn't find the other guy");
foreach(Collider c in GetComponentsInChildren<Collider>()) {
if (c.CompareTag("Body")) {
_body = c;
break;
}
}
Assert.IsTrue(_body != null, "huh?? didn't find body collider.");
}
示例13: getKeyDown
public static bool getKeyDown(KeyCode[] keys)
{
foreach (KeyCode key in keys)
if (Input.GetKeyDown(key))
return true;
return false;
}
示例14: InventoryActionInput
public InventoryActionInput(PointerEventData.InputButton button, EventType eventType, KeyCode keyCode, MobileUIActions mobileAction = MobileUIActions.None)
{
this.button = button;
this.keyCode = keyCode;
this.mobileAction = mobileAction;
this.eventType = eventType;
}
示例15: OnKey
private void OnKey(KeyCode key)
{
if (this.onKey != null)
{
this.onKey(base.gameObject, key);
}
}