Advertisement
gotoheavenbro

GameSettings

Sep 29th, 2014
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.52 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System;
  4. public class GameSettings : MonoBehaviour {
  5.     void Awake()
  6.     {
  7.         DontDestroyOnLoad(this);
  8.     }
  9.     // Use this for initialization
  10.     void Start () {
  11.    
  12.     }
  13.    
  14.     // Update is called once per frame
  15.     void Update () {
  16.    
  17.     }
  18.     public void SaveCharacterData()
  19.     {
  20.         GameObject pc = GameObject.Find("pc");
  21.         PlayerCharacter pcClass = pc.GetComponent<PlayerCharacter>();
  22.        
  23.         PlayerPrefs.DeleteAll();
  24.  
  25.         PlayerPrefs.SetString("Player Name", pcClass.Name);
  26.         for (int i = 0; i < Enum.GetValues(typeof(AttributeName)).Length; i++)
  27.         {
  28.             PlayerPrefs.SetInt(((AttributeName)i).ToString() + " - Base Value",(pcClass.GetPrimaryAttribute(i).BaseValue));
  29.             PlayerPrefs.SetInt(((AttributeName)i).ToString() + " - Next Level", (pcClass.GetPrimaryAttribute(i).NextLevel));
  30.         }
  31.         for (int i = 0; i < Enum.GetValues(typeof(VitalName)).Length; i++)
  32.         {
  33.             PlayerPrefs.SetInt(((VitalName)i).ToString() + " - Base Value", (pcClass.GetVital(i).BaseValue));
  34.             PlayerPrefs.SetInt(((VitalName)i).ToString() + " - Next Level", (pcClass.GetVital(i).NextLevel));
  35.            
  36.             PlayerPrefs.SetInt(((VitalName)i).ToString() + " - Current Value", (pcClass.GetVital(i).CurValue));
  37.             PlayerPrefs.SetString(((VitalName)i).ToString()+"- Mods", pcClass.GetVital(i).GetModifyingAttributesString());
  38.            
  39.         }
  40.         for (int i = 0; i < Enum.GetValues(typeof(SkillName)).Length; i++)
  41.         {
  42.             PlayerPrefs.SetInt(((SkillName)i).ToString() + " - Base Value", (pcClass.GetSkill(i).BaseValue));
  43.             PlayerPrefs.SetInt(((SkillName)i).ToString() + " - Next Level", (pcClass.GetSkill(i).NextLevel));
  44.             PlayerPrefs.SetString(((SkillName)i).ToString()+" - Mods",pcClass.GetSkill(i).GetModifyingAttributesString());
  45.            
  46.         }
  47.     }
  48.     public void LoadCharacterData()
  49.     {
  50.         GameObject pc = GameObject.Find("pc");
  51.         PlayerCharacter pcClass = pc.GetComponent<PlayerCharacter>();
  52.  
  53.  
  54.         pcClass.Name=PlayerPrefs.GetString("Player Name");
  55.         Debug.Log(pcClass.Name);
  56.         for (int i = 0; i < Enum.GetValues(typeof(AttributeName)).Length; i++)
  57.         {
  58.             pcClass.GetPrimaryAttribute(i).BaseValue=PlayerPrefs.GetInt(((AttributeName)i).ToString() + " - Base Value" );
  59.             pcClass.GetPrimaryAttribute(i).NextLevel= PlayerPrefs.GetInt(((AttributeName)i).ToString() + " - Next Level");
  60.         }
  61.         for (int i = 0; i < Enum.GetValues(typeof(VitalName)).Length; i++)
  62.         {
  63.             pcClass.GetVital(i).BaseValue = PlayerPrefs.GetInt(((VitalName)i).ToString() + " - Base Value");
  64.             pcClass.GetVital(i).NextLevel = PlayerPrefs.GetInt(((VitalName)i).ToString() + " - Next Level");
  65.  
  66.             pcClass.GetVital(i).CurValue = PlayerPrefs.GetInt(((VitalName)i).ToString() + " - Current Value");
  67.             PlayerPrefs.GetString(((VitalName)i).ToString() + "- Mods", pcClass.GetVital(i).GetModifyingAttributesString());
  68.  
  69.         }
  70.         for (int i = 0; i < Enum.GetValues(typeof(SkillName)).Length; i++)
  71.         {
  72.             PlayerPrefs.GetInt(((SkillName)i).ToString() + " - Base Value", (pcClass.GetSkill(i).BaseValue));
  73.             PlayerPrefs.GetInt(((SkillName)i).ToString() + " - Next Level", (pcClass.GetSkill(i).NextLevel));
  74.             PlayerPrefs.GetString(((SkillName)i).ToString() + " - Mods", pcClass.GetSkill(i).GetModifyingAttributesString());
  75.  
  76.         }
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement