private void SaveHiScore() { if (File.Exists(Application.persistentDataPath + "/playerInfo.dat")) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/playerInfo.dat", FileMode.Open); HiScoreData data = new HiScoreData(); data.hiScore = _hiScore; bf.Serialize(file, data); file.Close(); } else { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Create(Application.persistentDataPath + "/playerInfo.dat"); HiScoreData data = new HiScoreData(); data.hiScore = _hiScore; bf.Serialize(file, data); file.Close(); } }
private void LoadHiScore() { if (File.Exists(Application.persistentDataPath + "/playerInfo.dat")) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/playerInfo.dat", FileMode.Open); HiScoreData data = (HiScoreData)bf.Deserialize(file); _hiScore = data.hiScore; _hiScoreText.text = _hiScore.ToString(); } }
public void InitializeScore() //スコアの初期化(外部使用) { _hiScoreData = SaveSystem.Load(0); //ハイスコアを取得 //GameManagerのHiScoreDataに適応 _hiScore1st = _hiScoreData._1stHiScoreLists[(int)_difficulty]; _hiScore2nd = _hiScoreData._2ndHiScoreLists[(int)_difficulty]; _hiScore3rd = _hiScoreData._3rdHiScoreLists[(int)_difficulty]; _score = 0; //スコアの初期化 }
private bool _isUpdateHiScore; //ゲーム中に1位のハイスコアを更新するかどうかのフラグ void Awake() { //instance変数が空だったらこのGameManagerをDontDestroyOnLoadに設定 if (instance == null) { instance = this; DontDestroyOnLoad(this.gameObject); } //instance変数に何か代入されていたらこれは必要ないため削除 else { Destroy(this.gameObject); } _hiScoreData = new HiScoreData(-1); //HiScoreDataを新規作成 HiScoreData LoadData = SaveSystem.Load(0); _hiScoreData.wasOpenExtra = LoadData.wasOpenExtra; //Extra達成条件済フラグをロード _hiScoreData.initialMessage = LoadData.initialMessage; //操作画面を出すかどうかのフラグをロード }