• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# InputState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中InputState的典型用法代码示例。如果您正苦于以下问题:C# InputState类的具体用法?C# InputState怎么用?C# InputState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



InputState类属于命名空间,在下文中一共展示了InputState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Start

	void Start () {

		//body2D = GetComponent<Rigidbody2D> ();
		player = gameObject.GetComponent<Transform> ();
		player.position = setPosition ((int)Positions.TOP);
		inputState = GetComponent<InputState>();
	}
开发者ID:MrrBond,项目名称:teamugly,代码行数:7,代码来源:CharacterMovement.cs


示例2: DirectionalIndicator

        public DirectionalIndicator(
                ContentUtil content, 
                InputState.Move move,
                float beatTimeInMs,
                float travelSpeed)
        {
            this.recordings = new List<RecordedStart>();
            this.color = Color.White;
            this.move = move;
            this.beatTimeInMs = beatTimeInMs;
            this.travelSpeed = travelSpeed;
            String texName = "hud/arrow_" + move.ToString().ToLower();
            this.texture = new ScaledTexture(
                content.load<Texture2D>(texName), TEXTURE_SCALE);
            switch (move) {
                case InputState.Move.UP:
                    this.direction = new Vector2(0, 1);
                    break;
                case InputState.Move.DOWN:
                    this.direction = new Vector2(0, -1);
                    break;
                case InputState.Move.LEFT:
                    this.direction = new Vector2(1, 0);
                    break;
                case InputState.Move.RIGHT:
                    this.direction = new Vector2(-1, 0);
                    break;
            }

            this.isMoving = false;
        }
开发者ID:RavenNevermore,项目名称:Omnom-III,代码行数:31,代码来源:DirectionalIndicator.cs


示例3: UpdatePlayerActionInput

        /// <summary>
        /// This is how we hook keyboard/other input.
        /// </summary>
        /// <param name="input"></param>
        /// <param name="allowFull"></param>
        /// <returns></returns>
        public override bool UpdatePlayerActionInput(InputState input, bool allowFull)
        {
            // this is a simple, hard coded example to handle input from a player
            // we can probably add some kind of modifier key here for doing something else cool
            if (input.IsKeyReleased(Keys.OemPlus))
            {
                bool canAutoTarget = false;
                bool canTargetSpace = false;
                bool isAutoTarget;
                bool isTargetBlocked;

                // find something to kill
                ITarget targetHere = this._world.Cursor.GetTargetHere(canAutoTarget, canTargetSpace, out isAutoTarget, out isTargetBlocked);
                if (null != targetHere)
                {
                    // output some data to the debug log
                    DebugLog.Write("Terminating target: {0}", targetHere.DisplayName);

                    // kill it
                    Damage.ApplyDamage(targetHere, targetHere.Health);
                }
            }

            return base.UpdatePlayerActionInput(input, allowFull);
        }
开发者ID:hross,项目名称:TheHollow,代码行数:31,代码来源:Game1Hook.cs


示例4: UpdateEmpty

    void UpdateEmpty()
    {
        var chrono = FindObjectOfType<Chrono>();
        var disco = FindObjectOfType<Disco>();
        var collider = GetComponent<SphereCollider>();

        var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        var info = new RaycastHit();
        var hit = Physics.Raycast(ray, out info);

        if (!hit)
            return;

        var obj = info.collider.gameObject;
        if (!obj)
            return;

        if (obj.CompareTag("Bouncer"))
        {
            hover_object = obj;
            hover_object.GetComponent<Renderer>().material.color = Color.green;

            state = InputState.Hover;
            return;
        }

        if (obj.CompareTag("Palette"))
        {
            hover_object = obj;
            hover_object.GetComponent<Renderer>().material.color = Color.green;

            state = InputState.Hover;
            return;
        }
    }
开发者ID:kalineh,项目名称:woop,代码行数:35,代码来源:MouseControls.cs


