Пример #1
0
    public void LoadAllWorkouts()
    {
        if (!IsSaveFile())
        {
            return;
        }

        int indexChecker = 0;

        string workoutPath = persistentDataPath + "/workout_" + indexChecker;

        BinaryFormatter bf = new BinaryFormatter();

        while (Directory.Exists(workoutPath))
        {
            string[]  files          = Directory.GetFiles(workoutPath);
            WorkoutSO savedWorkoutSo = ScriptableObject.CreateInstance <WorkoutSO>();

            foreach (var foundFile in files)
            {
                FileStream file = File.Open(foundFile, FileMode.Open);
                JsonUtility.FromJsonOverwrite((string)bf.Deserialize(file), savedWorkoutSo);
                file.Close();
            }

            savedWorkoutSo._components.Clear();

            string[] componentDirectoryPaths = Directory.GetDirectories(workoutPath);

            foreach (var foundComponentDirectoryPath in componentDirectoryPaths)
            {
                string[] componentFiles = Directory.GetFiles(foundComponentDirectoryPath);

                foreach (var component in componentFiles)
                {
                    WorkoutComponentSO savedWorkoutComponentSo = ScriptableObject.CreateInstance <WorkoutComponentSO>();
                    FileStream         file = File.Open(component, FileMode.Open);
                    JsonUtility.FromJsonOverwrite((string)bf.Deserialize(file), savedWorkoutComponentSo);
                    file.Close();

                    savedWorkoutSo._components.Add(savedWorkoutComponentSo);
                }
            }

            WorkoutList.instance.workouts.Add(savedWorkoutSo);
            indexChecker++;
            workoutPath = persistentDataPath + "/workout_" + indexChecker;
        }
    }
    void SaveWorkoutComponent(WorkoutComponentPackage package)
    {
        WorkoutComponentSO newComponentSo = WorkoutComponentSO.CreateInstance(package);

        CurrentWorkoutSo._components.Add(newComponentSo);
    }
Пример #3
0
    void ChangeSetDisplayInformation(WorkoutComponentSO newComponent, int setCount)
    {
        string setIdicatorText = string.Format("Set: {0} of {1}", setCount, newComponent._setNumber);

        _componentSetIndicator.text = setIdicatorText;
    }
Пример #4
0
 /// <summary>
 /// Update UI elements to display the information of the new workout component that started
 /// </summary>
 /// <param name="newComponent">The new workout component that just started</param>
 void ChangeBasicDisplayInformation(WorkoutComponentSO newComponent)
 {
     _componentName.text    = newComponent._name;
     _componentSubname.text = newComponent._subName;
 }