Exemplo n.º 1
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();
            }
        }
    }
    public void OverwriteProfile()
    {
        GameManager     instance = FindObjectOfType <GameManager>();
        ProfileCopier   copier   = FindObjectOfType <ProfileCopier>();
        ProfileSaver    saver    = FindObjectOfType <ProfileSaver>();
        ProfileSetter   setter   = FindObjectOfType <ProfileSetter>();
        ProfileMessager messager = FindObjectOfType <ProfileMessager>();

        Profile saveProfile = copier.CopyProfile(setter.CurrentProfile);

        instance.Profiles[saver.profileToLoad] = saveProfile;
        instance.SaveProfiles();

        ui.Close(ProfileUI.CloseType.nameCheckSave);
    }
    public void LoadProfile()
    {
        Debug.Log("Attempting to Load the original profile.");

        GameManager     instance = FindObjectOfType <GameManager>();
        ProfileSaver    saver    = FindObjectOfType <ProfileSaver>();
        ProfileCopier   copier   = FindObjectOfType <ProfileCopier>();
        ProfileLoader   loader   = FindObjectOfType <ProfileLoader>();
        ProfileSetter   setter   = FindObjectOfType <ProfileSetter>();
        ProfileMessager messager = FindObjectOfType <ProfileMessager>();

        Debug.Log("Loading profile named " + instance.Profiles[saver.profileToLoad].Name + ".");
        setter.CurrentProfile = copier.CopyProfile(instance.Profiles[saver.profileToLoad]);

        loader.LoadProfile(setter.CurrentProfile);

        ui.Close(ProfileUI.CloseType.nameCheckLoad);
    }
Exemplo n.º 4
0
    public void LoadProfile(Profile profile)
    {
        Debug.Log("Attempting to Load the original profile.");

        ProfileCopier   copier   = FindObjectOfType <ProfileCopier>();
        ProfileSetter   setter   = FindObjectOfType <ProfileSetter>();
        ProfileUI       UI       = FindObjectOfType <ProfileUI>();
        ProfileMessager messager = FindObjectOfType <ProfileMessager>();

        Debug.Log("Loading profile named " + profile.Name + ".");

        for (int i = 0; i <= setter.CurrentProfile.DamageCharts; i++)
        {
            Debug.Log("MinM" + i + ": " + setter.CurrentProfile.MinMove[i] +
                      " M" + i + ": " + setter.CurrentProfile.Move[i] +
                      " WS" + i + ": " + setter.CurrentProfile.WeaponSkill[i] +
                      " BS" + i + ": " + setter.CurrentProfile.BallisticSkill[i] +
                      " S" + i + ": " + setter.CurrentProfile.Strength[i] +
                      " T" + i + ": " + setter.CurrentProfile.Toughness[i] +
                      " W" + i + ": " + setter.CurrentProfile.Wounds[i] +
                      " A" + i + ": " + setter.CurrentProfile.Attacks[i] +
                      " Ld" + i + ": " + setter.CurrentProfile.Leadership[i] +
                      " Sv" + i + ": " + setter.CurrentProfile.Save[i]);
        }

        Debug.Log("Setting Damage Profiles to " + setter.CurrentProfile.DamageCharts + ".");
        UI.dropdownDamage.value = setter.CurrentProfile.DamageCharts;

        Debug.Log("Loading the current profile into the UI.");
        if (setter.CurrentProfile.DamageCharts == 0)
        {
            UI.ReadProfile();
        }
        else
        {
            UI.CreateDamageProfiles();
        }

        StartCoroutine(messager.DisplayTemporaryMessage(setter.CurrentProfile.Name + " loaded.", false));
    }