示例5: OnPlayerInput

        //Oxide Hook
        void OnPlayerInput(BasePlayer player, InputState input)
        {
            if (this.allowAdminRotate && player.IsAdmin() && player.GetActiveItem() != null && player.GetActiveItem().info.shortname.Equals("hammer"))
            {
                if (input.WasJustPressed(BUTTON.FIRE_PRIMARY))
                {
                    RaycastHit hit;
                    if (Physics.Raycast(player.eyes.position, (player.eyes.rotation * Vector3.forward), out hit, 2f, Layers.Server.Buildings))
                    {
                        BaseEntity baseEntity = hit.collider.gameObject.ToBaseEntity();
                        if (baseEntity != null)
                        {
                            BuildingBlock block = baseEntity.GetComponent<BuildingBlock>();
                            if (block != null && block.blockDefinition.canRotate && !this.instanceIDs.Contains(block.GetInstanceID()))
                            {
                                block.SetFlag(BaseEntity.Flags.Reserved1, true);
                                addBlockToLists(block.GetInstanceID(), DateTime.Now.AddMinutes(-this.amountOfMinutesAfterUpgrade).ToString());

                                int remainingSeconds = timerInterval - DateTime.Now.Subtract(lastTimerTick).Seconds;
                                SendReply(player, "<color=green>You can now rotate this " + block.blockDefinition.info.name.english + " for " + remainingSeconds +  " seconds.</color>");
                            }
                        }
                    }
                }
            }
        }
开发者ID:SHOrdr,项目名称:Rust,代码行数:27,代码来源:RotateOnUpgrade.cs


示例6: ProcessKey

 protected override void ProcessKey(ConsoleKeyInfo consoleKey, InputState inputState)
 {
     switch(consoleKey.Key)
     {
         case ConsoleKey.Backspace:
             if(inputState.CarrageIndex > 0)
             {
                 inputState.Line.Remove(inputState.CarrageIndex - 1, 1);
                 inputState.CarrageIndex--;
                 Console.Write("\b");
                 inputState.RefreshTail(1);
             }
             break;
         case ConsoleKey.Delete:
             if(inputState.CarrageIndex < inputState.Line.Length)
             {
                 inputState.Line.Remove(inputState.CarrageIndex, 1);
                 inputState.RefreshTail(1);
             }
             break;
         default:
             base.ProcessKey(consoleKey, inputState);
             break;
     }
 }
开发者ID:mijay,项目名称:Shell,代码行数:25,代码来源:ConsoleEditorWithRemove.cs


示例7: HandleInput

 protected override void HandleInput(UserInput button, InputState state)
 {
     //First we need to define if we are inside the ingame screen
     if (state == InputState.Ingame)
     {
         //If the pressed button equals Start we open the menu screen and disable ingame input
         if (button == UserInput.Start)
         {
             StopAllCoroutines();
             StartCoroutine(OpenPauseMenu());
         }
     }
     //If we are not then maybe we are inside the menus screen?
     else if (state == InputState.PauseMenu)
     {
         switch (button)
         {
             case UserInput.Start:
                 StopAllCoroutines();
                 StartCoroutine(ClosePauseMenu());
                 break;
             case UserInput.Up:
                 Up();
                 break;
             case UserInput.Down:
                 Down();
                 break;
             case UserInput.A:
                 selectedButton.Invoke();
                 break;
         }
     }
 }
开发者ID:Schadek,项目名称:Skelevator,代码行数:33,代码来源:MainMenu.cs


示例8: HandleInput

        public override void HandleInput(GameTime gameTime, InputState input)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            GamePadState gamePadState = input.CurrentGamePadState;

            if (pauseAction.Evaluate(input))
            {
                ScreenManager.AddScreen(new PauseScreen());
            }
            else
            {
                Vector2 movement = Vector2.Zero;

                if (input.touchState.Count > 0)
                {
                    Vector2 touchPosition = input.touchState[0].Position;
                    Vector2 direction = touchPosition - playerPosition;
                    direction.Normalize();
                    movement += direction;
                }

                if (movement.Length() > 1)
                    movement.Normalize();

                playerPosition += movement * 8f;
            }
        }
开发者ID:V1ncam,项目名称:Tetris,代码行数:29,代码来源:GameplayScreen.cs


