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;
        }
示例#2
1
 void OnGUI()
 {
     if (curInput != Event.current.keyCode && Event.current.keyCode != KeyCode.None)
     {
         curInput = Event.current.keyCode;
     }
 }
示例#3
0
    public void recordNote(KeyCode arrow, float time)
    {
        int beat = (int)(time / (60.0f / 128));

        string arrowString = "";

        switch (arrow) {
        case KeyCode.UpArrow:
            arrowString = "up";
            break;
        case KeyCode.DownArrow:
            arrowString = "down";
            break;
        case KeyCode.LeftArrow:
            arrowString = "left";
            break;
        case KeyCode.RightArrow:
            arrowString = "right";
            break;
        }

        root ["notes"] [notesCounter] ["beat"].AsInt = beat;
        root ["notes"] [notesCounter] ["arrow"] = arrowString;

        notesCounter++;
    }
 public void Add(KeyCode key, string descr, KeyCode alt = KeyCode.None)
 {
     var keyValue = new KeyValue() { descr = descr, keyCodeAlt = new[] { key, alt }, main = key };
     keyValue.Load();
     keys.Add(keyValue);
     m_alternatives[(int)key] = keyValue;
 }
    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
        }
    }
   public bool Driven(out KeyCode Value, out int CurrentIndex)
   {
      Value = 0;
      CurrentIndex = m_CurrentIndex;
      if (!m_Done && m_List != null)
      {
         if (m_CurrentIndex < m_List.Length)
         {
            Value = m_List[m_CurrentIndex];
            CurrentIndex = m_CurrentIndex;
         }
         m_CurrentIndex++;

         // done iterating
         if (m_CurrentIndex > m_List.Length)
         {
            m_List = null;
            m_Done = true;
         }

         return true;
      }

      return false;
   }
示例#7
0
 public CameraControl(TargetEnum argTarget, KeyCode argKeyCode, MouseCodeEnum argMouseCode, float argStepSize)
 {
     target = argTarget;
     keyCode = argKeyCode;
     mouseCode = argMouseCode;
     stepSize = argStepSize;
 }
示例#8
0
 public void SetUpControlsAsPlayer2()
 {
     HorizontalAxisName = ControlsManager.instance.Player2Controls.HorizontalAxis;
     VerticalAxisName = ControlsManager.instance.Player2Controls.VerticalAxis;
     SuperWeaponButton = ControlsManager.instance.Player2Controls.MegaWeaponFireButton;
     SuperWeaponButtonGamepad = ControlsManager.instance.Player2Controls.MegaWeaponFireButtonGamePad;
 }
示例#9
0
    /// <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;

    }
示例#10
0
    void Update()
    {
        if (Input.GetKey(KeyCode.None))
        {
            curInput = KeyCode.None;
            Debug.Log("true");
        }

        if (Input.GetKeyUp(curInput))
        {
            inputTime.Add(Time.realtimeSinceStartup - keyPressTimeStart);

            //Debug.Log(inputTime[inputTime.Count-1]);

        }

        if (prevInput != curInput)
        {

            if (curInput != KeyCode.None)
            {
                inputsSinceSync.Add(curInput.ToString());
                keyPressTimeStart = Time.realtimeSinceStartup;

                //Debug.Log(inputsSinceSync[inputsSinceSync.Count-1]);

            }

        }
        Debug.Log(curInput);

        prevInput = curInput;
    }
示例#11
0
    //
    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";
    }
示例#12
0
	void Cast(KeyCode key){
		int offset = keyMapping[key];
	
		if (offset < 0 || (offset >= spells.Length) || !isAvailable[offset])
			return;
		StartCoroutine (CastCoroutine(offset));
	}
	void Start () 
	{
		if (playerType == Players.Player2)
		{
			shoot = KeyCode.RightShift;
		}
	}
示例#14
0
	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;


	}
示例#15
0
文件: gameFM.cs 项目: junezzhu/cs426
    // 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
                }
    }
