Example #1
0
 // Use this for initialization
 void Start()
 {
     profileUI = FindObjectOfType <ProfileUI>();
     Assert.IsNotNull(profileUI, "Could not find Profile UI.");
     valueChecker = FindObjectOfType <ProfileValueChecker>();
     Assert.IsNotNull(valueChecker, "Could not find Profile Setter.");
 }
Example #2
0
    public void SaveProfile()
    {
        ProfileValueChecker valueChecker = FindObjectOfType <ProfileValueChecker>();;

        Debug.Log("Profile Saver is attempting to save the current Profile");
        ProfileSetter profileSetter       = FindObjectOfType <ProfileSetter>();
        bool          profileSetCorrectly = valueChecker.CheckFullProfile();

        if (profileSetCorrectly)
        {
            Debug.Log("Profile appears correct, attempting to save.");
            GameManager instance  = FindObjectOfType <GameManager>();;
            ProfileUI   profileUI = FindObjectOfType <ProfileUI>();;
            bool        nameCheck = true;
            for (int i = 0; i < instance.Profiles.Count; i++)
            {
                if (profileSetter.CurrentProfile.Name == instance.Profiles[i].Name)
                {
                    Debug.Log("A profile with the name " + instance.Profiles[i].Name + " has been found.");
                    nameCheck     = false;
                    profileToLoad = i;
                }
            }

            if (nameCheck)
            {
                ProfileMessager messager = FindObjectOfType <ProfileMessager>();
                Debug.Log("The profile is okay to save.");
                //profileSetter.ClearExcessDamageChartEntries();
                Debug.Log("Attempting to add the profile to the profile list.");
                ProfileCopier copier      = FindObjectOfType <ProfileCopier>();
                Profile       saveProfile = copier.CopyProfile(profileSetter.CurrentProfile);
                instance.Profiles.Add(saveProfile);
                instance.SaveProfiles();
                profileUI.EnableLoad();
                StartCoroutine(messager.DisplayTemporaryMessage("Profile Saved.", false));

                //} else if (overwrite) {

                //    instance.Profiles[profileToLoad] = profile;
                //    overwritePanel.SetActive(false);
                //    instance.Save();
            }
            else
            {
                profileUI.OpenNameCheckPanel();
            }
        }
    }