示例9: Evaluate

        /// <summary>
        /// Evaluates the action against a given InputState.
        /// </summary>
        /// <param name="state">The InputState to test for the action.</param>
        /// <param name="controllingPlayer">The player to test, or null to allow any player.</param>
        /// <param name="player">If controllingPlayer is null, this is the player that performed the action.</param>
        /// <returns>True if the action occurred, false otherwise.</returns>
        public bool Evaluate(InputState state, PlayerIndex? controllingPlayer, out PlayerIndex player)
        {
            // Figure out which delegate methods to map from the state which takes care of our "newPressOnly" logic
            ButtonPress buttonTest;
            KeyPress keyTest;
            if (newPressOnly)
            {
                buttonTest = state.IsNewButtonPress;
                keyTest = state.IsNewKeyPress;
            }
            else
            {
                buttonTest = state.IsButtonPressed;
                keyTest = state.IsKeyPressed;
            }

            // Now we simply need to invoke the appropriate methods for each button and key in our collections
            foreach (Buttons button in buttons)
            {
                if (buttonTest(button, controllingPlayer, out player))
                    return true;
            }
            foreach (Keys key in keys)
            {
                if (keyTest(key, controllingPlayer, out player))
                    return true;
            }

            // If we got here, the action is not matched
            player = PlayerIndex.One;
            return false;
        }
开发者ID:jmoral4,项目名称:Tears,代码行数:39,代码来源:InputAction.cs


示例10: HandleLeftMoveRightAttack

        void HandleLeftMoveRightAttack(InputState state,Vector3 acc)
        {
            var player = MyPlayerController.Instance;
            Vector3 weapon = new Vector3(Mathf.Clamp(EulerAsin(-acc.z), -45f, 30f), 0, 0);	// 視線
            const float DUMP = 0.4f;	// 減衰

            if(state == InputState.NONE)
            {
                player.ActAttackEnd();
                if (acc.x > 0) player.TurnRight(acc.x); else player.TurnLeft(-acc.x);
            }
            else if(state == InputState.MOVE)
            {
                player.ActAttackEnd();
                if (acc.z < 0) player.MoveForward(-acc.z); else player.MoveBack(acc.z);
                if (acc.x > 0) player.MoveRight(acc.x); else player.MoveLeft(-acc.x);
                weapon = Vector3.zero;
            }
            else if(state == InputState.ATTACK)
            {
                player.ActAttackStart();
                if (acc.x > 0) player.TurnRight(acc.x); else player.TurnLeft(-acc.x);
            }
            else if(state == InputState.ATTACK_AND_MOVE)
            {
                player.ActAttackStart();
                if (acc.x > 0) player.TurnRight(acc.x * DUMP); else player.TurnLeft(-acc.x * DUMP);
                if (acc.x > 0) player.MoveRight(acc.x * DUMP); else player.MoveLeft(-acc.x * DUMP);
                if (acc.z < 0) player.MoveForward(-acc.z * DUMP); else player.MoveBack(acc.z * DUMP);
            }
            // 視線
            _BufferWeaponAngle = _BufferWeaponAngle * 0.9f + weapon * 0.1f;
            player.WeaponAngle = _BufferWeaponAngle;
        }
开发者ID:hidetobara,项目名称:Painter,代码行数:34,代码来源:InputAdapter.cs


示例11: Awake

	void Awake () {
		inputState = GetComponent<InputState> ();
		walkBehaviour = GetComponent<Walk> ();
		duckBehaviour = GetComponent<Duck> ();
		animator = GetComponent<Animator> ();
		collisionState = GetComponent<CollisionState> ();
	}
开发者ID:scott-goetz,项目名称:town-hall,代码行数:7,代码来源:PlayerManager.cs


示例12: DoResize

 public override void DoResize(DiagramView view, RectangleF origRect, PointF newPoint, int whichHandle, InputState evttype, SizeF min, SizeF max)
 {
     INodeIconConstraint constraint1 = this.Constraint;
     SizeF ef1 = constraint1.MinimumIconSize;
     SizeF ef2 = constraint1.MaximumIconSize;
     base.DoResize(view, origRect, newPoint, whichHandle, evttype, ef1, ef2);
 }