示例#16
0
    private void handleInputHeld(KeyCode key)
    {
		//player input changes MyRotation
		if (key == KeyCode.W)
			XRotation.x += RotationSpeed;
		if (key == KeyCode.S)
			XRotation.x -= RotationSpeed;
		if (key == KeyCode.A)
			YRotation.y += RotationSpeed;
		if (key == KeyCode.D)
			YRotation.y -= RotationSpeed;

		//make sure MyRotation does not get too crazy huge
		if (XRotation.x > 360)
			XRotation.x -= 360f;
		else if (XRotation.x < 0)
			XRotation.x += 360f;
		if (YRotation.y > 360)
			YRotation.y -= 360f;
		else if (YRotation.y < 0)
			YRotation.y += 360f;

		//apply MyRotation to the object's transform
		transform.localEulerAngles = XRotation;
		HorizontalRotationObject.transform.localEulerAngles = YRotation;
    }
 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;
 }
示例#18
0
 public void AssignAction(KeyAction action, KeyCode code)
 {
     if(map.ContainsKey(action))
         map[action] = code;
     else
         map.Add(action, code);
 }
   public void InsertIntoList(ref KeyCode[] VariableList, int Index, KeyCode[] Target, out int ListCount)
	{
      List<KeyCode> list = new List<KeyCode>(VariableList);
		
		if (Index < 0) {
			Index = 0;
		}
		
		if (list.Count == 0) {
         foreach (KeyCode tmpVar in Target)
         {
            list.Add(tmpVar);
			}
			
		} else {
			if (Index + 1 >= list.Count) {
            foreach (KeyCode tmpVar in Target)
            {
               list.Add(tmpVar);
				}
				
			} else {

            foreach (KeyCode tmpVar in Target)
            {
               list.Insert(Index, tmpVar);
				}

			}
		}

      VariableList = list.ToArray();
      ListCount = VariableList.Length;
      
	}	
示例#20
0
    // 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;
    }
 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;
         }
     }
 }
 private void OnKey(KeyCode key)
 {
     if (this.onKey != null)
     {
         this.onKey(base.gameObject, key);
     }
 }
示例#23
0
	int keyToInt (KeyCode keyTest){
		if (Input.GetKey (keyTest)) {
			return 1;
		} else {
			return 0;
		}
	}
示例#24
0
        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;
        }
示例#25
0
        public WaitForKeyUp(KeyCode key)
        {
            if (key == KeyCode.None)
                throw new ArgumentException("keyCode could not be equal to None.");

            this._keyCode = key;
        }
示例#26
0
文件: C.cs 项目: maggardJosh/OGREAT
 public static bool getKeyDown(KeyCode[] keys)
 {
     foreach (KeyCode key in keys)
         if (Input.GetKeyDown(key))
             return true;
     return false;
 }
示例#27
0
    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.");
    }
        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);
            }
        }
示例#29
0
	void OnGUI()
	{
		if (selected) 
		{
			key = findKey (Event.current);
		}
	}
	public KeyCode[] newPatternPlayer2(){
		KeyCode[] pattern = new KeyCode[4];
		for (int i = 0; i < 4; i++) {
			pattern[i] = pattern2[Random.Range(0,4)];
		}
		return pattern;
	}
示例#31
0
 public UndoCommand(KeyCode key) : base(key)
 {}
示例#32
0
 /// <summary>
 /// @keycode from the input buffer will be destroyed immediately.
 /// </summary>
 /// <param name="keycode"></param>
 /// <returns></returns>
 void RemoveKeyFromBufferImmediately(KeyCode keycode)
 {
     buffKeys.Remove(keycode);
 }
 public void OnKeyUp(KeyCode keyCode)
 {
     GameManager.Instanse.GameEventSystem.KeyUpEventLaunch(keyCode);
 }
 public void OnKeyPressed(KeyCode keyCode)
 {
     GameManager.Instanse.GameEventSystem.KeyPressEventLaunch(keyCode);
     //KeyPress (keyCode);
 }
