本文整理汇总了C#中KeyCode类的典型用法代码示例。如果您正苦于以下问题:C# KeyCode类的具体用法?C# KeyCode怎么用?C# KeyCode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KeyCode类属于命名空间,在下文中一共展示了KeyCode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
}
开发者ID:melsov,项目名称:SmashyBrosGame,代码行数:30,代码来源:PlayerContrScratch.cs
示例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;
}
开发者ID:KevinBreurken,项目名称:VME,代码行数:31,代码来源:VMESettingsObject.cs
示例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;
}
开发者ID:jpnavarrofennell,项目名称:urbantribes,代码行数:33,代码来源:SequenceItem.cs
示例4: OnGUI
void OnGUI()
{
if (curInput != Event.current.keyCode && Event.current.keyCode != KeyCode.None)
{
curInput = Event.current.keyCode;
}
}
开发者ID:borismul,项目名称:Chaos-Crew,代码行数:7,代码来源:PlayerPrediction.cs
示例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";
}
开发者ID:patte88,项目名称:Monsters-Incoming,代码行数:29,代码来源:RtsCameraMouse.cs
示例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
}
}
开发者ID:junezzhu,项目名称:cs426,代码行数:28,代码来源:gameFM.cs
示例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;
}
开发者ID:5thFloorGames,项目名称:SevenLayersOfSummoning,代码行数:7,代码来源:ComboCreator.cs
示例8: keyToInt
int keyToInt (KeyCode keyTest){
if (Input.GetKey (keyTest)) {
return 1;
} else {
return 0;
}
}
开发者ID:vibrating-orb,项目名称:littlePeople,代码行数:7,代码来源:cameraScript.cs
示例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);
}
}
开发者ID:ndc5057,项目名称:BobisbackCombinedMods,代码行数:26,代码来源:GUIWindowControlGroup.cs
示例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;
}
开发者ID:TheWulo,项目名称:SpaceShooterGame,代码行数:27,代码来源:WarpEngine.cs
示例11: WaitForKeyUp
public WaitForKeyUp(KeyCode key)
{
if (key == KeyCode.None)
throw new ArgumentException("keyCode could not be equal to None.");
this._keyCode = key;
}
开发者ID:BLK10,项目名称:Iterator,代码行数:7,代码来源:WaitForKeyUp.cs
示例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.");
}
开发者ID:melsov,项目名称:SmashyBrosGame,代码行数:35,代码来源:PlayerControls.cs
示例13: getKeyDown
public static bool getKeyDown(KeyCode[] keys)
{
foreach (KeyCode key in keys)
if (Input.GetKeyDown(key))
return true;
return false;
}
开发者ID:maggardJosh,项目名称:OGREAT,代码行数:7,代码来源:C.cs
示例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;
}
开发者ID:predominant,项目名称:Treasure_Chest,代码行数:7,代码来源:InventoryActionInput.cs
示例15: OnKey
private void OnKey(KeyCode key)
{
if (this.onKey != null)
{
this.onKey(base.gameObject, key);
}
}
开发者ID:Lessica,项目名称:Something-of-SHIPWAR-GAMES,代码行数:7,代码来源:UIEventListener.cs
示例16: Start
void Start ()
{
if (playerType == Players.Player2)
{
shoot = KeyCode.RightShift;
}
}
开发者ID:sandcoder,项目名称:UnityWorkshop,代码行数:7,代码来源:PlayerShootScript.cs
示例17: Start
void Start ()
{
stageEnd_left = -30.0f;
stageEnd_right = 30.0f;
wait_for_start = true;
firstTime = true;
paused = false;
GameObject mainCameraObj = GameObject.Find ("Camera");
GameObject healthBars = GameObject.Find ("HealthBars");
GameObject player1Obj = GameObject.Find ("Player1");
GameObject player2Obj = GameObject.Find ("Player2");
GameObject debugTextObj = GameObject.Find ("DebugText");
GameObject winTextObj = GameObject.Find ("WinText");
GameObject MIObj = GameObject.Find ("Info");
MI_gd = MIObj.GetComponent<MenuInfo> ();
mainCamera = mainCameraObj.GetComponent<CameraController> ();
healthbarcontroller = healthBars.GetComponent<HealthBarController> ();
player1 = player1Obj.GetComponent<PlayerController> ();
player2 = player2Obj.GetComponent<PlayerController> ();
debugText = debugTextObj.GetComponent<DebugTextController> ();
winText = winTextObj.GetComponent<Text> ();
Quit = KeyCode.Escape;
start_game = KeyCode.G;
TogglePause = KeyCode.BackQuote;
ToggleDebugText = KeyCode.Quote;
winText.text = "";
winText.color = Color.white;
}
开发者ID:rhyschris,项目名称:CS194Project,代码行数:31,代码来源:GameDelegate.cs
示例18: Start
// Use this for initialization
void Start()
{
igs = Engine.GetComponent<InGameScript>();
switch((int)transform.position.x){
case 0:
state = "left";
associatedKeyCode1 = DataManager.Instance.KeyCodeLeft;
associatedKeyCode2 = DataManager.Instance.SecondaryKeyCodeLeft;
this.pm = igs.StartParticleMineLeft;
break;
case 2:
state = "down";
associatedKeyCode1 = DataManager.Instance.KeyCodeDown;
associatedKeyCode2 = DataManager.Instance.SecondaryKeyCodeDown;
this.pm = igs.StartParticleMineDown;
break;
case 4:
state = "up";
associatedKeyCode1 = DataManager.Instance.KeyCodeUp;
associatedKeyCode2 = DataManager.Instance.SecondaryKeyCodeUp;
this.pm = igs.StartParticleMineUp;
break;
case 6:
state = "right";
associatedKeyCode1 = DataManager.Instance.KeyCodeRight;
associatedKeyCode2 = DataManager.Instance.SecondaryKeyCodeRight;
this.pm = igs.StartParticleMineRight;
break;
}
missed = false;
}
开发者ID:bobwister,项目名称:Unity-ITGHD,代码行数:33,代码来源:MineScript.cs
示例19: Cast
void Cast(KeyCode key){
int offset = keyMapping[key];
if (offset < 0 || (offset >= spells.Length) || !isAvailable[offset])
return;
StartCoroutine (CastCoroutine(offset));
}
开发者ID:jsaglio42,项目名称:rush01,代码行数:7,代码来源:spellManager.cs
示例20: ProcessKeyEvent
private static void ProcessKeyEvent(BrushOptionPanel panel, UnityEngine.EventType eventType, KeyCode keyCode, EventModifiers modifiers)
{
if (eventType != UnityEngine.EventType.KeyDown)
return;
var mBrushSizeSlider = Util.GetPrivate<UISlider>(panel, "m_BrushSizeSlider");
var sizeInterval = GetSliderValue(mBrushSizeSlider) < 50f ? 1f : 50f;
if (Util.GetPrivate<SavedInputKey>(panel, "m_IncreaseBrushSize").IsPressed(eventType, keyCode, modifiers))
SetSliderValue(mBrushSizeSlider, GetSliderValue(mBrushSizeSlider) + sizeInterval);
else if (Util.GetPrivate<SavedInputKey>(panel, "m_DecreaseBrushSize").IsPressed(eventType, keyCode, modifiers))
SetSliderValue(mBrushSizeSlider, GetSliderValue(mBrushSizeSlider) - sizeInterval);
else
{
var mBrushStrengthSlider = Util.GetPrivate<UISlider>(panel, "m_BrushStrengthSlider");
var strengthInterval = 0.1f;
if (Util.GetPrivate<SavedInputKey>(panel, "m_IncreaseBrushStrength").IsPressed(eventType, keyCode, modifiers))
{
mBrushStrengthSlider.value = mBrushStrengthSlider.value + strengthInterval;
}
else
{
if (!Util.GetPrivate<SavedInputKey>(panel, "m_DecreaseBrushStrength").IsPressed(eventType, keyCode, modifiers))
return;
mBrushStrengthSlider.value = mBrushStrengthSlider.value - strengthInterval;
}
}
}
开发者ID:earalov,项目名称:Skylines-NaturalResourcesBrush,代码行数:26,代码来源:BrushOptionPanelDetour.cs
注:本文中的KeyCode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论