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


C# InputHandler.CheckJustPressedKey方法代码示例

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


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

示例1: Update

        public void Update(InputHandler handler, int x, int y)
        {
            if (!neverEditAgain)
            {
                if (handler.CheckJustPressedKey(Keys.H))
                {
                    showMode = !showMode;
                }

                if (handler.CheckLeftMouseJustPressed())
                {
                    if (handler.CheckMouseIn(c.ScalePosition(start)))
                    {
                        dragPointC = true;
                        original = c.GetPoint();
                    }
                    else
                        if (handler.CheckMouseIn(b.ScalePosition(start)))
                        {
                            dragPointB = true;

                            original = b.GetPoint();
                        }
                        else
                            if (handler.CheckMouseIn(a.ScalePosition(start)))
                            {
                                dragPointA = true;

                                original = a.GetPoint();
                            }
                }
                else
                    if (handler.CheckLeftMouseJustReleased())
                    {
                        dragPointA = dragPointB = dragPointC = false;
                    }

                    if (dragPointA)
                    {
                        a.SetPoint(original + handler.LeftMouseDraggedBy());
                    }
                    else
                        if (dragPointB)
                        {

                            b.SetPoint(original + handler.LeftMouseDraggedBy());
                        }
                        else
                            if (dragPointC)
                            {

                                c.SetPoint(original + handler.LeftMouseDraggedBy());
                            }
            }
            start.X = x;
            start.Y = y;
        }
开发者ID:TheCreatorJames,项目名称:TajTetrisGame,代码行数:57,代码来源:ArmTool.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

        public void Update(InputHandler handler)
        {
            try
            {
                if (done)
                {
                    done = false;
                    return;
                }

                if (modeB)
                {

                    if(frames == 0)
                    {
                        ff = 0;
                        modeB = false;
                        return;
                    }
                    ff++;
                    ff %= frames;
                    left.LoadFrame(ff);
                    right.LoadFrame(ff);
                    lright.LoadFrame(ff);
                    lleft.LoadFrame(ff);
                }

                DragDropInterface.UpdateTextBox(textBox, handler);
                if (textBox.GetSelected()) return;
                if (fileMode != 0)
                {
                    if (fileMode == 1)
                    {
                        SaveFileSystem.SaveObjectToFile(new BodyAnimation(left, right, lleft, lright, frames), "Animations" + Path.DirectorySeparatorChar + textBox.GetText() + ".taj");
                        textBox.SetText("");

                    }
                    else if (fileMode == 2)
                    {
                        BodyAnimation a = SaveFileSystem.LoadObjectFromFile<BodyAnimation>("Animations" + Path.DirectorySeparatorChar + textBox.GetText() + ".taj", new GameLoader());
                        this.left = a.GetLeft();
                        this.lleft = a.GetLegLeft();
                        this.lright = a.GetLegRight();
                        this.right = a.GetRight();

                        this.frames = a.GetFrames();

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

                left.Update(handler, testingRectangle.GetX(), testingRectangle.GetY() + 20);
                right.Update(handler, testingRectangle.GetX() + testingRectangle.GetWidth(), testingRectangle.GetY() + 20);
                lleft.Update(handler, testingRectangle.GetX() + 20, testingRectangle.GetY() + testingRectangle.GetHeight());
                lright.Update(handler, testingRectangle.GetX() - 20 + testingRectangle.GetWidth(), testingRectangle.GetY() + testingRectangle.GetHeight());

                if (!dragging && handler.CheckJustPressedKey(Keys.M))
                {
                    mode = !mode;
                }

                if (handler.CheckJustPressedKey(Keys.Escape) || handler.CheckJustPressedKey(Keys.A))
                {
                    done = true;
                }

                if (handler.CheckJustPressedKey(Keys.OemSemicolon))
                {
                    if (frames == 0) return;
                    modeB = !modeB;
                }

                if (handler.CheckJustPressedKey(Keys.D1))
                {
                    textBox.TellSelected(true);
                    fileMode = 1;

                }

                if (handler.CheckJustPressedKey(Keys.D2))
                {

                    textBox.TellSelected(true);
                    fileMode = 2;

                }

                if (handler.CheckJustPressedKey(Keys.S))
                {
                    left.SaveArm();
                    right.SaveArm();
                    lright.SaveArm();
                    lleft.SaveArm();
                    frames++;
                    ff++;
                }

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


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