public PlayerData(int money, string playerName, List <scoreRecord> hs) { this.money = money; this.playerName = playerName; this.highscores = hs; this.PlayerUpgradeData = UpgradeCenter.GetPlayerUpgradeData(); }
void LoadData() { if (File.Exists(Application.persistentDataPath + "/PlayerInfo.panda")) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/PlayerInfo.panda", FileMode.Open); PlayerData data = (PlayerData)bf.Deserialize(file); file.Close(); Debug.Log("Money in LoadData: " + data.money); money = data.money; highscores = data.highscores; playerName = data.playerName; UpgradeCenter.SetPlayerUpgradeData(data.PlayerUpgradeData); } else { AskPlayerName(); } if (highscores == null) { highscores = new List <scoreRecord>(); for (int i = 0; i < numberOfScores; i++) { highscores.Add(new scoreRecord(-5 - 10 * i, "Noob")); } unlocked[0] = true; } }
private void Start() { jumping = GetComponent <AudioSource>(); GM = GameObject.FindWithTag("GameManager").GetComponent <GameManagerEndless>(); _rigidBody = GetComponent <Rigidbody2D>(); Anim = GetComponent <Animator>(); //soundCenter = GetComponent<PlayerSoundController>(); _upgradeCenter = UpgradeCenter.GetInstance(); }