Пример #1
0
 public void Push(Hop hop)
 {
     if (m_index >= -1 && m_index < m_hopList.Count - 1)
     {
         // Drop any outstanding redos
         List<Hop> oldList = m_hopList;
         m_hopList = new List<Hop>();
         for (int i = 0; i <= m_index; i++)
         {
             m_hopList.Add(oldList[i]);
         }
     }
     m_hopList.Add(hop);
     m_index += 1;
 }
Пример #2
0
        public Task(string details)
        {
            // Convert to uppercase and strip out spaces
            string cleaned = Regex.Replace(details.ToUpper(), @" ", "", RegexOptions.None);

            Match m = Regex.Match(cleaned, "^(?<number>[0-9]+):(?<level>[BIAE]):(?<positions>[A-M].+):(?<solution>.+)$");
            if (!m.Success)
                throw new ArgumentException("Invalid task specified: " + details);

            Name = m.Groups["number"].Value;
            string level = m.Groups["level"].Value;
            string positions = m.Groups["positions"].Value;
            string solutions = m.Groups["solution"].Value;

            Level difficulty = LevelFromChar(level[0]);
            char red = positions[0];
            char[] greens = positions.Substring(1).ToCharArray();

            List<Hop> solution = new List<Hop>();

            // Split up the solution into separate moves and parse each
            string[] moves = solutions.Split(',');
            foreach (string move in moves)
            {
                string[] steps = move.Split(new char[] { '-', '/' }, StringSplitOptions.RemoveEmptyEntries);
                string start = steps[0];
                if (start.Length != 1)
                    throw new ArgumentException("Invalid task specified - move start invalid: " + move );
                char startPad = start[0];
                for (int i = 1; i < steps.Length; i++)
                {
                    string next = steps[i];
                    if (next.Length != 1)
                        throw new ArgumentException("Invalid task specified - move next invalid: " + move);
                    char endPad = next[0];
                    Hop hop = new Hop(startPad, endPad);
                    solution.Add(hop);
                    startPad = endPad;
                }
            }

            Difficulty = difficulty;
            Red = red;
            Greens = greens;
            Solution = solution;
            Number = sm_taskNumber++;
        }
Пример #3
0
 public void UndoHop(Hop hop)
 {
     PadRoute r = GetRoute(hop.StartPad, hop.EndPad);
     PadState ps = SetPadState(hop.EndPad, PadState.Empty);
     SetPadState(r.Middle, PadState.Green);
     SetPadState(hop.StartPad, ps);
 }
Пример #4
0
 private void ShowHop(Hop hop)
 {
     if (m_showHop != null)
     {
         m_showHop(hop);
     }
 }
Пример #5
0
        private void KeysForHop(Hop hop)
        {
            // Select command
            keybd_event(VK_S, 0, KEYEVENTF_EXTENDEDKEY | 0, 0);
            keybd_event(VK_S, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);

            keybd_event(VK_SPACE, 0, KEYEVENTF_EXTENDEDKEY | 0, 0);
            keybd_event(VK_SPACE, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);

            byte selectKey = ConvertToKey(hop.StartPad);

            keybd_event(selectKey, 0, KEYEVENTF_EXTENDEDKEY | 0, 0);
            keybd_event(selectKey, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);

            keybd_event(VK_RETURN, 0, KEYEVENTF_EXTENDEDKEY | 0, 0);
            keybd_event(VK_RETURN, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);

            Thread.Sleep(2000);

            // Jump command
            keybd_event(VK_J, 0, KEYEVENTF_EXTENDEDKEY | 0, 0);
            keybd_event(VK_J, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);

            keybd_event(VK_SPACE, 0, KEYEVENTF_EXTENDEDKEY | 0, 0);
            keybd_event(VK_SPACE, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);

            byte jumpKey = ConvertToKey(hop.EndPad);

            keybd_event(jumpKey, 0, KEYEVENTF_EXTENDEDKEY | 0, 0);
            keybd_event(jumpKey, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);

            keybd_event(VK_RETURN, 0, KEYEVENTF_EXTENDEDKEY | 0, 0);
            keybd_event(VK_RETURN, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);

            Thread.Sleep(2000);
        }
Пример #6
0
 public JumpResult JumpTo(char jumpToPad)
 {
     if (m_selectedPad == '\0')
         return JumpResult.NoSelection;
     else if (m_possibleHops.IndexOf(jumpToPad) == -1)
         return JumpResult.NotPossible;
     else
     {
         Hop hop = new Hop(m_selectedPad, jumpToPad);
         m_pond.Hop(hop);
         m_hopStack.Push(hop);
         ShowHop(hop);
         SelectPad(jumpToPad);
         // UpdateGameState();
         return JumpResult.Jumped;
     }
 }
Пример #7
0
 private void ShowHop(Hop hop)
 {
     PadView pvStart = m_padViews[hop.StartPad];
     PadView pvEnd = m_padViews[hop.EndPad];
     // Need to od a local animation here? https://msdn.microsoft.com/en-us/library/aa970492(v=vs.110).aspx
 }