示例#35
0
        public NodeAttributes(string name, string category, string description, System.Type castType = null, KeyCode shortcutKey = KeyCode.None, bool available = true, bool deprecated = false, string deprecatedAlternative = null, System.Type deprecatedAlternativeType = null, string community = null, string customCategoryColor = null, int sortOrderPriority = -1, int nodeAvailabilityFlags = int.MaxValue)
        {
            Name        = name;
            Description = description;
            Category    = category;
            if (castType != null)
            {
                CastType = new System.Type[] { castType }
            }
            ;

            ShortcutKey           = shortcutKey;
            Available             = available;
            Deprecated            = deprecated;
            DeprecatedAlternative = deprecatedAlternative;
            Community             = community;
            if (string.IsNullOrEmpty(Community))
            {
                Community = string.Empty;
            }
            else
            {
                FromCommunity = true;
            }
            CustomCategoryColor       = customCategoryColor;
            DeprecatedAlternativeType = deprecatedAlternativeType;
            SortOrderPriority         = sortOrderPriority;
            NodeAvailabilityFlags     = nodeAvailabilityFlags;
            NodeUrl = (FromCommunity ? Constants.CommunityNodeCommonUrl : Constants.NodeCommonUrl) + UIUtils.UrlReplaceInvalidStrings(Name);
        }
示例#36
0
 public static extern ushort MapVirtualKey(KeyCode uCode, uint uMapType);
示例#37
0
 public RawkeyCodeAxis(KeyCode positive, KeyCode negative)
 {
     this.positive = positive;
     this.negative = negative;
 }
示例#38
0
 public Axis(string Name, KeyCode positiveButton, KeyCode negativeButton, KeyCode altPositiveButton, KeyCode altNegativeButton, float accelerationTime, float decelerationTime)
 {
     this.Name              = Name;
     this.positiveButton    = positiveButton;
     this.negativeButton    = negativeButton;
     this.altPositiveButton = altPositiveButton;
     this.altNegativeButton = altNegativeButton;
     this.accelerationTime  = accelerationTime;
     this.decelerationTime  = decelerationTime;
 }
示例#39
0
    /// <summary>
    /// @keycode from the input buffer will be destroyed in @time seconds from now.
    /// </summary>
    /// <param name="keycode"></param>
    /// <param name="time"></param>
    /// <returns></returns>
    IEnumerator RemoveKeyFromBuffer(KeyCode keycode, float time)
    {
        yield return(new WaitForSeconds(time));

        buffKeys.Remove(keycode);
    }
示例#40
0
    /// <summary>
    /// @keycode from the input buffer will be destroyed at the end of the frame.
    /// </summary>
    /// <param name="keycode"></param>
    /// <returns></returns>
    IEnumerator RemoveKeyFromBuffer(KeyCode keycode)
    {
        yield return(new WaitForEndOfFrame());

        buffKeys.Remove(keycode);
    }
示例#41
0
 public MoveLeft(KeyCode key) : base(key)
 {}
示例#42
0
 //// PUBLIC: CONTROLS
 public void Input_SetKeyCellValue(KeyCode k, ushort cellValue)
 {
     this.keyToCellValue[k] = cellValue;
 }
示例#43
0
 public MoveForward(KeyCode key) : base(key)
 {}
示例#44
0
 public MoveReverse(KeyCode key) : base(key)
 {}
示例#45
0
 public ToggleUI(KeyCode key) : base(key) {}
示例#46
0
 protected Command(KeyCode key)
 {
     keyCode = key;
 }
 private void AddKeyboardInput(ControllerInput controllerInput, KeyCode keyCode) {
     ControllerInput.Keyboard keyboardInput = new ControllerInput.Keyboard();
     keyboardInput.keyCode = keyCode;
     controllerInput.keys.Add(keyboardInput);
 }
示例#48
0
 public ReplayCommand(KeyCode key) : base(key)
 {}
示例#49
0
文件: Input.cs 项目: lineCode/Xaloc
 public static bool IsKeyPressed(KeyCode keycode)
 {
     return(IsKeyPressed_Native(keycode));
 }
示例#50
0
 public MoveRight(KeyCode key) : base(key)
 {}
示例#51
0
 public override bool IsButtonDown(KeyCode key)
 {
     return(base.IsButtonDown(key) ||
            touchPadButtons.IsButtonDown(key) ||
            triggerButtons.IsButtonDown(key));
 }
