Advertisement
Guest User

Untitled

a guest
May 26th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.10 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class SaveManager : MonoBehaviour {
  6.  
  7.     public static SaveManager saveManager { get; set; }
  8.  
  9.     [SerializeField]
  10.     int areaNumber;
  11.     [SerializeField]
  12.     float currentPlayerBloodlust;
  13.  
  14.     private float playerBloodlust;
  15.  
  16.     private void Awake()
  17.     {
  18.         if (saveManager == null)
  19.         {
  20.             saveManager = this;
  21.             DontDestroyOnLoad(gameObject);
  22.         }
  23.         else
  24.         {
  25.             Destroy(gameObject);
  26.         }
  27.     }
  28.  
  29.  
  30.     // Update is called once per frame
  31.     void Update () {
  32.         playerBloodlust = FindObjectOfType<Player>().Sanity;
  33.     }
  34.  
  35.     void SaveGameData()
  36.     {
  37.         PlayerPrefs.SetInt("Area", areaNumber);
  38.         PlayerPrefs.SetFloat("Bloodlust", currentPlayerBloodlust);
  39.     }
  40.  
  41.     void LoadGameData()
  42.     {
  43.         areaNumber = PlayerPrefs.GetInt("Area");
  44.         currentPlayerBloodlust = PlayerPrefs.GetInt("Bloodlust");
  45.     }
  46.  
  47.     void ResetData()
  48.     {
  49.         areaNumber = 1;
  50.         currentPlayerBloodlust = 100;
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement