public void saveFile() { string destination = Application.persistentDataPath + "/playerSave"; string filename = "/save.dat"; FileStream file; if (File.Exists(destination + filename)) { Debug.Log("rewriting"); file = File.OpenWrite(destination + filename); } else { Debug.Log("creating"); if (!Directory.Exists(destination)) { Directory.CreateDirectory(destination); } file = File.Create(destination + filename); } gameData tmpData = new gameData(gameData); BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(file, tmpData); file.Close(); }
public void saveData(int score) { BinaryFormatter BinForm = new BinaryFormatter(); //Creates a binary formatter FileStream file = File.Open(Application.persistentDataPath + "/gameInfo34.dat", FileMode.Open); gameData data = new gameData(); //Creates container for data if (score >= 50) { data.knightUnlocked = true; } for (int i = 0; i < 20; i++) { if (score > scores[i]) { scores.Insert(i, score); break; } else if (i == 19) { scores.Add(score); } } data.scores = scores; BinForm.Serialize(file, data); //serializes file.Close(); }
public void loadData() { if (File.Exists(Application.persistentDataPath + "/gameInfo34.dat")) { BinaryFormatter BinForm = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/gameInfo34.dat", FileMode.OpenOrCreate); gameData data = (gameData)BinForm.Deserialize(file); file.Close(); scores = data.scores; knightUnlocked = data.knightUnlocked; } else { BinaryFormatter BinForm = new BinaryFormatter(); //Creates a binary formatter FileStream file = File.Create(Application.persistentDataPath + "/gameInfo34.dat"); //Creates file gameData data = new gameData(); //Creates container for data for (int i = 0; i < 20; i++) { data.scores.Add(0); } BinForm.Serialize(file, data); //serializes file.Close(); scores = data.scores; } }
public static void SaveData(gameData data) { if (data.Highscore == -1) { data.Highscore = Highscore; } else { Highscore = data.Highscore; } if (data.PixelEffect == -1) { data.PixelEffect = PixelEffect; } else { PixelEffect = data.PixelEffect; } BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Create); formatter.Serialize(stream, data); stream.Close(); }
void Start() { AS = this.GetComponent <AudioSource>(); completedLevels = new bool[10]; for (int i = 0; i < completedLevels.Length; i++) { completedLevels[i] = false; } allPoints = new List <GameObject>(); allInflictionPoints = new List <GameObject>(); availableMethods = new List <List <inflictionMethods> >(); anwser = new List <inflictionMethods>(); currentMethods = new List <inflictionMethods>(); gameData data = saveSystem.loadProgress(); if (data != null) { volumeSlider.value = data.Volume; Volume = data.Volume; completedLevels = new bool[data.completedLevels.Length]; for (int i = 0; i < data.completedLevels.Length; i++) { completedLevels[i] = data.completedLevels[i]; } Level = data.Level; checkLevel(); } else { generateLevel(); } }
// Use this for initialization void Start() { DB = FindObjectOfType <gameData>(); createButton.onClick.AddListener(loadPlayer); usr.onValidateInput += delegate(string input, int charIndex, char addedChar) { return(Validate(addedChar)); }; pas.onValidateInput += delegate(string input, int charIndex, char addedChar) { return(Validate(addedChar)); }; }
private string receiveData() { try { Console.WriteLine("Waiting for broadcast"); byte[] bytes = listener.Receive(ref groupEP); string message = $"{Encoding.ASCII.GetString(bytes, 0, bytes.Length)}"; receivedData.text = "Received: " + message.Split('|')[2]; gData = JsonConvert.DeserializeObject <gameData>(message.Split('|')[2]); Xtarget = gData.Xtarget; Ytarget = gData.Ytarget; Ztarget = gData.Ztarget; X_Attractor1 = gData.X_Attractor1; Y_Attractor1 = gData.Y_Attractor1; Z_Attractor1 = gData.Z_Attractor1; X_Attractor2 = gData.X_Attractor2; Y_Attractor2 = gData.Y_Attractor2; Z_Attractor2 = gData.Z_Attractor2; Traj_Flag = gData.Traj_Flag; DeadZone = gData.DeadZone; Assistance = gData.Assistance; Shutdown = gData.Shutdown; AssistanceLevel = gData.AssistanceLevel; return(message); } catch (SocketException e) { Console.WriteLine(e); return("timeout"); } }
////////////////////////////////////////////////////////////////////////// void Start() { if (devMode == false) { listener = new UdpClient(3500); groupEP = new IPEndPoint(IPAddress.Any, 3500); } else { listener = new UdpClient(2300); groupEP = new IPEndPoint(IPAddress.Any, 2300); } listener.Client.ReceiveBufferSize = 0; listener.Client.ReceiveTimeout = 15; textX.text = "X: 0"; textY.text = "Y: 0"; UDPsendFirst("VC|controllerStartUpAcknowledgment"); cData = new controllerData(); gData = new gameData(); }
public bool loadfile() { Debug.Log("loading file"); string destination = Application.persistentDataPath + "/playerSave/save.dat"; FileStream file; if (File.Exists(destination)) { file = File.OpenRead(destination); } else { Debug.Log("File not found"); return(false); } BinaryFormatter bf = new BinaryFormatter(); gameData data = null; try{ data = (gameData)bf.Deserialize(file); file.Close(); }catch { Debug.Log("File Structure Changed: "); file.Close(); return(false); } set(data); return(true); }
void Start() { string path = Application.streamingAssetsPath + "/AppleLogs.json"; string jsonString = File.ReadAllText(path); gameData data = JsonUtility.FromJson <gameData>(jsonString); logs.Clear(); if (!(data == null)) { foreach (GameLog log in data.ApplePicker) { logs.Add(log); } } basketList = new List <GameObject>(); for (int i = 0; i < numBaskets; i++) { GameObject tBasketGO = Instantiate <GameObject>(basketPrefab); Vector3 pos = Vector3.zero; pos.y = basketBottomY + (basketSpacingY * i); tBasketGO.transform.position = pos; basketList.Add(tBasketGO); } }
////////////////////////////////////////////////////////////////////////// void Start() { listener = new UdpClient(3000); groupEP = new IPEndPoint(IPAddress.Any, 3000); listener.Client.ReceiveBufferSize = 0; listener.Client.ReceiveTimeout = 15; gData = new gameData(); }
public void set(gameData data) { try{ gameData = new gameData(data); }catch { gameData = gameData.init; } }
public static void saveProgress(int l, bool[] com, int v) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Create); gameData data = new gameData(l, com, v); formatter.Serialize(stream, data); stream.Close(); }
void DoubleCoins() { soundMan.Play("CoinReward"); coinsText.text = (levelMan.coinsValue * 2).ToString(); gameData data = saveSystem.LoadGameData(); saveSystem.SaveCoinData(levelMan.coinsValue + data.totalCoins); on = false; }
void Start() { string path = Application.streamingAssetsPath + "/AppleLogs.json"; // path to apple string jsonString = File.ReadAllText(path); // read all text from json file gameData data = JsonUtility.FromJson <gameData>(jsonString); // store the json data into a gamedata variable Applelogs.Clear(); if (!(data == null)) // as long as there is more data { foreach (GameLog log in data.ApplePicker) // for each log in the data { Applelogs.Add(log); // add the log to Applelogs } } // This of these code segment are very similar for every game^^ string RPSpath = Application.streamingAssetsPath + "/RPSLogs.json"; string RPSjsonString = File.ReadAllText(RPSpath); gameDataRPS RPSdata = JsonUtility.FromJson <gameDataRPS>(RPSjsonString); RPSlogs.Clear(); if (!(RPSdata == null)) { foreach (GameLog log in RPSdata.RockPaperScissors) { RPSlogs.Add(log); } } string Mempath = Application.streamingAssetsPath + "/MemLogs.json"; string MemjsonString = File.ReadAllText(Mempath); gameDataMemory Memdata = JsonUtility.FromJson <gameDataMemory>(MemjsonString); Memlogs.Clear(); if (!(Memdata == null)) { foreach (GameLog log in Memdata.MemoryGame) { Memlogs.Add(log); } } string Spacepath = Application.streamingAssetsPath + "/SpaceLogs.json"; string SpacejsonString = File.ReadAllText(Spacepath); gameDataShooter Spacedata = JsonUtility.FromJson <gameDataShooter>(SpacejsonString); Spacelogs.Clear(); if (!(Spacedata == null)) { foreach (GameLog log in Spacedata.SpaceGame) { Spacelogs.Add(log); } } }
public void SaveData() { BinaryFormatter binForm = new BinaryFormatter(); // for encryption FileStream file = File.Create(Application.persistentDataPath + "/highScore.dat"); // creates save file gameData data = new gameData(); // container data.highScore = this.highScore; binForm.Serialize(file, data); file.Close(); }
public void SaveData() { BinaryFormatter BinForm = new BinaryFormatter(); //creates a bin formatter FileStream file = File.Create(Application.persistentDataPath + "/gameInfo.dat"); //Creates file gameData data = new gameData(); //creates container for data data.highscore = highScore; BinForm.Serialize(file, data); //serializes file.Close(); //closes file }
public void SaveData() { BinaryFormatter BinForm = new BinaryFormatter(); FileStream file = File.Create(Application.persistentDataPath + "/gameInfo.dat"); gameData data = new gameData(); data.highscore = highScore; BinForm.Serialize(file, data); file.Close(); }
public void SaveData() { BinaryFormatter binForm = new BinaryFormatter(); FileStream file = File.Create (Application.persistentDataPath + "/gameinfo.dat"); gameData data = new gameData(); data.highScore = highScore; data.coinsCollected = coinsCollected; binForm.Serialize(file, data); file.Close(); }
private void Start() { if (GameObject.Find("gameData") != null) { data = GameObject.Find("gameData").GetComponent <gameData> (); amountOfPlayers = data.NRPlayer; } builderParent.gameObject.SetActive(false); StartGameFlow(); }
public void SaveData() { using (FileStream file = File.Create(Application.persistentDataPath + "/gameInfo.dat")) { BinaryFormatter binForm = new BinaryFormatter(); gameData data = new gameData(); data.highScore = highScore; data.coinsCollected = coinsCollected; binForm.Serialize(file, data); } }
public void SaveData() { BinaryFormatter Binform = new BinaryFormatter(); //skapa bin formatering FileStream file = File.Create(Application.persistentDataPath + "/gameInfo.dat"); //skapa fil gameData data = new gameData(); //skapar container för data data.highScore = highScore; Binform.Serialize(file, data); file.Close(); }
public void loadData() { if (File.Exists(Application.persistentDataPath + "/gameInfo.dat")) //dont load if there has been nothing saved { BinaryFormatter BinForm = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/gameInfo.dat", FileMode.Open); gameData data = (gameData)BinForm.Deserialize(file); //decripts the binary file.Close(); highScore = data.highscore; } }
public void LoadData() { if (File.Exists(Application.persistentDataPath + "/highScore.dat")) { BinaryFormatter binForm = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/highScore.dat", FileMode.Open); gameData data = (gameData)binForm.Deserialize(file); file.Close(); this.highScore = data.highScore; } }
void LoadGameData() { try { gdata = saveSystem.LoadGameData(); } catch (System.Exception) { coinsValue = 0; } }
public void SaveData() { BinaryFormatter binaryForm = new BinaryFormatter(); FileStream file = File.Create(Application.persistentDataPath + "/gameInfo.dat"); gameData data = new gameData(); data.highScore = data_Management.highScore; data.boneCollected = data_Management.boneCollected; binaryForm.Serialize(file, data); file.Close(); }
public static void saveLevelInfo(levelManager levelman) { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/info.nfo"; FileStream stream = new FileStream(path, FileMode.Create); gameData data = new gameData(levelman); formatter.Serialize(stream, data); stream.Close(); }
public static void SaveCoinData(int coins) { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/info.nfo"; FileStream stream = new FileStream(path, FileMode.Create); gameData data = new gameData(coins); formatter.Serialize(stream, data); stream.Close(); }
private void saveNewScore() { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "gameInfo.dat", FileMode.Create); gameData scoreDataToSave = new gameData(); scoreDataToSave.mapIndex = SceneManager.GetActiveScene().buildIndex; scoreDataToSave.NewTimeToFinish = timeTimer.GetTimerTime(); bf.Serialize(file, scoreDataToSave); file.Close(); }
public void LoadData() { //Data is loaded if (File.Exists(Application.persistentDataPath + "/gameInfo.dat")) //if file in condition exists { BinaryFormatter BinForm = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/gameInfo.dat", FileMode.Open); //opens file gameData data = (gameData)BinForm.Deserialize(file); file.Close(); highScore = data.highscore; } }
public void SaveGameDataApple() // save the data of the player { gameData newData = new gameData(); string path = Application.streamingAssetsPath + "/AppleLogs.json"; foreach (GameLog log in ApplePicker.logs) // for each log in Apple pickers logs { newData.Add(log); // add the new game data } File.WriteAllText(path, JsonUtility.ToJson(newData)); // write log into system }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { gameData ds = new gameData(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())); ) { ; } if ((s1.Position == s1.Length)) { return type; } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return type; }