//public static void SetYogaScore(int score) //{ // GetYoga(currentYoga); //} public void Evaluate(Skeleton skeleton) { Yoga yoga = GetYoga(currentYoga); if (yoga == null) { System.Console.WriteLine("No more yogas"); return; } if (yoga.EvaluateYoga(skeleton)) { // Update profile userProfile.SetYogaComplete(currentYoga); userProfile.SetYogaScore(currentYoga, GetYoga(currentYoga).Score); userProfile.SaveProfile(); userProfile.ReadProfile(); // reinitialise score to 0 yoga.Score = 0; // Do necessary UI changes. currentYoga++; } }
public void ReadPositions() { XmlDocument document = new XmlDocument(); try { document.Load(file); } catch (Exception e) { System.Console.WriteLine(e.Message); return; } XmlNode root = document.FirstChild; yogas = new List <Yoga>(); //int id = 0; if (root != null && root.HasChildNodes) { // get all nodes with tag name "Level" foreach (XmlNode yoga in root.ChildNodes) { if (yoga.Name != "Yoga") { continue; } try { Yoga yogaObj = new Yoga(Int32.Parse(yoga.Attributes["id"].Value), yoga.Attributes["name"].Value); foreach (XmlNode position in yoga.ChildNodes) { if (position.Name != "Position") { continue; } Position positionobj = new Position(Int32.Parse(position.Attributes["id"].Value), position.Attributes["name"].Value, Int32.Parse(position.Attributes["score"].Value)); foreach (XmlNode gesture in position.ChildNodes) { if (gesture.Name == "Gesture") { Gestures gestureObj; if (Enum.TryParse(gesture.InnerText, out gestureObj)) { positionobj.AddGesture(gestureObj); } } } yogaObj.AddPosition(positionobj); } yogas.Add(yogaObj); } catch (Exception) { } } } }