예제 #1
0
        // When the Profiles Manager loads it sets it's values and it loads the profiles
        public async void Start()
        {
            SaveManagerEvents.current.OnProfileSaved      += OnProfileSaved;
            SaveManagerEvents.current.OnProfileDeleted    += OnProfileDeleted;
            SaveManagerEvents.current.OnProfileEdited     += OnProfileEdited;
            SaveManagerEvents.current.OnCreateProfile     += OnCreateProfile;
            SaveManagerEvents.current.OnAllProfilesSaved  += OnAllProfilesSaved;
            SaveManagerEvents.current.OnAllProfilesLoaded += OnAllProfilesLoaded;
            SaveManagerEvents.current.OnProfileLoaded     += OnProfileLoaded;

            //Sets the main path value for Profiles
            mainDirectoryPath = Path.Combine(Application.persistentDataPath, "Profiles");

            //Sets the profiles.dat path value
            profilesPath = mainDirectoryPath + "/profiles.dat";

            // Checks if the Profiles Folder Exists or not. If it doesn't exist it creates it.
            if (!Directory.Exists(mainDirectoryPath))
            {
                FileManagerExtension.CreateDirectory(mainDirectoryPath);
            }

            // Loads the event
            FileSystemEventsManager.FileSystemEvents(mainDirectoryPath);

            //Gets all Directories in the Profiles folder
            string[] profiles = FileManagerExtension.GetDirectories(mainDirectoryPath);

            // Shows the Create profile UI if player doesn't have any profiles
            if (!profiles.Any())
            {
                FirstTimePlaying();
                await SaveManager.SaveAllProfilesAsync(profilesPath);

                return;
            }

            await SaveManager.LoadAllProfilesAsync(profilesPath);

            for (int i = 0; i < profiles.Length; i++)
            {
                await LoadProfile(profiles.GetValue(i).ToString());
            }
        }