示例#52
0
 public DoNothing(KeyCode key) : base(key)
 {}
示例#53
0
    /// <summary>
    /// Get the index of the character on the line directly above or below the current index.
    /// </summary>

    public int GetCharacterIndex(int currentIndex, KeyCode key)
    {
        if (isValid)
        {
            string text = processedText;
            if (string.IsNullOrEmpty(text))
            {
                return(0);
            }

            int def = defaultFontSize;
            UpdateNGUIText(def, mWidth, mHeight);

            NGUIText.PrintCharacterPositions(text, mTempVerts, mTempIndices);

            if (mTempVerts.size > 0)
            {
                ApplyOffset(mTempVerts, 0);

                for (int i = 0; i < mTempIndices.size; ++i)
                {
                    if (mTempIndices[i] == currentIndex)
                    {
                        // Determine position on the line above or below this character
                        Vector2 localPos = mTempVerts[i];

                        if (key == KeyCode.UpArrow)
                        {
                            localPos.y += def + spacingY;
                        }
                        else if (key == KeyCode.DownArrow)
                        {
                            localPos.y -= def + spacingY;
                        }
                        else if (key == KeyCode.Home)
                        {
                            localPos.x -= 1000f;
                        }
                        else if (key == KeyCode.End)
                        {
                            localPos.x += 1000f;
                        }

                        // Find the closest character to this position
                        int retVal = NGUIText.GetClosestCharacter(mTempVerts, localPos);
                        retVal = mTempIndices[retVal];
                        if (retVal == currentIndex)
                        {
                            break;
                        }

                        mTempVerts.Clear();
                        mTempIndices.Clear();
                        return(retVal);
                    }
                }
                mTempVerts.Clear();
                mTempIndices.Clear();
            }

            // If the selection doesn't move, then we're at the top or bottom-most line
            if (key == KeyCode.UpArrow || key == KeyCode.Home)
            {
                return(0);
            }
            if (key == KeyCode.DownArrow || key == KeyCode.End)
            {
                return(text.Length);
            }
        }
        return(currentIndex);
    }
示例#54
0
    void Update()
    {
        // Return player if they are out of bounds
        if (this.transform.position.y < resetThreshold)
        {
            ResetPlayerPosition();
        }

        if (Debug.isDebugBuild)
        {
            for (KeyCode key = playerTeleportKeyMin; key <= playerTeleportKeyMaxInclusive; ++key)
            {
                if (Input.GetKeyDown(key))
                {
                    this.generalObject.SetPlayerToArea(key - playerTeleportKeyMin + 1);
                }
            }
        }

        // Debug tools
        if (Debug.isDebugBuild)
        {
            // Toggle Boost powerup
            if (Input.GetKeyDown(KeyCode.B))
            {
                this.gotBoostPowerup = !this.gotBoostPowerup;
                this.RenderBallAfterPowerup();
                Debug.Log("Toggled boost powerup: " + (this.gotBoostPowerup ? "On" : "Off"));
            }

            // Toggle Camera powerup
            if (Input.GetKeyDown(KeyCode.C))
            {
                this.gotCameraPowerup = !this.gotCameraPowerup;
                this.RenderBallAfterPowerup();
                Debug.Log("Toggled camera powerup: " + (this.gotCameraPowerup ? "On" : "Off"));
            }

            // Toggle Jump powerup
            if (Input.GetKeyDown(KeyCode.J))
            {
                this.gotJumpPowerup = !this.gotJumpPowerup;
                this.RenderBallAfterPowerup();
                this.jumpHeight = this.gotJumpPowerup ? 30.0f : 20.0f;
                Debug.Log("Toggled jump powerup: " + (this.gotJumpPowerup ? "On" : "Off"));
            }
        }

        // Boost powerup used
        if ((Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.RightShift)) && this.gotBoostPowerup && this.hasBoosted == false)
        {
            this.Boost(true);
        }
        if (Input.GetKeyDown(KeyCode.Space))
        {
            this.Jump();
        }
        if (Input.GetKeyDown(KeyCode.Z))
        {
            CameraController.zoomFactor = CameraController.zoomFactor == 1.0f ? 0.5f : 1.0f;
        }

        // Mobile
        if (Input.touchCount > 0)
        {
            if (Input.GetTouch(0).phase == TouchPhase.Began && Input.touchCount == 1)
            {
                this.Jump();
            }
            if (Input.GetTouch(0).phase == TouchPhase.Began && Input.touchCount == 2)
            {
                this.Boost(true);
            }

            /*
             *          if (Input.GetTouch(i).phase == TouchPhase.Canceled)
             *          {
             *          }
             *          if (Input.GetTouch(i).phase == TouchPhase.Ended)
             *          {
             *          }
             *          if (Input.GetTouch(i).phase == TouchPhase.Moved)
             *          {
             *          }
             *          if (Input.GetTouch(i).phase == TouchPhase.Stationary)
             *          {
             *          }
             */
        }

        // Controller
        if (Input.GetAxis("Xbox A Button") > 0)
        {
            this.Jump();
        }
        if (Input.GetAxis("Xbox X and B Button") > 0)
        {
            this.Boost(true);
        }
    }