开发者ID:JBTech,项目名称:Dot.Utility,代码行数:7,代码来源:NodeIcon.cs


示例13: UniversalDetector

 public UniversalDetector(int languageFilter) { 
     this.start = true;
     this.inputState = InputState.PureASCII;
     this.lastChar = 0x00;   
     this.bestGuess = -1;
     this.languageFilter = languageFilter;
 }
开发者ID:shu2333,项目名称:dnGrep,代码行数:7,代码来源:UniversalDetector.cs


示例14: Update

        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            if (!Game.IsActive)
                return;

            input = new InputState();
            WiimoteLib.PointF ws = wm.WiimoteState.IRState.Midpoint;
            input.Position.X = GameEngine.WIDTH * (1 - ws.X);
            input.Position.Y = GameEngine.HEIGHT * ws.Y;
            float time = gameTime.ElapsedGameTime.Milliseconds; // time elapsed since last update
            Vector2 posDiff = input.Position - buffer.CurrentPosition;
            input.Velocity = posDiff / time;
            WiimoteLib.Point3F acc = wm.WiimoteState.AccelState.Values;
            input.Acceleration = new Vector2(acc.X, acc.Y);

            input.Pause = wm.WiimoteState.ButtonState.Home;
            input.Confirm = wm.WiimoteState.ButtonState.A;

            if (ws.X == 0.0f && ws.Y == 0.0f) // sensor bar out of range
            {
                input.Position = lastPosition;
                posDiff = new Vector2();
            }
            else
            {
                lastPosition = input.Position;
            }

            if (Math.Abs(posDiff.X) > POS_DIFF_THRESHOLD || Math.Abs(posDiff.Y) > POS_DIFF_THRESHOLD) // add only only if the baton has moved at least a decent amount of distance
            {
                buffer.Add(input);
            }
            base.Update(gameTime);
        }
开发者ID:calebperkins,项目名称:Ensembler,代码行数:38,代码来源:WiiController.cs


示例15: HandleInput

        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            if (input == null)
            {
                return;
            }

            // Look up inputs for the active player profile.
            if (ControllingPlayer == null)
            {
                Debug.WriteLine("ControllingPlayer is null...");
                return;
            }
            var playerIndex = (int)ControllingPlayer.Value;

            var keyboardState = input.CurrentKeyboardStates[playerIndex];
            var gamePadState = input.CurrentGamePadStates[playerIndex];

            // The game pauses either if the user presses the pause button, or if
            // they unplug the active gamepad. This requires us to keep track of
            // whether a gamepad was ever plugged in, because we don't want to pause
            // on PC if they are playing with a keyboard and have no gamepad at all!
            var gamePadDisconnected = !gamePadState.IsConnected &&
                                      input.GamePadWasConnected[playerIndex];

            if (input.IsPauseGame(ControllingPlayer) || gamePadDisconnected)
            {
                const string message = "Pause. Do you really want to exit game?";
                var confirmExit = new DecisionScreen(message);
                confirmExit.Accepted += ConfirmExitGameAccepted;
                ScreenManager.AddScreen(confirmExit, ControllingPlayer);
            }
        }
开发者ID:CTU-FEE-Y39PHA-43-2010,项目名称:BombermanAdventure,代码行数:37,代码来源:PlayingScreen.cs


示例16: HandleInput

 public override void HandleInput(GameTime gameTime, InputState input)
 {
     if (_activeMenuEntry!=null)
         _activeMenuEntry.HandleInput(gameTime,input);
     else
         base.HandleInput(gameTime, input);
 }
开发者ID:Bajena,项目名称:Miner,代码行数:7,代码来源:ControlsOptionsMenuScreen.cs


示例17: HandleInput

 private void HandleInput(UserInput button, InputState state)
 {
     if (button == UserInput.A && state == InputState.Ingame)
     {
         m_Jump = true;
     }
 }
开发者ID:Schadek,项目名称:Skelevator,代码行数:7,代码来源:ThirdPersonUserControl.cs


