void Update() { //used for building dictionary. not sure why it only will work once per run of program. //has an exception around file sharing/permissions, but writes and reads the files anyway. if (Input.anyKeyDown) { string keyPressed = Input.inputString; //get key pressed print("I THINK I'M WORKING!"); if (keyPressed == "p") { UpdateText("Challenge:\n Spell BED"); ChallengeActive = true; signSoFar = ""; } else { Frame framey = cont.Frame(); if (framey.CurrentFramesPerSecond > 0 && framey.Hands.Count > 0) //if in a valid frame { Hand whyDoesThisNotWork = framey.Hands[0]; //but it does work now! string filename = saveTheStuffs(whyDoesThisNotWork, (keyPressed + "Reference.txt")); //save file based on key pressed. signTemplate testymctestface = readTheStuffs(filename); //read back the file print(compareHands(testymctestface.data, whyDoesThisNotWork)); if (compareHands(testymctestface.data, whyDoesThisNotWork) > 0.01) { throw new InvalidOperationException("Hand written and hand read don't match"); } } else { print("no hands"); } } } if (ChallengeActive) { if (signSoFar.Contains("bed")) { UpdateText("Challenge Complete"); bed.SetActive(true); //ChallengeActive = false; } } return; }
List <signTemplate> baseHands; //list of possible signs currently defined // Use this for initialization void Start() { lsp = new LeapServiceProvider(); baseHands = new List <signTemplate>(); cont = lsp.GetLeapController(); cont.FrameReady += handleFrameReady; //add listener that notifies if there's a valid tracking frame //bed.SetActive(false); /*generate the signing dictionary*/ baseHand = readTheStuffs("OpenPalmReference.txt"); baseHands.Add(baseHand); baseHand = readTheStuffs("aReference.txt"); baseHands.Add(baseHand); baseHand = readTheStuffs("bReference.txt"); baseHands.Add(baseHand); baseHand = readTheStuffs("cReference.txt"); baseHands.Add(baseHand); baseHand = readTheStuffs("dReference.txt"); baseHand.precision = 11.5; baseHands.Add(baseHand); baseHand = readTheStuffs("eReference.txt"); baseHands.Add(baseHand); baseHand = readTheStuffs("fReference.txt"); baseHand.precision = 13; baseHands.Add(baseHand); baseHand = readTheStuffs("gReference.txt"); baseHands.Add(baseHand); //baseHand = readTheStuffs("hReference.txt"); //baseHands.Add(baseHand); //baseHand = readTheStuffs("iReference.txt"); //baseHands.Add(baseHand); //baseHand = readTheStuffs("tReference.txt"); //baseHands.Add(baseHand); //baseHand = readTheStuffs("mReference.txt"); //baseHands.Add(baseHand); //baseHand = readTheStuffs("nReference.txt"); //baseHands.Add(baseHand); }