コード例 #1
0
ファイル: HopStack.cs プロジェクト: JFarlette/Hopper
 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
ファイル: Tasks.cs プロジェクト: JFarlette/Hopper
        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
ファイル: Pond.cs プロジェクト: JFarlette/Hopper
 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
ファイル: GameManager.cs プロジェクト: JFarlette/Hopper
 private void ShowHop(Hop hop)
 {
     if (m_showHop != null)
     {
         m_showHop(hop);
     }
 }
コード例 #5
0
ファイル: GameManager.cs プロジェクト: JFarlette/Hopper
        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
ファイル: GameManager.cs プロジェクト: JFarlette/Hopper
 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
ファイル: MainWindow.xaml.cs プロジェクト: JFarlette/Hopper
 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
 }