예제 #1
0
    public void ShowWorkouts(WorkoutClassJSON[] workoutClasses, Dictionary <int, WorkoutJSON> workouts)
    {
        for (int i = 0; i < workoutClasses.Length; i++)
        {
            WorkoutJSON workout = workouts[workoutClasses[i].workoutId];

            // workout.MemberwiseClone();
            print(workout.name);
            //fechas[i] = workoutClasses[i].dateStart;
            // 60 width of item
            float spawnY = i * 60;
            //newSpawn Position
            Vector3 pos = new Vector3(0, -spawnY, 0);
            //instantiate item
            GameObject SpawnedItem = Instantiate(item, pos, SpawnPoint.rotation);
            //setParent
            SpawnedItem.transform.SetParent(SpawnPoint, false);
            //get ItemDetails Component
            ClassUiItem classuiItem = SpawnedItem.GetComponent <ClassUiItem>();

            classuiItem.workout = workout;
            //set name
            classuiItem.className.text = workout.name;
            //set hour
            classuiItem.classStart.text = workoutClasses[i].dateStart.TimeOfDay.ToString();
            //set day
            classuiItem.Day.text = workoutClasses[i].dateStart.DayOfWeek.ToString();
        }
        print("ScheduleController.ShowWorkouts Count" + workoutClasses.Length);
    }
        public override async Task <WorkoutJSON[]> GetWorkouts(string user)
        {
            string sJSON = null;

            try
            {
                sJSON = await GetWorkoutsJSON(user);

                WorkoutMessageJSON jojoT         = JsonUtility.FromJson <WorkoutMessageJSON>(sJSON);
                WorkoutJSONW[]     workoutJSONWs = jojoT.workouts;
                WorkoutJSON[]      workouts      = new WorkoutJSON[workoutJSONWs.Length];
                for (int i = 0; i < workoutJSONWs.Length; i++)
                {
                    workouts[i] = new WorkoutJSON(workoutJSONWs[i]);
                }
                return(workouts);
            }
            catch (System.Exception e)
            {
                Debug.Log("Eroror!!! " + e.Message);
                Debug.Log("but wanted " + sJSON);
            }

            return(null);
        }
예제 #3
0
    //public float GetRemainingSegment (int segmentId, ErgData e)
    //{
    //    segments[segmentId].
    //}

    /*
     * async Task TestLoadClass()
     * {
     *  InteroCloud interoCloud = new InteroCloud();
     *
     *  await interoCloud.OAuth("rodrigosavage-at-gmail.com", "rtopdfrtio");
     *
     *  List<WorkoutJSON> workouts = await interoCloud.GetWorkouts("rodrigosavage-at-gmail.com");
     *  WorkoutJSON work = workouts[0];
     *  print("n " + work.name);
     *  foreach (SegmentJSON segmentJSON in work.segments)
     *  {
     *
     *      Segment s = Segment.Factory(segmentJSON);
     *      print("segmentJSON " + segmentJSON);
     *      //print("segmentJSON " + (segmentJSON.type == SegmentType.distance));
     *      print("seg " + s);
     *      segmentManager.Push(s);
     *  }
     * }*/

    public void LoadWorkout(WorkoutJSON work)
    {
        segmentManager.Clear();
        print("Loading " + work);
        if (work == null)
        {
            print("Error Workout is null");
            // return;
        }

        foreach (SegmentJSON segmentJSON in work.segments)
        {
            Segment s = Segment.Factory(segmentJSON);
            segmentManager.Push(s);
        }
    }
예제 #4
0
    public void ShowSelectedWorkout(WorkoutJSON workout)//List<WorkoutJSON> workouts, string workoutId)
    {
        canvas.ShowworkoutSumaryView();
        if (client != null)
        {
            client.StartClient(canvas.GetUsername());
        }
        if (workout == null)
        {
            print("SegmentFiller.ShowSelectedWorkout Nu!!!");
            // return;
        }
        workoutManager.LoadWorkout(workout);

        /*
         *
         * WorkoutJSON workout = null;
         * for (int i=0; i< workouts.Count; i++)
         * {
         *  if(workoutId == workouts[i].id)
         *  {
         *      workout = SingletonWorkouts.instancia.workouts[i];
         *  }
         * }
         */
        CleanMenu(workout.segments.Length);
        print("segments " + workout.segments.Length);
        content.sizeDelta = new Vector2(0, workout.segments.Length * 100);
        string[] strDifficulty = { "recuperación", "medio", "Fuerte!" };
        // Workout
        for (int i = 0; i < workout.segments.Length; i++)
        {
            Segment s = Segment.Factory(workout.segments[i]);
            // Segment segment = new SegmentTime()
            // 60 width of item

            /*
             * float spawnY = i * 95;
             * //newSpawn Position
             * Vector3 pos = new Vector3(0.0f, -spawnY, SpawnPoint.position.z);
             * //instantiate item
             * GameObject SpawnedItem = Instantiate(item, pos, SpawnPoint.rotation);
             * // SpawnedItem.se
             * //setParent
             */
            GameObject SpawnedItem = SpawedItems[i];
            SpawnedItem.transform.SetParent(SpawnPoint, false);
            //get ItemDetails Component
            ClassSegmentUi segmentItem = SpawnedItem.GetComponent <ClassSegmentUi>();
            //set type
            segmentItem.segmentType.text = strDifficulty[(int)s.typeIntensity]; // .type.ToString();
            //set target
            segmentItem.segmentObjective.text = s.getTextObjective();           // workout.segments[i].target.spm.ToString();
            //set duration
            segmentItem.segmentDuration.text = s.getTextRemaining(0);           // workout.segments[i].duration.ToString();
            //set background color
            //no se que valores arroja intensity porque es del tipo SegmentIntensity
            // pero para cambiar el color del fondo seria
            //segmentItem.intensity.color = el color
        }
    }