public void NewStart() { string name = nameCharacterInputField.GetComponent <InputField> ().text; if (IsValidNameCharacter(name) == true) { string path = "Assets/Resources/Saved/" + name + ".data"; if (File.Exists(path) == false) { FileStream f = new FileStream(path, FileMode.CreateNew); byte[] byteArray; /* * int offSetX = UnityEngine.Random.Range (-99999, 99999); * Debug.Log ("Random X : " + offSetX); * byteArray = BitConverter.GetBytes (offSetX); * f.Write (byteArray, 0, byteArray.Length); * * int offSetY = UnityEngine.Random.Range (-99999, 99999); * Debug.Log ("Random Y : " + offSetY); * byteArray = BitConverter.GetBytes (offSetY); * f.Write (byteArray, 0, byteArray.Length); */ byteArray = BitConverter.GetBytes((int)0); f.Write(byteArray, 0, byteArray.Length); byteArray = BitConverter.GetBytes((int)0); f.Write(byteArray, 0, byteArray.Length); byteArray = System.Text.Encoding.UTF8.GetBytes(name); f.Write(byteArray, 0, byteArray.Length); byteArray [0] = (byte)(isHardMode == true ? 1 : 0); f.WriteByte(byteArray [0]); f.Close(); //Debug.Log (name + " Character Saved!"); path = "Assets/Resources/Config/whatToPlay.cfg"; f = new FileStream(path, FileMode.Create); byte[] data = new byte[name.Length]; for (int i = 0; i < name.Length; i++) { data [i] = (byte)name [i]; //Debug.Log (name [i]+" "+data[i]); } f.Write(data, 0, data.Length); f.Close(); BackToMainMenuFromNewCharacter(); GameSystem.ChangeLevelOfGame(GameSystem.levelSceneOfGame.game); } else { alertMessage.transform.localPosition = new Vector3(0, 0, 0); newCharacter.SetActive(false); alertMessage.SetActive(true); } } }
public void LoadSavedGame() { if (whatSavedGame != "") { string path = "Assets/Resources/Config/whatToPlay.cfg"; FileStream f = new FileStream(path, FileMode.Create); byte[] data = new byte[whatSavedGame.Length]; for (int i = 0; i < whatSavedGame.Length; i++) { data [i] = (byte)whatSavedGame [i]; } f.Write(data, 0, data.Length); f.Close(); GameSystem.ChangeLevelOfGame(GameSystem.levelSceneOfGame.game); } }
public void ExitLevel() { SaveGame(); GameSystem.ChangeLevelOfGame(GameSystem.levelSceneOfGame.startUpMenu); }