Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using UnityEngine;
- using System.IO;
- using Inventory;
- namespace IOUtility {
- public class IOAccess {
- static int _onlineScore = 0;
- public static int OnlineScore {
- get {
- return _onlineScore;
- }
- set {
- _onlineScore = value;
- }
- }
- public static void SaveCredentials(string path, string userName, string password) {
- string filepath = Application.persistentDataPath + @"/" + path;
- using (StreamWriter writer = new StreamWriter(filepath)) {
- writer.WriteLine(userName);
- writer.WriteLine(password);
- }
- }
- public static string[] OpenCredentials(string path) {
- string[] userNameAndPass = new string[2];
- userNameAndPass[0] = " ";
- userNameAndPass[1] = " ";
- string filepath = Application.persistentDataPath + @"/" + path;
- if (File.Exists(filepath)) {
- using (StreamReader reader = new StreamReader(filepath)) {
- userNameAndPass[0] = reader.ReadLine();
- userNameAndPass[1] = reader.ReadLine();
- }
- }
- return userNameAndPass;
- }
- public static void SaveString(string path, string stringValue) {
- string filepath = Application.persistentDataPath + @"/" + path;
- using (StreamWriter writer = new StreamWriter(filepath)) {
- writer.WriteLine(ballName);
- }
- }
- public static string OpenString(string path) {
- string filepath = Application.persistentDataPath + @"/" + path;
- if (File.Exists(filepath)) {
- using (StreamReader reader = new StreamReader(filepath)) {
- return reader.ReadLine();
- }
- }
- return null;
- }
- public static void SaveInt(string path, int score) {
- string filepath = Application.persistentDataPath + @"/" + path;
- using (FileStream stream = new FileStream(filepath, FileMode.Create, FileAccess.Write)) {
- using (BinaryWriter writer = new BinaryWriter(stream)) {
- //using (StreamWriter writer = new StreamWriter(filepath)) {
- writer.Write(score);
- //writer.WriteLine(score);
- //}
- }
- }
- }
- public static int OpenInt(string path) {
- int score = 0;
- string filepath = Application.persistentDataPath + @"/" + path;
- if (File.Exists(filepath)) {
- using (FileStream stream = new FileStream(filepath, FileMode.Open, FileAccess.Read)) {
- using (BinaryReader reader = new BinaryReader(stream)) {
- // using (StreamReader reader = new StreamReader(filepath)) {
- score = reader.ReadInt32();
- //score = int.Parse(reader.ReadLine());
- //}
- }
- }
- }
- return score;
- }
- public void SaveStringOnline(string ballName) {
- }
- public static string OpenStringOnline() {
- return null;
- }
- public static void SaveIntOnline(int score) {
- //GJAPI.Data.Set("score", score.ToString(), true);
- }
- public static string CallBack(string data) {
- return data;
- }
- public static void OpenIntOnline() {
- string onlineData = string.Empty;
- //GJAPI.Data.DataReady += delegate {
- // _onlineScore = int.Parse(GJAPI.Data.StringData);
- //};
- //GJAPI.Data.Get("score", true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment