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


C# InputHandler.CheckPressedKey方法代码示例

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


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

示例1: Update

 public override void Update(InputHandler handler)
 {
     normal = false;
     if(handler.CheckPressedKey(Keys.L) && editing)
     {
         normal = true;
     }
     base.Update(handler);
 }
开发者ID:TheCreatorJames,项目名称:TajTetrisGame,代码行数:9,代码来源:LightLevelCircle.cs

示例2: UpdateTextBox

        public static void UpdateTextBox(DragDropTextbox textbox, InputHandler inputHandler)
        {
            #region If there is a textbox
                if (textbox != null)
                {
                    var keys = inputHandler.KeysJustPressed();
                    #region Detect Normal Keys
                    foreach (var key in keys)
                    {

                        char keyLetter = (char)key;
                        if ((keyLetter >= 'A' && keyLetter <= 'Z') || (keyLetter >= '0' && keyLetter <= '9'))
                        {
                            if (!inputHandler.CheckPressedKey(Microsoft.Xna.Framework.Input.Keys.LeftShift))
                            {
                                keyLetter = Char.ToLower(keyLetter);
                            }
                            else
                            {
                                switch (keyLetter)
                                {
                                    case '0':
                                        keyLetter = ')';
                                        break;
                                    case '1':
                                        keyLetter = '!';
                                        break;
                                    case '2':
                                        keyLetter = '@';
                                        break;
                                    case '3':
                                        keyLetter = '#';
                                        break;
                                    case '4':
                                        keyLetter = '$';
                                        break;
                                    case '5':
                                        keyLetter = '%';
                                        break;
                                    case '6':
                                        keyLetter = '^';
                                        break;
                                    case '7':
                                        keyLetter = '&';
                                        break;
                                    case '8':
                                        keyLetter = '*';
                                        break;
                                    case '9':
                                        keyLetter = '(';
                                        break;
                                }
                            }

                            (textbox).AddLetter(keyLetter);

                        }
                    }
                    #endregion
                    #region Other Keys
                    if (inputHandler.CheckJustPressedKey(Microsoft.Xna.Framework.Input.Keys.Back))
                    {
                        (textbox).RemoveLetter();
                    }

                    if (inputHandler.CheckJustPressedKey(Microsoft.Xna.Framework.Input.Keys.OemMinus))
                    {
                        if (inputHandler.CheckPressedKey(Microsoft.Xna.Framework.Input.Keys.LeftShift))
                            (textbox).AddLetter('_');
                        else
                            (textbox).AddLetter('-');
                    }

                    if (inputHandler.CheckJustPressedKey(Microsoft.Xna.Framework.Input.Keys.OemPlus))
                    {
                        if (inputHandler.CheckPressedKey(Microsoft.Xna.Framework.Input.Keys.LeftShift))
                            (textbox).AddLetter('+');
                        else
                            (textbox).AddLetter('=');
                    }

                    if (inputHandler.CheckJustPressedKey(Microsoft.Xna.Framework.Input.Keys.Left))
                    {
                        (textbox).PositionDecrease();
                        scrollTextbox = 1;
                    }

                    if (inputHandler.CheckJustPressedKey(Microsoft.Xna.Framework.Input.Keys.Enter))
                    {
                        (textbox).Enter();
                    }

                    if (inputHandler.CheckJustPressedKey(Microsoft.Xna.Framework.Input.Keys.Space))
                    {
                        (textbox).AddLetter(' ');
                    }

                    if (inputHandler.CheckJustPressedKey(Microsoft.Xna.Framework.Input.Keys.OemComma))
                    {
                        if (!inputHandler.CheckPressedKey(Microsoft.Xna.Framework.Input.Keys.LeftShift))
//.........这里部分代码省略.........
开发者ID:TheCreatorJames,项目名称:TajTetrisGame,代码行数:101,代码来源:DragDropInterface.cs

示例3: Update

        public void Update(InputHandler handler)
        {
            try
            {
                if (textBox.GetSelected())
                {
                    DragDropInterface.UpdateTextBox(textBox, handler);

                    return;
                }

                if (fileMode != 0)
                {
                    if (fileMode == 1)
                    {

                        SaveFileSystem.SaveObjectToFile(new World(objects.ToArray()), "Levels" + Path.DirectorySeparatorChar + textBox.GetText() + ".taj");
                        textBox.SetText("");
                    }
                    else if (fileMode == 2)
                    {
                        World n = SaveFileSystem.LoadObjectFromFile<World>("Levels" + Path.DirectorySeparatorChar + textBox.GetText() + ".taj", new GameLoader());
                        objects.Clear();
                        objects.AddRange(n.GetObjects());
                    }
                    else if (fileMode == 3)
                    {

                        ((LevelPerson)couldDrag).SetBodyAnimation(textBox.GetText() + ".taj");
                        ((LevelPerson)couldDrag).SetLoop(true);
                        ((LevelPerson)couldDrag).SetPlaying(true);

                    }
                    else if (fileMode == 4)
                    {

                        ((LevelPerson)couldDrag).SetName(textBox.GetText());

                    }
                    else if (fileMode ==5)
                    {
                        SaveFileSystem.SaveObjectToFile(new World(objects.ToArray()), "Levels" + Path.DirectorySeparatorChar + textBox.GetText() + ".taj");

                        fileName = "Levels" + Path.DirectorySeparatorChar  + textBox.GetText() + ".taj";
                        safeFileName = textBox.GetText() + ".taj";
                        finished = true;
                    }

                    textBox.SetText("");
                    fileMode = 0;
                }

                if (animationMode)
                {

                    tool.Update(handler);

                    if (tool.GetDone()) animationMode = false;
                    return;
                }

                if (!modifyingOne)
                    foreach (LevelObject o in objects)
                    {
                        o.Update(handler);
                        o.SetEditing(!hideEditing);

                        if (o.Modifying())
                        {
                            modifying = o;
                            modifyingOne = true;
                            break;
                        }

                        if (!dragging && o.CheckInside(handler))
                        {

                            if (o is LightLevelCircle)
                            {
                                if (handler.CheckPressedKey(Keys.L))
                                {
                                    couldDrag = o;
                                }
                            }
                            else
                                couldDrag = o;
                        }

                    }
                else
                {
                    modifying.Update(handler);
                    if (!modifying.Modifying())
                    {
                        modifying = null;
                        modifyingOne = false;
                    }
                }

                if (handler.CheckJustPressedKey(Keys.H))
//.........这里部分代码省略.........
开发者ID:TheCreatorJames,项目名称:TajTetrisGame,代码行数:101,代码来源:WorldEditor.cs

示例4: Update

        public void Update(InputHandler inputHandler)
        {
            #region Update Parts
            UpdateMode(inputHandler);
            UpdateElements(inputHandler);
            UpdateScrolling(inputHandler);
            UpdateTextBox(inputHandler);
            UpdateSuggestions(inputHandler);
            #endregion

            if(inputHandler.CheckJustPressedKey(Keys.E) && inputHandler.CheckPressedKey(Keys.D9))
            {
               TajLevelLinker linker = new TajLevelLinker();
               foreach(LooseDragDropLink link in elements)
                {
                    if(link  != null)
                    {
                        if(link.GetElement() is CodeDragDropHolder)
                        {
                            CodeDragDropHolder holder = ((CodeDragDropHolder)link.GetElement());

                            // "Code", "If", "Else", "EndIf", "Start", "Cleared Row", "Cleared Red", "Cleared Blue", "Cleared Teal", "Cleared Purple", "Cleared Orange", "Cleared Yellow", "Cleared Green", "Cleared Any Color"
                            switch(holder.GetMode())
                            {
                            case 4:
                                linker.OnStart(holder.GetCode());
                                break;
                            case 5 :
                                linker.SetRowCleared(holder.GetCode());
                                break;
                            case 6:

                                linker.SetRedCleared(holder.GetCode());
                                break;
                            case 7:

                                linker.SetBlueCleared(holder.GetCode());
                                break;
                            case 8:

                                linker.SetTealCleared(holder.GetCode());
                                break;
                            case 9:
                                linker.SetPurpleCleared(holder.GetCode());
                                break;
                            case 10:

                                linker.SetOrangeCleared(holder.GetCode());
                                break;
                            case 11:

                                linker.SetYellowCleared(holder.GetCode());
                                break;
                            case 12:
                                linker.SetGreenCleared(holder.GetCode());
                                break;
                            case 13:
                                linker.SetAnyCleared(holder.GetCode());
                                break;
                            }

                        }
                    }
                }
               linker.CreateGame(fileName);
               linker.SetFullSave(true);
               SaveFileSystem.SaveObjectToFile(linker, "LevelPacks" + Path.DirectorySeparatorChar + safeFileName);
            }

            /*
            if(inputHandler.CheckJustPressedKey(Keys.Y))
            {

                TempList list = new TempList();
                list.elements = this.elements.ToArray();

                SaveFileSystem.SaveObjectToFile(list, "Haha.taj");
            }
            */
            //Temporary Code
            if(classManager == null && !test)
            {

                suggestions.Add(new LooseDragDropLink(new StringTextbox()));
                suggestions.Add(new LooseDragDropLink(new NumberTextbox()));
                suggestions.Add(new LooseDragDropLink(new BooleanDragDrop()));
                suggestions.Add(new LooseDragDropLink(new NotBooleanMethod()));
                suggestions.Add(new LooseDragDropLink(new BooleanMethod()));
                suggestions.Add(new LooseDragDropLink(new NumberMethodDragDrop()));
                suggestions.Add(new LooseDragDropLink(new NumberMethod()));
                suggestions.Add(new LooseDragDropLink(new StringMethod()));
                suggestions.Add(new LooseDragDropLink(new SetVariableDragDrop()));
                suggestions.Add(new LooseDragDropLink(new GameCommandDragDrop()));
                suggestions.Add(new LooseDragDropLink(new GetVariableDragDrop()));
                suggestions.Add(new LooseDragDropLink(new CodeTextbox()));
                suggestions.Add(new LooseDragDropLink(new CodeDragDropHolder()));

                test = true;
                //Show New Class Button
            }
//.........这里部分代码省略.........
开发者ID:TheCreatorJames,项目名称:TajTetrisGame,代码行数:101,代码来源:DragDropInterface.cs

示例5: Update


//.........这里部分代码省略.........
                }

                if (handler.CheckJustPressedKey(Keys.B))
                {
                    dragBody = !dragBody;
                }

                if (handler.CheckJustPressedKey(Keys.Z))
                {
                    squareOrCircle = !squareOrCircle;
                }

                if (handler.CheckJustPressedKey(Keys.OemPlus))
                {
                    ff++;
                    ff %= frames;
                    left.LoadFrame(ff);
                    right.LoadFrame(ff);
                    lright.LoadFrame(ff);
                    lleft.LoadFrame(ff);

                }

                if (handler.CheckJustPressedKey(Keys.OemMinus))
                {
                    ff--;
                    if (ff < 0) ff = 0;
                    left.LoadFrame(ff);
                    right.LoadFrame(ff);
                    lright.LoadFrame(ff);
                    lleft.LoadFrame(ff);
                }

                if (handler.CheckPressedKey(Keys.LeftShift) || handler.CheckPressedKey(Keys.RightShift))
                {
                    if (handler.CheckPressedKey(Keys.Down))
                    {
                        testingRectangle.ModifyHeight(SPEED);
                    }

                    if (handler.CheckPressedKey(Keys.Up))
                    {
                        testingRectangle.ModifyHeight(-SPEED);
                    }

                    if (handler.CheckPressedKey(Keys.Left))
                    {
                        testingRectangle.ModifyWidth(-SPEED);
                    }

                    if (handler.CheckPressedKey(Keys.Right))
                    {
                        testingRectangle.ModifyWidth(SPEED);
                    }
                }
                else
                {
                    if (handler.CheckPressedKey(Keys.Down))
                    {
                        testingRectangle.ModifyY(SPEED);
                    }

                    if (handler.CheckPressedKey(Keys.Up))
                    {
                        testingRectangle.ModifyY(-SPEED);
                    }
开发者ID:TheCreatorJames,项目名称:TajTetrisGame,代码行数:67,代码来源:AnimationTool.cs


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