Exemplo n.º 5
0
    public bool CheckFullProfile()
    {
        Debug.Log("Profile Saver has called Profile Checker for the current Profile");
        ProfileMessager message   = FindObjectOfType <ProfileMessager>();
        ProfileUI       profileUI = FindObjectOfType <ProfileUI>();
        Profile         profile   = FindObjectOfType <ProfileSetter>().CurrentProfile;

        //int nTemp;

        Debug.Log("Profile Checker is checking Name in Profile");
        Debug.Log("Current profile Name is " + profile.Name);
        if (profile.Name.Length == 0)
        {
            profileUI.OutputProfileError("Input Name", 0);
            Debug.Log("Value of Name is not legal.");
            message.DisplayMessage("Please enter the model's name.", true);
            return(false);
        }
        //nTemp = 100;
        for (int i = 0; i <= profile.DamageCharts; i++)
        {
            Debug.Log("Current Move is " + profile.MinMove[i]);
            if (profile.MinMove[i] < 0)
            {
                profileUI.OutputProfileError("Input MinM" + i, i);
                Debug.Log("Value of MinM" + i + " is not legal.");
                message.DisplayMessage("The profile may not have a negative Minimum Move.", true);
                return(false);
            }
            if (profile.MinMove[i] > profile.Move[i])
            {
                profileUI.OutputProfileError("Input MinM" + i, i);
                Debug.Log("Value of MinM" + i + " is not legal.");
                message.DisplayMessage("The profile may not have a negative Minimum Move greater than its Move.", true);
                return(false);
            }
        }
        CheckForWarnings(profile, "MinM0");
        for (int i = 0; i <= profile.DamageCharts; i++)
        {
            Debug.Log("Current Move is " + profile.Move[i]);
            if (profile.Move[i] < 0)
            {
                profileUI.OutputProfileError("Input M" + i, i);
                Debug.Log("Value of M" + i + " is not legal.");
                message.DisplayMessage("The profile may not have a negative Move.", true);
                return(false);
            }
            //if (nTemp < profile.Move[i]) {
            //    Debug.Log("Warning: Value of M" + i + " is greater than value of M" + (i-1));
            //    message.CurrentState = ProfileMessager.State.warning;
            //    message.MWarning = true;
            //    message.ReturnToCurrentState();
            //}
            //nTemp = profile.Move[i];
        }
        CheckForWarnings(profile, "M0");
        //nTemp = 0;
        for (int i = 0; i <= profile.DamageCharts; i++)
        {
            Debug.Log("Current Weapon Skill is " + profile.WeaponSkill[i]);
            if (0 > profile.WeaponSkill[i] || profile.WeaponSkill[i] > 7)
            {
                profileUI.OutputProfileError("Input WS" + i, i);
                message.DisplayMessage("The profile must have a Weapon Skill between 0 and 6.", true);
                Debug.Log("Value of WS" + i + " is not legal.");
                return(false);
            }
            //if (nTemp > profile.WeaponSkill[i]) {
            //    message.CurrentState = ProfileMessager.State.warning;
            //    message.WSWarning = true;
            //    message.ReturnToCurrentState();
            //    Debug.Log("Warning: Value of WS" + i + " is better than value of WS" + (i-1));
            //}
            //nTemp = profile.WeaponSkill[i];
        }
        CheckForWarnings(profile, "WS0");
        //nTemp = 0;
        for (int i = 0; i <= profile.DamageCharts; i++)
        {
            Debug.Log("Current Ballistic Skill is " + profile.BallisticSkill[i]);
            if (0 > profile.BallisticSkill[i] || profile.BallisticSkill[i] > 7)
            {
                profileUI.OutputProfileError("Input BS" + i, i);
                message.DisplayMessage("The profile must have a Ballistic Skill between 0 and 6.", true);
                Debug.Log("Value of BS" + i + " is not legal.");
                return(false);
            }
            //if (nTemp > profile.BallisticSkill[i]) {
            //    message.CurrentState = ProfileMessager.State.warning;
            //    message.BSWarning = true;
            //    message.ReturnToCurrentState();
            //    Debug.Log("Warning: Value of BS" + i + " is better than value of BS" + (i-1));
            //}
            //nTemp = profile.BallisticSkill[i];
            CheckForWarnings(profile, "BS0");
        }
        //nTemp = 100;
        for (int i = 0; i <= profile.DamageCharts; i++)
        {
            Debug.Log("Current Strength is " + profile.Strength[i]);
            if (profile.Strength[i] < 0)
            {
                profileUI.OutputProfileError("Input S" + i, i);
                message.DisplayMessage("The profile may not have a negative Strength.", true);
                Debug.Log("Value of S" + i + " is not legal.");
                return(false);
            }
            //if (nTemp < profile.Strength[i]) {
            //    message.CurrentState = ProfileMessager.State.warning;
            //    message.SWarning = true;
            //    message.ReturnToCurrentState();
            //    Debug.Log("Warning: Value of S" + i + " is greater than value of S" + (i-1));
            //}
            //nTemp = profile.Strength[i];
        }
        CheckForWarnings(profile, "S0");
        //nTemp = 20;
        for (int i = 0; i <= profile.DamageCharts; i++)
        {
            Debug.Log("Current Toughness is " + profile.Toughness[i]);
            if (profile.Toughness[i] < 1)
            {
                profileUI.OutputProfileError("Input T" + i, i);
                message.DisplayMessage("The profile must have a non zero Toughness.", true);
                Debug.Log("Value of T" + i + " is not legal.");
                return(false);
            }
            //if (nTemp < profile.Toughness[i]) {
            //    message.CurrentState = ProfileMessager.State.warning;
            //    message.TWarning = true;
            //    message.ReturnToCurrentState();
            //    Debug.Log("Warning: Value of T" + i + " is better than value of T" + (i-1));
            //}
            //nTemp = profile.Toughness[i];
        }
        CheckForWarnings(profile, "T0");
        //nTemp = 100;
        for (int i = 0; i <= profile.DamageCharts; i++)
        {
            Debug.Log("Current Wounds is " + profile.Wounds[i]);
            if (profile.Wounds[i] < 1)
            {
                profileUI.OutputProfileError("Input W" + i, i);
                message.DisplayMessage("The profile may not have zero Wounds.", true);
                Debug.Log("Value of W" + i + " is not legal.");
                return(false);
            }
            //if (nTemp <= profile.Wounds[i]) {
            //    message.DisplayMessage("Wounds must decrease with each damage chart.", true);
            //    Debug.Log("Value of W must decrease at each damage level.");
            //    return false;
            //}
            //nTemp = profile.Wounds[i];
        }
        bool error = CheckForWarnings(profile, "W0");

        if (error)
        {
            return(false);
        }
        //nTemp = 20;
        for (int i = 0; i <= profile.DamageCharts; i++)
        {
            Debug.Log("Current Attacks is " + profile.Attacks[i]);
            if (profile.Attacks[i] < 0)
            {
                profileUI.OutputProfileError("Input A" + i, i);
                message.DisplayMessage("The profile may not have a negative number of Attacks.", true);
                Debug.Log("Value of A" + i + " is not legal.");
                return(false);
            }
            //if (nTemp < profile.Attacks[i]) {
            //    message.CurrentState = ProfileMessager.State.warning;
            //    message.AWarning = true;
            //    message.ReturnToCurrentState();
            //    Debug.Log("Warning: Value of A" + i + " is greater than value of A" + (i-1));
            //}
            //nTemp = profile.Attacks[i];
        }
        CheckForWarnings(profile, "A0");
        //nTemp = 20;
        for (int i = 0; i <= profile.DamageCharts; i++)
        {
            Debug.Log("Current Leadership is " + profile.Leadership[i]);
            if (profile.Leadership[i] < 0)
            {
                profileUI.OutputProfileError("Input Ld" + i, i);
                message.DisplayMessage("The profile may not have a negative Leadership.", true);
                Debug.Log("Value of Ld" + i + " is not legal.");
                return(false);
            }
            //if (nTemp < profile.Leadership[i]) {
            //    message.CurrentState = ProfileMessager.State.warning;
            //    message.LdWarning = true;
            //    message.ReturnToCurrentState();
            //    Debug.Log("Warning: Value of Ld" + i + " is greater than value of Ld" + (i-1));
            //}
            //nTemp = profile.Leadership[i];
        }
        CheckForWarnings(profile, "Ld0");
        //nTemp = 0;
        for (int i = 0; i <= profile.DamageCharts; i++)
        {
            Debug.Log("Current Save is " + profile.Save[i]);
            if (0 > profile.Save[i] || profile.Save[i] > 7)
            {
                profileUI.OutputProfileError("Input Sv" + i, i);
                message.DisplayMessage("The profile must have a Save between 0 and 6.", true);
                Debug.Log("Value of Sv" + i + " is not legal.");
                return(false);
            }
            //if (nTemp > profile.Save[i]) {
            //    message.CurrentState = ProfileMessager.State.warning;
            //    message.SvWarning = true;
            //    message.ReturnToCurrentState();
            //    Debug.Log("Warning: Value of Sv" + (i) + " is better than value of Sv" + (i-1));
            //}
            //nTemp = profile.Save[i];
        }
        CheckForWarnings(profile, "Sv0");
        //Debug
        //for (int i = 0; i < profile.Toughness.Count; i++) {
        //    Debug.Log("T" + i + ": " + profile.Toughness[i]);
        //}

        return(true);
    }
