static Queue <Target> LoadSequence(int sequenceNumber) { Queue <Target> targets = new Queue <Target>(); using (StreamReader sr = new StreamReader("sequences/" + sequenceNumber + "_sequence.txt")) { string line = ""; while ((line = sr.ReadLine()) != null) { if (line == "") { break; } string[] targetInfo = line.Split(','); int x = Int32.Parse(targetInfo[0].Trim()); int y = Int32.Parse(targetInfo[1].Trim()); GridSize size = String.Compare(targetInfo[2].Trim(), "L", true) == 0 ? GridSize.Large : GridSize.Small; string tLength = targetInfo[3].Trim(); JumpLength length = JumpLength.Long; switch (tLength) { case "JL": length = JumpLength.Long; break; case "JM": length = JumpLength.Medium; break; case "JS": length = JumpLength.Short; break; default: length = JumpLength.NA; break; } Target t = new Target(x, y, size, length); targets.Enqueue(t); } } return(targets); }
public Target(int x, int y, GridSize size, JumpLength length) { X = x; Y = y; Size = size; Length = length; }
/// <summary> /// Log that target has been hit /// </summary> public void CurrentTargetHit(bool hit, Cell target, Point p, Cell pointer, bool correctShape, JumpLength length) { string result = hit ? "Target: Hit " : "Target: Miss "; string shape = correctShape ? "Shape: Correct " : "Shape: Wrong "; string cells = "TC: (" + target.X.ToString("D2") + "," + target.Y.ToString("D2") + ")" + " CC: (" + pointer.X.ToString("D2") + ", " + pointer.Y.ToString("D2") + ") "; string jLength = "JL: " + length + " "; string pString = "Pointer position: (" + p.X.ToString("F1", System.Globalization.CultureInfo.InvariantCulture) + "," + p.Y.ToString("F1", System.Globalization.CultureInfo.InvariantCulture) + ")."; string message = result + shape + cells + jLength + pString; Log(message); }
public void TargetHit(bool hit, bool correctShape, Cell target, Point pointer, Cell pointerCell, JumpLength length) { if (practiceDone) { Logger.CurrentLogger.CurrentTargetHit(hit, target, pointer, pointerCell, correctShape, length); } if (practiceSequence.Count != 0) { board.CreateTarget(practiceSequence.Dequeue()); return; } else if (!practiceDone) { practiceDone = true; Logger.CurrentLogger.StartNewgestureTest(GestureParser.GetTypeContext(), GestureParser.GetDirectionContext()); board.PracticeDone(); } if (targetSequence.Count != 0) { board.CreateTarget(targetSequence.Dequeue()); } else { board.CurrentGestureDone(); if (gestureTypeList.Count == 0 && done) { Finish(); } else if (gestureTypeList.Count == 0) { if (!firstDirectionRun) { firstDirectionRun = true; } } } }
public void TargetHit(bool hit, bool correctShape, Cell target, Point pointer, Cell pointerCell, JumpLength length) { if(practiceDone) { Logger.CurrentLogger.CurrentTargetHit(hit, target, pointer, pointerCell, correctShape, length); } if (practiceSequence.Count != 0) { board.CreateTarget(practiceSequence.Dequeue()); return; } else if (!practiceDone){ practiceDone = true; Logger.CurrentLogger.StartNewgestureTest(GestureParser.GetTypeContext(), GestureParser.GetDirectionContext()); board.PracticeDone(); } if(targetSequence.Count != 0) { board.CreateTarget(targetSequence.Dequeue()); } else { board.CurrentGestureDone(); if (gestureTypeList.Count == 0 && done) { Finish(); } else if (gestureTypeList.Count == 0) { if(!firstDirectionRun) { firstDirectionRun = true; } } } }
public void DrawNextTargets() { if (runningTest && runningGesture) { if (target == null) { ClearCross(); double size = squareWidth > squareHeight ? squareHeight : squareWidth; string shape = GetNextShape(); if (currentSize != nextTarget.Size) { Logger.CurrentLogger.ChangeSize(nextTarget.Size); } CreateGrid(nextTarget.Size); if (GestureParser.GetDirectionContext() == GestureDirection.Pull) { connection?.SetNextShape(shape); string extraShape = shape == "circle" ? "square" : "circle"; int t = nextTarget.Size == GridSize.Large ? 1 : 2; List <int> xPossibilities = new List <int>(); List <int> yPossibilities = new List <int>(); for (int i = 0; i < gridWidth; i++) { if (i < nextTarget.X - t || i > nextTarget.X + t) { xPossibilities.Add(i); } } for (int i = 0; i < gridHeight; i++) { if (i < nextTarget.Y - t || i > nextTarget.Y + t) { yPossibilities.Add(i); } } int x = xPossibilities[randomizer.Next(xPossibilities.Count)], y = yPossibilities[randomizer.Next(yPossibilities.Count)]; extraTarget = grid[x, y]; extraTarget.GridCell.Fill = targetColor; PushShape(extraShape, extraTarget); extraTarget.Shape.Fill = Brushes.Black; if (accuracyTest) { DrawCross(extraTarget); } } currentLength = nextTarget.Length; target = grid[nextTarget.X, nextTarget.Y]; target.GridCell.Fill = targetColor; PushShape(shape, target); target.Shape.Fill = Brushes.Black; if (accuracyTest) { DrawCross(target); } } } }
/// <summary> /// Log that target has been hit /// </summary> public void CurrentTargetHit(bool hit, Cell target, Point p, Cell pointer, bool correctShape, JumpLength length) { string result = hit ? "Target: Hit " : "Target: Miss "; string shape = correctShape ? "Shape: Correct " : "Shape: Wrong "; string cells = "TC: (" + target.X.ToString("D2") + "," + target.Y.ToString("D2") + ")" + " CC: (" + pointer.X.ToString("D2") + ", " + pointer.Y.ToString("D2") + ") "; string jLength = "JL: " + length + " "; string pString = "Pointer position: (" + p.X.ToString("F1", System.Globalization.CultureInfo.InvariantCulture) +"," + p.Y.ToString("F1", System.Globalization.CultureInfo.InvariantCulture) + ")."; string message = result + shape + cells + jLength + pString; Log(message); }