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


C# InputState.IsActive方法代码示例

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


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

示例1: Update

        public void Update(InputState input)
        {
            _model.Frozen = input.WentActive(Keys.Space, false) ? !_model.Frozen : _model.Frozen;

            if (input.IsActive(Modifiers.Control) && input.WentActive(Keys.Right))
            {
                _model.Speed++;
            }

            if (input.IsActive(Modifiers.Control) && input.WentActive(Keys.Left))
            {
                _model.Speed--;
            }
        }
开发者ID:Jaywd,项目名称:binary.fail.project.haumea,代码行数:14,代码来源:WorldDateView.cs

示例2: UpdateSelectionBox

 public void UpdateSelectionBox(InputState input)
 {
     if (input.WentInactive(Buttons.LeftButton))
     {
         _selectionBoxP1 = Vector2.Zero;
         _selectionBoxP2 = Vector2.Zero;
     } else if (input.WentActive(Buttons.LeftButton))
     {
         _selectionBoxP1 = input.ScreenMouse;
         _selectionBoxP2 = input.ScreenMouse;
     }
     else if (input.IsActive(Buttons.LeftButton))
     {
         _selectionBoxP2 = input.ScreenMouse;
     }
 }
开发者ID:Jaywd,项目名称:binary.fail.project.haumea,代码行数:16,代码来源:MapView.cs

示例3: Update

        public void Update(InputState input)
        {
            if (input.WentActive(Keys.F1))
            {
                _dialogMgr.Add(new Prompt(Console.WriteLine));
            }

            AABB selectionBox = new AABB(_selectionBoxP1, _selectionBoxP2);

            int id;
            if (_provinces.TryGetProvinceFromPoint(input.Mouse, out id))
            {
                if (input.WentActive(Buttons.LeftButton) && 
                    _labelClickableBoundaries.ContainsKey(id) &&
                    _labelClickableBoundaries[id].IsPointInside(input.ScreenMouse) &&
                    _units.IsPlayerArmy(id))
                {
                    _unitsSelection.Select(id, input.IsActive(Keys.LeftControl));    
                }
                // Only handle new selections.
                else if (input.WentActive(Buttons.LeftButton))
                {
                    _provinceSelection.Select(id);
                }
                else if (input.WentInactive(Buttons.LeftButton)
                    && selectionBox.Area < _minimumSelectionSize
                    && _unitsSelection.Count > 0)
                {
                    _units.AddOrder(_unitsSelection.Set, id);
                }
                    
                SwapInstrs(_provinceSelection.Hovering);
                _provinceSelection.Hover(id);
                SwapInstrs(id);
            }
            else
            {
                SwapInstrs(_provinceSelection.Hovering);
                _provinceSelection.StopHovering();    
            }

            if (input.WentActive(Keys.G))      MergeSelectedArmies();
            if (input.WentActive(Keys.Escape)) _unitsSelection.DeselectAll();
            if (input.WentActive(Keys.Delete)) DeleteSelectedArmies();

            if (input.WentInactive(Buttons.LeftButton) && selectionBox.Area > _minimumSelectionSize)
            {
                _unitsSelection.DeselectAll();

                // Find all units within the area and select them.
                _labelClickableBoundaries
                    .FindAll(p => _units.IsPlayerArmy(p.Key) && p.Value.Intersects(selectionBox))
                    .ForEach(p => _unitsSelection.Select(p.Key, true));
            }

            UpdateSelectionBox(input);

            if (_unitsSelection.Count > 0)
            {
                Debug.WriteToScreen("Armies", _unitsSelection.Set.Join(", "));    
            }
        }
开发者ID:Jaywd,项目名称:binary.fail.project.haumea,代码行数:62,代码来源:MapView.cs

示例4: Update

        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public void Update(GameTime gameTime)
        {
            // Read input.
            Vector2 screenDim = _spriteBatch.GetScreenDimensions();
            _input = Input.GetState(screenDim,  _renderer.RenderState.ScreenToWorldCoordinates);
            _renderer.RenderState.UpdateAspectRatio(screenDim);

            _tickTime = gameTime.ElapsedGameTime.TotalMilliseconds;

            if (_input.IsActive(Keys.LeftControl) && _input.IsActive(Keys.Q))
            {
                IsRunning = false;
                return;
            }
            if (_input.IsActive(Keys.LeftControl) && _input.IsActive(Keys.S) && !_startServer)
            {
                _startServer = true;
                _trollServer = new Network.Server(6667);
                _trollServer.start();
            }
            if (_input.IsActive(Keys.LeftShift) && _input.IsActive(Keys.S) && _startServer)
            {
                _trollServer.stop();
                _startServer = false;
            }
            if (_input.IsActive(Keys.LeftControl) && _input.IsActive(Keys.C) && !_startClient)
            {
                _startClient = true;
                _trollClient= new Network.Client("192.168.0.3",6667);
                _trollClient.start();
            }
            if (_input.IsActive(Keys.LeftShift) && _input.IsActive(Keys.C) && _startClient)
            {
                _trollClient.stop();
                _startClient = false;
            }
                
            // It is important that _worldDate is updated first of all,
            // since the other components depend on it being in sync.
            _worldDate.Update(gameTime);

            // We update the views in reverse order,
            // because if the input state gets updated by an entity,
            // enties behind (meaning draw before, meaning having a higher index in _views) it
            // should get notified, but not entities in front of it.
            foreach (IView view in _views.Reverse())
            {
                view.Update(_input);
            }

            foreach (IModel entity in _models)
            {
                entity.Update(_worldDate);
            }

            UpdateCamera();

            Debug.WriteToScreen("Slow"     , gameTime.IsRunningSlowly ? "Yes" : "No");
            Debug.WriteToScreen("Zoom"     , _renderer.RenderState.Camera.Zoom);
            Debug.WriteToScreen("Mouse"    , _input.ScreenMouse);
            Debug.WriteToScreen("Mouse rel", _input.MouseRelativeToCenter);
        }
开发者ID:Jaywd,项目名称:binary.fail.project.haumea,代码行数:67,代码来源:Engine.cs


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