示例18: HandleInput

        public override void HandleInput(GameTime gameTime, InputState inputState)
        {
            base.HandleInput(gameTime, inputState);

            if (increaseCountAction.Evaluate(inputState))
            {
                switch (SelectedMenuItemIndex)
                {
                    case 0:
                        verticalNodeCount = verticalNodeCount + 1 > verticalMax ? verticalMax : verticalNodeCount + 1;
                        MenuItems[0].Text = String.Format("Vertical Nodes: {0}", verticalNodeCount);
                        break;
                    case 1:
                        horizontalNodeCount = horizontalNodeCount + 1 > horizontalMax ? horizontalMax : horizontalNodeCount + 1;
                        MenuItems[1].Text = String.Format("Horizontal Nodes: {0}", horizontalNodeCount);
                        break;
                }
            }

            if (decreaseCountAction.Evaluate(inputState))
            {
                switch (SelectedMenuItemIndex)
                {
                    case 0:
                        verticalNodeCount = verticalNodeCount - 1 < verticalMin ? verticalMin : verticalNodeCount - 1;
                        MenuItems[0].Text = String.Format("Vertical Nodes: {0}", verticalNodeCount);
                        break;
                    case 1:
                        horizontalNodeCount = horizontalNodeCount - 1 < horizontalMin ? horizontalMin : horizontalNodeCount - 1;
                        MenuItems[1].Text = String.Format("Horizontal Nodes: {0}", horizontalNodeCount);
                        break;
                }
            }
        }
开发者ID:Grahamcraker,项目名称:Project_Greenhorn,代码行数:34,代码来源:MapEditorConfigMenuScreen.cs


示例19: ProcessKey

 protected override void ProcessKey(ConsoleKeyInfo consoleKey, InputState inputState)
 {
     switch(consoleKey.Key)
     {
         case ConsoleKey.End:
             if(inputState.CarrageIndex < inputState.Line.Length)
             {
                 inputState.GotoEnd();
             }
             break;
         case ConsoleKey.Home:
             if(inputState.CarrageIndex > 0)
             {
                 inputState.GotoBegin();
             }
             break;
         case ConsoleKey.LeftArrow:
             if(inputState.CarrageIndex > 0)
             {
                 inputState.CarrageIndex--;
                 Console.Write('\b');
             }
             break;
         case ConsoleKey.RightArrow:
             if(inputState.CarrageIndex < inputState.Line.Length)
             {
                 Console.Write(inputState.Line.ToString().Substring(inputState.CarrageIndex, 1));
                 inputState.CarrageIndex++;
             }
             break;
         default:
             base.ProcessKey(consoleKey, inputState);
             return;
     }
 }
开发者ID:mijay,项目名称:Shell,代码行数:35,代码来源:ConsoleEditorWithNavigation.cs


示例20: GetState

        /// <summary>
        ///     Gets the current InputState.
        /// </summary>
        /// <param name="touch">The current touch.</param>
        /// <param name="state">The state to check against.</param>
        /// <returns>True if the InputState matches the current input</returns>
        /// <exception cref="System.ArgumentOutOfRangeException">touch;null</exception>
        public static bool GetState(Touch touch, InputState state)
        {
            #if UNITY_EDITOR
            switch (state)
            {
                case InputState.Began:
                    return Input.GetMouseButtonDown(0);
                case InputState.Moving:
                    return Input.GetMouseButton(0);
                case InputState.Ended:
                    return Input.GetMouseButtonUp(0);
                case InputState.Canceled:
                    return false;
                default:
                    throw new ArgumentOutOfRangeException("touch", state, null);
            }
            #else
            switch (state)
            {
                case InputState.Began:
                    return touch.phase == TouchPhase.Began;
                case InputState.Moving:
                    return touch.phase == TouchPhase.Moved;
                case InputState.Ended:
                    return touch.phase == TouchPhase.Ended;
                case InputState.Canceled:
                    return touch.phase == TouchPhase.Canceled;
                default:
                    throw new ArgumentOutOfRangeException("touchPhase", state, null);
            }

            #endif //UNITY_EDITOR
        }
开发者ID:AnotherGameCompany,项目名称:LWD-2018,代码行数:40,代码来源:EditorInput.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# InputType类代码示例发布时间:2022-05-24
下一篇:
C# InputMode类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap