Пример #1
0
        public Keypress[] translateInput(GameStateMatch game, KeyboardDevice keyboard)
        {
            Keypress[] cmds = new Keypress[keys.Length];
            int        i    = 0; // length/first_free index in cmds array

            for (int k = 0; k < keys.Length; k++)
            {
                if (keyboard[keys[k]])
                {
                    if (kxpressed[k])
                    {
                        cmds[i++] = new Keypress(commands[k], Keypress.KeypressState.HOLD);
                    }
                    else
                    {
                        kxpressed[k] = true;
                        cmds[i++]    = new Keypress(commands[k], Keypress.KeypressState.PRESS);
                    }
                }
                else
                {
                    if (kxpressed[k])
                    {
                        kxpressed[k] = false;
                        cmds[i++]    = new Keypress(commands[k], Keypress.KeypressState.RELEASE);
                    }
                }
            }

            if (i == 0)
            {
                return(null);
            }

            Keypress[] cmds2 = new Keypress[i];
            int        p     = 0;

            for (int k = 0; k < keys.Length; k++)
            {
                if (cmds[k] != null)
                {
                    cmds2[p++] = cmds[k];
                }
            }

            return(cmds2);
        }
Пример #2
0
        /*
         * public bool CommandAtIs(int time, Keypress c)
         * {
         *  for (int i=0; i<times.Count; i++)
         *      if (times.ElementAt(i) == time)
         *          if (keypress.ElementAt(i).Type == c.Type && (keypress.ElementAt(i).State == Keypress.KeypressState.PRESS || keypress.ElementAt(i).State == Keypress.KeypressState.HOLD))
         *              return true;
         *
         *  return false;
         * }*/



        public Keypress[] CurrentMoveList()
        {
            LinkedList <Keypress> valid = new LinkedList <Keypress>();

            for (int i = 0; i < keypress.Count; i++)
            {
                Keypress c = keypress.ElementAt(i);

                if (c.State == Keypress.KeypressState.PRESS)
                {
                    valid.AddFirst(c);
                }
//                else if (c.State == Command.CommandState.HOLD)
//                    valid.AddLast(c);
//                else if (c.State == Command.CommandState.RELEASE)
//                    valid.AddLast(c);
            }

            return(valid.ToArray <Keypress>());
        }
Пример #3
0
 public Keypress(Keypress cmd, KeypressState state)
 {
     keypresstype = cmd.Type;
     commandstate = state;
 }
Пример #4
0
 public virtual Keypress[] getKeySequence()
 {
     Keypress[] kp = new Keypress[1];
     kp[0] = Keypress.KeyNULL;
     return(kp);
 }
Пример #5
0
 public void addKeypress(Keypress c, int time)
 {
     keypress.AddFirst(c);
     times.AddFirst(time);
 }