Exemplo n.º 6
0
    public void CheckValue(string value)
    {
        ProfileMessager message   = FindObjectOfType <ProfileMessager>();
        ProfileUI       profileUI = GetComponent <ProfileUI>();

        if (profileName == "Name")
        {
            Debug.Log("Checking profile Name from Profile Value Checker.");

            if (value.Length > 0)
            {
                Debug.Log("Saving Name, " + value + ", to Profile.");
                profileUI.SetColor(profileName, true);
                setter.SetProfile(profileName, value);
                message.ReturnToCurrentState();
            }
            else
            {
                profileUI.SetColor(profileName, false);
                message.DisplayMessage("Value of " + profileName + " is not legal.", true);
                Debug.Log("Value of " + profileName + " is not legal.");
            }
        }
        else
        {
            int  nValue      = ReadIntString(value);
            bool valueChecks = false;

            Debug.Log("Profile Value Checker is checking a numeric Profile: " + profileName);
            switch (profileName)
            {
            case "MinM0":
            case "MinM1":
            case "MinM2":
            case "MinM3":
            case "MinM4":
            case "M0":
            case "M1":
            case "M2":
            case "M3":
            case "M4":
            case "S0":
            case "S1":
            case "S2":
            case "S3":
            case "S4":
            case "A0":
            case "A1":
            case "A2":
            case "A3":
            case "A4":
            case "Ld0":
            case "Ld1":
            case "Ld2":
            case "Ld3":
            case "Ld4":
                valueChecks = (nValue >= 0);
                break;

            case "T0":
            case "T1":
            case "T2":
            case "T3":
            case "T4":
            case "W0":
            case "W1":
            case "W2":
            case "W3":
            case "W4":
                valueChecks = (nValue > 0);
                break;

            case "WS0":
            case "WS1":
            case "WS2":
            case "WS3":
            case "WS4":
            case "BS0":
            case "BS1":
            case "BS2":
            case "BS3":
            case "BS4":
            case "Sv0":
            case "Sv1":
            case "Sv2":
            case "Sv3":
            case "Sv4":
                valueChecks = (0 <= nValue && nValue <= 7);
                break;

            default:
                break;
            }

            if (valueChecks)
            {
                Debug.Log("Profile Value Checker is saving a numeric profile to Profile: " + profileName);
                profileUI.SetColor(profileName, valueChecks);
                setter.SetProfile(profileName, nValue);
                CheckForWarnings(setter.CurrentProfile, profileName);
            }
            else
            {
                profileUI.SetColor(profileName, valueChecks);
                message.DisplayMessage("Value of " + profileName + " is not legal.", true);
                Debug.Log("Value of " + profileName + " is not legal.");
            }
        }
    }
