Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System;
- public class GameSettings : MonoBehaviour {
- void Awake()
- {
- DontDestroyOnLoad(this);
- }
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- }
- public void SaveCharacterData()
- {
- GameObject pc = GameObject.Find("pc");
- PlayerCharacter pcClass = pc.GetComponent<PlayerCharacter>();
- PlayerPrefs.DeleteAll();
- PlayerPrefs.SetString("Player Name", pcClass.Name);
- for (int i = 0; i < Enum.GetValues(typeof(AttributeName)).Length; i++)
- {
- PlayerPrefs.SetInt(((AttributeName)i).ToString() + " - Base Value",(pcClass.GetPrimaryAttribute(i).BaseValue));
- PlayerPrefs.SetInt(((AttributeName)i).ToString() + " - Next Level", (pcClass.GetPrimaryAttribute(i).NextLevel));
- }
- for (int i = 0; i < Enum.GetValues(typeof(VitalName)).Length; i++)
- {
- PlayerPrefs.SetInt(((VitalName)i).ToString() + " - Base Value", (pcClass.GetVital(i).BaseValue));
- PlayerPrefs.SetInt(((VitalName)i).ToString() + " - Next Level", (pcClass.GetVital(i).NextLevel));
- PlayerPrefs.SetInt(((VitalName)i).ToString() + " - Current Value", (pcClass.GetVital(i).CurValue));
- PlayerPrefs.SetString(((VitalName)i).ToString()+"- Mods", pcClass.GetVital(i).GetModifyingAttributesString());
- }
- for (int i = 0; i < Enum.GetValues(typeof(SkillName)).Length; i++)
- {
- PlayerPrefs.SetInt(((SkillName)i).ToString() + " - Base Value", (pcClass.GetSkill(i).BaseValue));
- PlayerPrefs.SetInt(((SkillName)i).ToString() + " - Next Level", (pcClass.GetSkill(i).NextLevel));
- PlayerPrefs.SetString(((SkillName)i).ToString()+" - Mods",pcClass.GetSkill(i).GetModifyingAttributesString());
- }
- }
- public void LoadCharacterData()
- {
- GameObject pc = GameObject.Find("pc");
- PlayerCharacter pcClass = pc.GetComponent<PlayerCharacter>();
- pcClass.Name=PlayerPrefs.GetString("Player Name");
- Debug.Log(pcClass.Name);
- for (int i = 0; i < Enum.GetValues(typeof(AttributeName)).Length; i++)
- {
- pcClass.GetPrimaryAttribute(i).BaseValue=PlayerPrefs.GetInt(((AttributeName)i).ToString() + " - Base Value" );
- pcClass.GetPrimaryAttribute(i).NextLevel= PlayerPrefs.GetInt(((AttributeName)i).ToString() + " - Next Level");
- }
- for (int i = 0; i < Enum.GetValues(typeof(VitalName)).Length; i++)
- {
- pcClass.GetVital(i).BaseValue = PlayerPrefs.GetInt(((VitalName)i).ToString() + " - Base Value");
- pcClass.GetVital(i).NextLevel = PlayerPrefs.GetInt(((VitalName)i).ToString() + " - Next Level");
- pcClass.GetVital(i).CurValue = PlayerPrefs.GetInt(((VitalName)i).ToString() + " - Current Value");
- PlayerPrefs.GetString(((VitalName)i).ToString() + "- Mods", pcClass.GetVital(i).GetModifyingAttributesString());
- }
- for (int i = 0; i < Enum.GetValues(typeof(SkillName)).Length; i++)
- {
- PlayerPrefs.GetInt(((SkillName)i).ToString() + " - Base Value", (pcClass.GetSkill(i).BaseValue));
- PlayerPrefs.GetInt(((SkillName)i).ToString() + " - Next Level", (pcClass.GetSkill(i).NextLevel));
- PlayerPrefs.GetString(((SkillName)i).ToString() + " - Mods", pcClass.GetSkill(i).GetModifyingAttributesString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement