当前位置: 首页>>代码示例>>C#>>正文


C# KeyCode类代码示例

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


注:本文中的KeyCode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。