public void Save() { string savePath = Directory.GetCurrentDirectory() + "\\Saves\\" + _titleWorld + ".txt"; string[] oldLog = File.ReadAllLines(savePath); string[] saveLog = new string[100]; saveLog[0] = "[ChunksCount]"; saveLog[1] = SHA1_Encode.Decryption(oldLog[1], "z0s%b&I)Y%PW26A8"); // количество чанков saveLog[2] = "[TitleWorld]"; saveLog[3] = _titleWorld; // название мира saveLog[4] = "[IsFirstGame]"; saveLog[5] = "false"; saveLog[6] = "[PlayerTransform]"; _player = FindObjectOfType <FirstPersonController>().transform; saveLog[7] = _player.position.x + "|" + _player.position.y + "|" + _player.position.z; saveLog[8] = _player.eulerAngles.x + "|" + _player.eulerAngles.y + "|" + _player.eulerAngles.z; saveLog[9] = _player.localScale.x + "|" + _player.localScale.y + "|" + _player.localScale.z; for (int i = 0; i < saveLog.Length; i++) { saveLog[i] = SHA1_Encode.Encryption(saveLog[i], "z0s%b&I)Y%PW26A8"); } File.WriteAllLines(savePath, saveLog); }
private Vector3 GetVector(string vector)//метод возвращает вектор, например позицию из зашифрованной строки { vector = SHA1_Encode.Decryption(vector, "z0s%b&I)Y%PW26A8"); Vector3 playerPos = new Vector3(0, 0, 0); string x = "", y = "", z = ""; string posYStr = ""; for (int i = 0; i < vector.Length; i++) { if (vector[i] != '|') { x += vector[i] != ',' ? vector[i] : '.'; } else { for (int k = i + 1; k < vector.Length; k++) { posYStr += vector[k]; } break; } } playerPos.x = Convert.ToSingle(x, System.Globalization.CultureInfo.InvariantCulture); string posZStr = ""; for (int i = 0; i < posYStr.Length; i++) { if (posYStr[i] != '|') { y += posYStr[i] != ',' ? posYStr[i] : '.'; } else { for (int k = i + 1; k < posYStr.Length; k++) { posZStr += posYStr[k]; } break; } } playerPos.y = Convert.ToSingle(y, System.Globalization.CultureInfo.InvariantCulture); for (int i = 0; i < posZStr.Length; i++) { if (posZStr[i] != '|') { z += posZStr[i] != ',' ? posZStr[i] : '.'; } else { break; } } playerPos.z = Convert.ToSingle(z, System.Globalization.CultureInfo.InvariantCulture); return(playerPos); }
private string[] ReadText(string path) { string[] save = File.ReadAllLines(path); for (int i = 0; i < save.Length; i++) { save[i] = SHA1_Encode.Decryption(save[i], "z0s%b&I)Y%PW26A8"); } return(save); }
private void OnEnable() { Saver.saveGame += this.Save;// сохраняет настройки мира и персонажа при вызове события string keyPath = "SOFTWARE\\" + "BuildingSimulator" + "\\Settings"; Settings.RegKey.GetValue("LoadWorld", out string title, keyPath); _titleWorld = SHA1_Encode.Decryption(title, "z0s%b&I)Y%PW26A8"); Debug.Log("Title world - " + _titleWorld);// вывод в дебаг название мира Load(); }
private void OnEnable() { _buildHouse = FindObjectOfType <BuildHouse>(); Saver.saveGame += this.Save;// сохраняет настройки мира и персонажа при вызове события string keyPath = "SOFTWARE\\" + "BuildingSimulator" + "\\Settings"; Settings.RegKey.GetValue("LoadWorld", out string title, keyPath); _titleWorld = SHA1_Encode.Decryption(title, "z0s%b&I)Y%PW26A8"); _objectDown = ObjectDown.Instance; Load(); }
private void Awake() { string keyPath = "SOFTWARE\\" + "BuildingSimulator" + "\\Settings"; // путь в регистре до настроек RegKey.GetValue("LoadWorld", out string loadWrld, keyPath); // получаем название мира loadWrld = SHA1_Encode.Decryption(loadWrld, "z0s%b&I)Y%PW26A8"); // декодируем название мира string path = Directory.GetCurrentDirectory() + "\\Saves\\" + loadWrld + ".txt"; // ищем такой же мир в папке Saves string[] save = File.ReadAllLines(path); //читаем найденое сохранение string count = SHA1_Encode.Decryption(save[1], "z0s%b&I)Y%PW26A8"); // декодируем // Debug.Log("Chunks count - " + count); string isFp = SHA1_Encode.Decryption(save[5], "z0s%b&I)Y%PW26A8"); bool isFirstGame = System.Convert.ToBoolean(isFp); BuildPlatforms(System.Convert.ToInt16(count), isFirstGame); }
public void Load() { string savePath = Directory.GetCurrentDirectory() + "\\Saves\\" + _titleWorld + ".txt"; string[] saveLog = File.ReadAllLines(savePath); if (Convert.ToBoolean(SHA1_Encode.Decryption(saveLog[5], "z0s%b&I)Y%PW26A8")))//проверяем первая ли игра { return; }// если нет, то загружаем позицию saveLog[6] = "[PlayerTransform]"; #region SetPosition LoadTransformation load; _player = FindObjectOfType <FirstPersonController>().transform; load.GetTransform(ref _player, saveLog[7], saveLog[8], saveLog[9]);//загрузка трансформа игрока _player.GetComponent <FirstPersonController>().originalRotation = _player.transform.eulerAngles; #endregion }