示例#55
0
文件: Input.cs 项目: lineCode/Xaloc
 private static extern bool IsKeyPressed_Native(KeyCode keycode);
        // Update is called once per frame
        void Update()
        {
            KeyCode triggerButton = (checkVive)
                                           ? (KeyCode)ViveTriggerButton
                                           : (checkOculus)
                                           ? (KeyCode)OculusTriggerButton
                                           : (checkWMR)
                                           ? (KeyCode)WMRTriggerButton
                                           : KeyCode.None;

            if (triggerButton == KeyCode.None)
            {
                return;
            }
            float triggerValue;
            bool  isTrigger = triggerButton == (KeyCode)ViveButton.LeftTrigger || triggerButton == (KeyCode)ViveButton.RightTrigger;

            if (isTrigger)
            {
                string axisName = (triggerButton == (KeyCode)ViveButton.LeftTrigger) ? "TriggerLeftHand" : "TriggerRightHand";
                triggerValue = Input.GetAxis(axisName);

                if (triggerValue > 0.5f)
                {
                    //GetKeyDown
                    if (!triggerPressed)
                    {
                        triggerPressed   = true;
                        checkDoubleClick = (Time.time - pressTime <= interval);
                        pressTime        = Time.time;
                        OnPress();
                        checkLongClick = true;
                        checkClick     = false;
                    }
                    //GetKey
                    OnHold();
                    if (checkLongClick && Time.time - pressTime >= longClickInterval)
                    {
                        checkLongClick = false;
                        OnLongClick();
                        longClicked = true;
                    }
                }
                else if (triggerPressed && triggerValue < 0.1f)
                {
                    //GetKeyUp
                    triggerPressed = false;
                    releaseTime    = Time.time;
                    OnRelease();
                    if (longClicked)
                    {
                        OnReleaseAfterLongClick();
                        longClicked = false;
                    }
                    if (releaseTime - pressTime <= interval)
                    {
                        if (checkDoubleClick)
                        {
                            OnDoubleClick();
                        }
                        else
                        {
                            checkClick = true;
                        }
                    }
                }
                else if (checkClick && Time.time - releaseTime > interval)
                {
                    checkClick = false;
                    OnClick();
                }
            }
            else
            {
                if (Input.GetKeyDown(triggerButton))
                {
                    //Debug.Log(pressedKey + " is pressed");
                    checkDoubleClick = (Time.time - pressTime <= interval);
                    pressTime        = Time.time;
                    OnPress();
                    checkLongClick = true;
                    checkClick     = false;
                }
                else if (Input.GetKey(triggerButton))
                {
                    //Debug.Log(pressedKey + " is hold");
                    OnHold();
                    if (checkLongClick && Time.time - pressTime >= longClickInterval)
                    {
                        checkLongClick = false;
                        OnLongClick();
                        longClicked = true;
                    }
                }
                else if (Input.GetKeyUp(triggerButton))
                {
                    //Debug.Log(pressedKey + " is up");
                    releaseTime = Time.time;
                    OnRelease();
                    if (longClicked)
                    {
                        OnReleaseAfterLongClick();
                        longClicked = false;
                    }
                    //Debug.Log("GetKeyUp : releaseTime - pressTime = " + (releaseTime - pressTime));
                    if (releaseTime - pressTime <= interval)
                    {
                        if (checkDoubleClick)
                        {
                            OnDoubleClick();
                        }
                        else
                        {
                            checkClick = true;
                        }
                    }
                }
                else if (checkClick && Time.time - releaseTime > interval)
                {
                    checkClick = false;
                    OnClick();
                }
            }
        }