Exemplo n.º 7
0
    bool CheckForWarnings(Profile profile, string profileName)
    {
        bool error = false;

        Debug.Log("Profile Value Checker is checking for warnings.");

        if (profileName == "Name" || profile.DamageCharts <= 0)
        {
            Debug.Log("Profile being checked can not create a warning.");
        }
        else
        {
            ProfileMessager message = FindObjectOfType <ProfileMessager>();
            int[]           copiedStats;

            switch (profileName)
            {
            case "MinM0":
            case "MinM1":
            case "MinM2":
            case "MinM3":
            case "MinM4":

                Debug.Log("Profile Value Checker is checking Move for warnings.");
                copiedStats = CopiedStats(profile.MinMove, profile.DamageCharts);
                if (CheckValueSeriesWarning(copiedStats, StatType.basic))
                {
                    Debug.Log("Calling a warning.");

                    message.MinMWarning = true;
                    message.SetWarning();
                }
                else
                {
                    Debug.Log("Updating warnings.");

                    message.MinMWarning = false;
                    message.ReturnToCurrentState();
                }
                break;

            case "M0":
            case "M1":
            case "M2":
            case "M3":
            case "M4":

                Debug.Log("Profile Value Checker is checking Move for warnings.");
                copiedStats = CopiedStats(profile.Move, profile.DamageCharts);
                if (CheckValueSeriesWarning(copiedStats, StatType.basic))
                {
                    Debug.Log("Calling a warning.");

                    message.MWarning = true;
                    message.SetWarning();
                }
                else
                {
                    Debug.Log("Updating warnings.");

                    message.MWarning = false;
                    message.ReturnToCurrentState();
                }
                break;

            case "WS0":
            case "WS1":
            case "WS2":
            case "WS3":
            case "WS4":

                Debug.Log("Profile Value Checker is checking Weapon Skill for warnings.");
                copiedStats = CopiedStats(profile.WeaponSkill, profile.DamageCharts);
                if (CheckValueSeriesWarning(copiedStats, StatType.dice))
                {
                    Debug.Log("Calling a warning.");

                    message.WSWarning = true;
                    message.SetWarning();
                }
                else
                {
                    Debug.Log("Updating warnings.");

                    message.WSWarning = false;
                    message.ReturnToCurrentState();
                }
                break;

            case "BS0":
            case "BS1":
            case "BS2":
            case "BS3":
            case "BS4":

                Debug.Log("Profile Value Checker is checking Ballistic Skill for warnings.");
                copiedStats = CopiedStats(profile.BallisticSkill, profile.DamageCharts);
                if (CheckValueSeriesWarning(copiedStats, StatType.dice))
                {
                    Debug.Log("Calling a warning.");

                    message.BSWarning = true;
                    message.SetWarning();
                }
                else
                {
                    Debug.Log("Updating warnings.");

                    message.BSWarning = false;
                    message.ReturnToCurrentState();
                }
                break;

            case "S0":
            case "S1":
            case "S2":
            case "S3":
            case "S4":

                Debug.Log("Profile Value Checker is checking Strength for warnings.");
                copiedStats = CopiedStats(profile.Strength, profile.DamageCharts);
                if (CheckValueSeriesWarning(copiedStats, StatType.basic))
                {
                    Debug.Log("Calling a warning.");

                    message.SWarning = true;
                    message.SetWarning();
                }
                else
                {
                    Debug.Log("Updating warnings.");

                    message.SWarning = false;
                    message.ReturnToCurrentState();
                }
                break;

            case "T0":
            case "T1":
            case "T2":
            case "T3":
            case "T4":

                Debug.Log("Profile Value Checker is checking Toughness for warnings.");
                copiedStats = CopiedStats(profile.Toughness, profile.DamageCharts);
                if (CheckValueSeriesWarning(copiedStats, StatType.basic))
                {
                    Debug.Log("Calling a warning.");

                    message.TWarning = true;
                    message.SetWarning();
                }
                else
                {
                    Debug.Log("Updating warnings.");

                    message.TWarning = false;
                    message.ReturnToCurrentState();
                }
                break;

            case "W0":
            case "W1":
            case "W2":
            case "W3":
            case "W4":

                Debug.Log("Profile Value Checker is checking Wounds for warnings.");
                copiedStats = CopiedStats(profile.Wounds, profile.DamageCharts);
                if (CheckValueSeriesWarning(copiedStats, StatType.wounds))
                {
                    Debug.Log("Calling an error.");

                    message.DisplayMessage("Wounds must decrease with each damage chart.", true);
                    error = true;
                    return(error);
                }
                else
                {
                    Debug.Log("Updating warnings.");

                    message.ReturnToCurrentState();
                }
                break;

            case "A0":
            case "A1":
            case "A2":
            case "A3":
            case "A4":

                Debug.Log("Profile Value Checker is checking Attacks for warnings.");
                copiedStats = CopiedStats(profile.Attacks, profile.DamageCharts);
                if (CheckValueSeriesWarning(copiedStats, StatType.basic))
                {
                    Debug.Log("Calling a warning.");

                    message.AWarning = true;
                    message.SetWarning();
                }
                else
                {
                    Debug.Log("Updating warnings.");

                    message.AWarning = false;
                    message.ReturnToCurrentState();
                }
                break;

            case "Ld0":
            case "Ld1":
            case "Ld2":
            case "Ld3":
            case "Ld4":

                Debug.Log("Profile Value Checker is checking Leadership for warnings.");
                copiedStats = CopiedStats(profile.Leadership, profile.DamageCharts);
                if (CheckValueSeriesWarning(copiedStats, StatType.basic))
                {
                    Debug.Log("Calling a warning.");

                    message.LdWarning = true;
                    message.SetWarning();
                }
                else
                {
                    Debug.Log("Updating warnings.");

                    message.LdWarning = false;
                    message.ReturnToCurrentState();
                }
                break;

            case "Sv0":
            case "Sv1":
            case "Sv2":
            case "Sv3":
            case "Sv4":

                Debug.Log("Profile Value Checker is checking Save for warnings.");
                copiedStats = CopiedStats(profile.Save, profile.DamageCharts);
                if (CheckValueSeriesWarning(copiedStats, StatType.dice))
                {
                    Debug.Log("Calling a warning.");

                    message.SvWarning = true;
                    message.SetWarning();
                }
                else
                {
                    Debug.Log("Updating warnings.");

                    message.SvWarning = false;
                    message.ReturnToCurrentState();
                }
                break;

            default:
                break;
            }
        }
        return(error);
    }