Esempio n. 1
0
        // moves the shifts the workout to the next exercise
        public void NextExercise()
        {
            // remove component from game components
            _game.Components.Remove(CurrentExercise);

            // complete the exercise
            CompletedExercises.Enqueue(CurrentExercise);

            if (null != CurrentExercise)
            {
                foreach (StartedRepetitionEventHandler evt in RepetitionStartedListener)
                {
                    CurrentExercise.Changed -= evt;
                }
            }

            // grab the next (or first) one and add to game components
            CurrentExercise = PendingExercises.Dequeue();

            // be sure to add any listeners
            foreach (StartedRepetitionEventHandler evt in RepetitionStartedListener)
            {
                CurrentExercise.Changed += evt;
            }

            _game.Components.Add(CurrentExercise);
        }
Esempio n. 2
0
        /// <summary>
        /// When the catalog notifies that the Exercises have been loaded and the patient is ready to exercise,
        /// The exercise queue will load up the exercises pushed into the CurrentCatalog.
        ///
        /// </summary>
        /// <returns></returns>
        public void LoadExercises(object sender, CatalogCompleteEventArg e)
        {
            ReInitialize();
            OnLoadStarted(EventArgs.Empty);
            string path = System.AppDomain.CurrentDomain.BaseDirectory + "../../../../KinectTherapyContent/Exercises/";

            Exercises = new ExerciseGameComponent[e.Exercises.Length];

            //loop through the exercises in the CurrentCatalog and turn them into Exercise objects.
            for (int i = 0; i < e.Exercises.Length; i++)
            {
                XmlSerializer serializer = new XmlSerializer(typeof(Exercise));
                StreamReader  reader     = new StreamReader(path + e.Exercises[i].Id + ".xml");

                // deserialize the xml and create an Exercise
                Exercise temp = (Exercise)serializer.Deserialize(reader);
                temp.Repetitions = e.Exercises[i].Repetitions;
                temp.Variance    = e.Exercises[i].Variance;

                Exercises[i] = new ExerciseGameComponent(_game, temp);
                reader.Close();

                //Queue up for a workout
                PendingExercises.Enqueue(Exercises[i]);
            }
            // once they're all queued start the first exercise.
            NextExercise();
            OnLoadComplete(EventArgs.Empty);
        }
Esempio n. 3
0
        public ExerciseTile(Game game, ExerciseGameComponent exercise, int exerciseIndex, Vector2 size, Vector2 position)
            : base(exercise.Name, size, position)
        {
            this.Title = exercise.Name;
            exercise.repetition.CheckpointChanged += HandleCheckpointChange;

            _oldGameTime = double.MaxValue;
        }
Esempio n. 4
0
        public ExerciseTile(Game game, ExerciseGameComponent exercise, int exerciseIndex, Vector2 size, Vector2 position)
            : base(exercise.Name, size, position)
        {
            this.Title = exercise.Name;
            exercise.repetition.CheckpointChanged += HandleCheckpointChange;

            _oldGameTime = double.MaxValue;
        }
        public void Init()
        {
            //Load test exercise from XML
            XmlSerializer serializer = new XmlSerializer(typeof(Exercise));
            StreamReader reader = new StreamReader(Directory + "EXELAE.xml");
            // deserialize the xml and create an Exercise
            Exercise = (Exercise)serializer.Deserialize(reader);

            testEgc = new ExerciseGameComponent(new Game(), Exercise);
        }
        // moves the shifts the workout to the next exercise
        private void NextExercise()
        {
            if (null != CurrentExercise)
            {
                foreach (StartedRepetitionEventHandler evt in RepetitionStartedListener)
                {
                    CurrentExercise.Changed -= evt;
                }
            }

            // grab the next (or first) one and add to game components
            CurrentExercise = PendingExercises.Dequeue();

            // be sure to add any listeners
            foreach (StartedRepetitionEventHandler evt in RepetitionStartedListener)
            {
                CurrentExercise.Changed += evt;
            }

            _game.Components.Add(CurrentExercise);
        }
        /// <summary>
        /// When the catalog notifies that the Exercises have been loaded and the patient is ready to exercise,
        /// The exercise queue will load up the exercises pushed into the CurrentCatalog. 
        /// 
        /// </summary>
        /// <returns></returns>
        public void LoadExercises(object sender, CatalogCompleteEventArg e)
        {
            ReInitialize();
            OnLoadStarted(EventArgs.Empty);
            string path = System.AppDomain.CurrentDomain.BaseDirectory + "../../../../KinectTherapyContent/Exercises/";

            Exercises = new ExerciseGameComponent[e.Exercises.Length];

             //loop through the exercises in the CurrentCatalog and turn them into Exercise objects.
            for (int i = 0; i < e.Exercises.Length; i++)
            {
                XmlSerializer serializer = new XmlSerializer(typeof(Exercise));
                StreamReader reader = new StreamReader(path + e.Exercises[i].Id + ".xml");
                // deserialize the xml and create an Exercise
                Exercise temp = (Exercise)serializer.Deserialize(reader);
                temp.Repetitions = e.Exercises[i].Repetitions;
                temp.Variance = e.Exercises[i].Variance;

                Exercises[i] = new ExerciseGameComponent(_game, temp);
                reader.Close();

                //Queue up for a workout
                PendingExercises.Enqueue(Exercises[i]);
            }
            // once they're all queued start the first exercise.
            NextExercise();
            OnLoadComplete(EventArgs.Empty);
        }