示例#57
0
 public bool KeyPressed(KeyCode keyCode)
 {
     return(Input.GetKey(keyCode));
 }
示例#58
0
 public bool KeyDown(KeyCode keyCode)
 {
     return(Input.GetKeyDown(keyCode));
 }
    // Token: 0x060007A3 RID: 1955 RVA: 0x0003F258 File Offset: 0x0003D458
    public virtual bool ProcessEvent(Event ev)
    {
        if (this.label == null)
        {
            return(false);
        }
        RuntimePlatform platform = Application.platform;
        bool            flag     = (platform == RuntimePlatform.OSXEditor || platform == RuntimePlatform.OSXPlayer) ? ((ev.modifiers & EventModifiers.Command) > EventModifiers.None) : ((ev.modifiers & EventModifiers.Control) > EventModifiers.None);

        if ((ev.modifiers & EventModifiers.Alt) != EventModifiers.None)
        {
            flag = false;
        }
        bool    flag2   = (ev.modifiers & EventModifiers.Shift) > EventModifiers.None;
        KeyCode keyCode = ev.keyCode;

        if (keyCode <= KeyCode.C)
        {
            if (keyCode == KeyCode.Backspace)
            {
                ev.Use();
                this.DoBackspace();
                return(true);
            }
            if (keyCode == KeyCode.A)
            {
                if (flag)
                {
                    ev.Use();
                    this.mSelectionStart = 0;
                    this.mSelectionEnd   = this.mValue.Length;
                    this.UpdateLabel();
                }
                return(true);
            }
            if (keyCode == KeyCode.C)
            {
                if (flag)
                {
                    ev.Use();
                    NGUITools.clipboard = this.GetSelection();
                }
                return(true);
            }
        }
        else if (keyCode <= KeyCode.X)
        {
            if (keyCode == KeyCode.V)
            {
                if (flag)
                {
                    ev.Use();
                    this.Insert(NGUITools.clipboard);
                }
                return(true);
            }
            if (keyCode == KeyCode.X)
            {
                if (flag)
                {
                    ev.Use();
                    NGUITools.clipboard = this.GetSelection();
                    this.Insert("");
                }
                return(true);
            }
        }
        else
        {
            if (keyCode == KeyCode.Delete)
            {
                ev.Use();
                if (!string.IsNullOrEmpty(this.mValue))
                {
                    if (this.mSelectionStart == this.mSelectionEnd)
                    {
                        if (this.mSelectionStart >= this.mValue.Length)
                        {
                            return(true);
                        }
                        this.mSelectionEnd++;
                    }
                    this.Insert("");
                }
                return(true);
            }
            switch (keyCode)
            {
            case KeyCode.UpArrow:
                ev.Use();
                if (this.onUpArrow != null)
                {
                    this.onUpArrow();
                }
                else if (!string.IsNullOrEmpty(this.mValue))
                {
                    this.mSelectionEnd = this.label.GetCharacterIndex(this.mSelectionEnd, KeyCode.UpArrow);
                    if (this.mSelectionEnd != 0)
                    {
                        this.mSelectionEnd += UIInput.mDrawStart;
                    }
                    if (!flag2)
                    {
                        this.mSelectionStart = this.mSelectionEnd;
                    }
                    this.UpdateLabel();
                }
                return(true);

            case KeyCode.DownArrow:
                ev.Use();
                if (this.onDownArrow != null)
                {
                    this.onDownArrow();
                }
                else if (!string.IsNullOrEmpty(this.mValue))
                {
                    this.mSelectionEnd = this.label.GetCharacterIndex(this.mSelectionEnd, KeyCode.DownArrow);
                    if (this.mSelectionEnd != this.label.processedText.Length)
                    {
                        this.mSelectionEnd += UIInput.mDrawStart;
                    }
                    else
                    {
                        this.mSelectionEnd = this.mValue.Length;
                    }
                    if (!flag2)
                    {
                        this.mSelectionStart = this.mSelectionEnd;
                    }
                    this.UpdateLabel();
                }
                return(true);

            case KeyCode.RightArrow:
                ev.Use();
                if (!string.IsNullOrEmpty(this.mValue))
                {
                    this.mSelectionEnd = Mathf.Min(this.mSelectionEnd + 1, this.mValue.Length);
                    if (!flag2)
                    {
                        this.mSelectionStart = this.mSelectionEnd;
                    }
                    this.UpdateLabel();
                }
                return(true);

            case KeyCode.LeftArrow:
                ev.Use();
                if (!string.IsNullOrEmpty(this.mValue))
                {
                    this.mSelectionEnd = Mathf.Max(this.mSelectionEnd - 1, 0);
                    if (!flag2)
                    {
                        this.mSelectionStart = this.mSelectionEnd;
                    }
                    this.UpdateLabel();
                }
                return(true);

            case KeyCode.Home:
                ev.Use();
                if (!string.IsNullOrEmpty(this.mValue))
                {
                    if (this.label.multiLine)
                    {
                        this.mSelectionEnd = this.label.GetCharacterIndex(this.mSelectionEnd, KeyCode.Home);
                    }
                    else
                    {
                        this.mSelectionEnd = 0;
                    }
                    if (!flag2)
                    {
                        this.mSelectionStart = this.mSelectionEnd;
                    }
                    this.UpdateLabel();
                }
                return(true);

            case KeyCode.End:
                ev.Use();
                if (!string.IsNullOrEmpty(this.mValue))
                {
                    if (this.label.multiLine)
                    {
                        this.mSelectionEnd = this.label.GetCharacterIndex(this.mSelectionEnd, KeyCode.End);
                    }
                    else
                    {
                        this.mSelectionEnd = this.mValue.Length;
                    }
                    if (!flag2)
                    {
                        this.mSelectionStart = this.mSelectionEnd;
                    }
                    this.UpdateLabel();
                }
                return(true);

            case KeyCode.PageUp:
                ev.Use();
                if (!string.IsNullOrEmpty(this.mValue))
                {
                    this.mSelectionEnd = 0;
                    if (!flag2)
                    {
                        this.mSelectionStart = this.mSelectionEnd;
                    }
                    this.UpdateLabel();
                }
                return(true);

            case KeyCode.PageDown:
                ev.Use();
                if (!string.IsNullOrEmpty(this.mValue))
                {
                    this.mSelectionEnd = this.mValue.Length;
                    if (!flag2)
                    {
                        this.mSelectionStart = this.mSelectionEnd;
                    }
                    this.UpdateLabel();
                }
                return(true);
            }
        }
        return(false);
    }
示例#60
0
    public override void handFurnitureUIInfo(ref string messageText, ref string actionText, ref KeyCode keyCode, ref Action action)
    {
        switch (lockType)
        {
        case LockType.password:

            keyCode = KeyCode.Space;

            if (isLock)
            {
                actionText = MessageText.Open();
                action     = PushPassWordPage;
            }
            else
            {
                //Open door switch
                actionText = MessageText.Check();
                action     = CorridorDoorSwitch;
            }

            break;

        case LockType.padLock:

            keyCode = KeyCode.Space;

            if (isLock)
            {
                actionText = MessageText.Open();
                action     = PushOpenPadLockScene;
            }
            else
            {
                actionText = MessageText.Check();
                action     = CorridorDoorSwitch;
            }

            break;

        case LockType.puzzle:
            actionText = MessageText.Open();
            keyCode    = KeyCode.Space;
            action     = ShowLockedMessage;
            break;

        default:
            break;
        }
    }