/// ========================================================================================================================= /// ========================================================================================================================= /// /// Operation Starshine ( Saving / Loading ) /// /// ========================================================================================================================= /// ========================================================================================================================= /// <summary> /// Saves the last round to the local leaderboard save file for this game /// </summary> /// <param name="_leaderboardData">The StarshineLeaderboardData to save</param> public static void SaveOperationStarshineToLocal(StarshineLeaderboardData _leaderboardData) { BinaryFormatter Formatter = new BinaryFormatter(); string SavePath = Application.persistentDataPath + "/operationstarshine.malf"; FileStream Stream = new FileStream(SavePath, FileMode.Append); Formatter.Serialize(Stream, _leaderboardData); Stream.Close(); }
public void SendDataToBoard(StarshineLeaderboardData Data) { if ((CheckFullData(Data)) && (!HasDataSent)) { StartCoroutine(OnlineLeaderboardManager.Send_OPSS_Data_Online(Data)); HasDataSent = true; Debug.Log("Data Send"); } else if ((!CheckFullData(Data)) && (!HasDataSent)) { Debug.LogWarning("Data Not Send - Not all values were filled"); } }
private bool CheckFullData(StarshineLeaderboardData dataToCheck) { if ((dataToCheck.Player1Name != null) && (dataToCheck.Player2Name != null) && (dataToCheck.Player1ShipName != null) && (dataToCheck.Player2ShipName != null) ) { Debug.Log("Success - Passed check"); return(true); } else { Debug.LogWarning("Failed - Data did not pass check"); return(false); } }
/// <summary> /// Loads the local leaderboard file for using in a local leaderboard /// </summary> /// <returns>The loaded StarshineLeaderboardData</returns> public static StarshineLeaderboardData LoadOperationStarshineLeaderboard() { string SavePath = Application.persistentDataPath + "/operationstarshine.malf"; if (File.Exists(SavePath)) { BinaryFormatter Formatter = new BinaryFormatter(); FileStream Stream = new FileStream(SavePath, FileMode.Open); StarshineLeaderboardData Data = Formatter.Deserialize(Stream) as StarshineLeaderboardData; Stream.Close(); return(Data); } else { Debug.LogError("Save file not found! (OP:SS - Load)"); return(null); } }
IEnumerator GetTopFive() { List <StarshineLeaderboardData> ListData = new List <StarshineLeaderboardData>(5); List <string> ReceivedPlayer1Name = new List <string>(); List <string> ReceivedPlayer2Name = new List <string>(); List <string> ReceivedPlayer1ShipName = new List <string>(); List <string> ReceivedPlayer2ShipName = new List <string>(); List <string> ReceivedPlayer1Score = new List <string>(); List <string> ReceivedPlayer2Score = new List <string>(); List <string> ReceivedTotalScore = new List <string>(); List <string> ReceivedPlatform = new List <string>(); UnityWebRequest Request = UnityWebRequest.Get(SaveManager.LoadOnlineBoardPath().onlineLeaderboardsBasePath + "getscorestarshinetopfive.php?"); yield return(Request.SendWebRequest()); if (Request.error == null) { string[] Values = Request.downloadHandler.text.Split("\r"[0]); // only get the top 5 entries for (int i = 0; i < Values.Length; i++) { if (i % 8 == 0) { ReceivedPlayer1Name.Add(Values[i]); } else if (i % 8 == 1) { ReceivedPlayer2Name.Add(Values[i]); } else if (i % 8 == 2) { ReceivedPlayer1ShipName.Add(Values[i]); } else if (i % 8 == 3) { ReceivedPlayer2ShipName.Add(Values[i]); } else if (i % 8 == 4) { ReceivedPlayer1Score.Add(Values[i]); } else if (i % 8 == 5) { ReceivedPlayer2Score.Add(Values[i]); } else if (i % 8 == 6) { ReceivedTotalScore.Add(Values[i]); } else if (i % 8 == 7) { ReceivedPlatform.Add(Values[i]); } else { Debug.LogError("Value to added to any list!"); } } for (int i = 0; i < ReceivedPlatform.Count; i++) { StarshineLeaderboardData Data = new StarshineLeaderboardData(); Data.Player1Name = ReceivedPlayer1Name[i]; Data.Player2Name = ReceivedPlayer2Name[i]; Data.Player1ShipName = ReceivedPlayer1ShipName[i]; Data.Player2ShipName = ReceivedPlayer2ShipName[i]; Data.Player1Score = int.Parse(ReceivedPlayer1Score[i]); Data.Player2Score = int.Parse(ReceivedPlayer2Score[i]); Data.Platform = ReceivedPlatform[i]; ListData.Add(Data); } ZeData = ListData; } }
/* * Format Types * * masf = Micro Arcade Save File * malf = Micro Arcade Leaderboard File * */ /// <summary> /// Creates all the save files with default vlaues if they do not exist on the system (helps avoid errors later on) /// </summary> public static void InitialseFiles() { BinaryFormatter _formatter = new BinaryFormatter(); string baseSavePath = Application.persistentDataPath; FileStream _stream; // Create Save Files // /settings.masf if (!File.Exists(baseSavePath + "/settings.masf")) { _stream = new FileStream(baseSavePath + "/settings.masf", FileMode.Create); ArcadeData _settingsData = new ArcadeData(); _formatter.Serialize(_stream, _settingsData); _stream.Close(); } // /controlconfig.masf -- is not made here as it works when you first run the project with a multi input //if (!File.Exists(baseSavePath + "/controlconfig.masf")) //{ // _stream = new FileStream(baseSavePath + "/controlconfig.masf", FileMode.Create); // ArcadeData _controlData = new ArcadeData(); // _formatter.Serialize(_stream, _controlData); // _stream.Close(); //} // /arcadeonline.masf if (!File.Exists(baseSavePath + "/arcadeonline.masf")) { _stream = new FileStream(baseSavePath + "/arcadeonline.masf", FileMode.Create); ArcadeOnlinePaths _onlineData = new ArcadeOnlinePaths(); _formatter.Serialize(_stream, _onlineData); _stream.Close(); } // Pinball Save Files // /ultimatepinball.masf if (!File.Exists(baseSavePath + "/ultimatepinball.masf")) { _stream = new FileStream(baseSavePath + "/ultimatepinball.masf", FileMode.Create); UltimatePinballData _pinballData = new UltimatePinballData(); _formatter.Serialize(_stream, _pinballData); _stream.Close(); } // /ultimatepinballsession.masf if (!File.Exists(baseSavePath + "/ultimatepinballsession.masf")) { _stream = new FileStream(baseSavePath + "/ultimatepinballsession.masf", FileMode.Create); UltimatePinballSessionData _pinballSessionData = new UltimatePinballSessionData(); _formatter.Serialize(_stream, _pinballSessionData); _stream.Close(); } // /ultimatepinballsession.malf if (!File.Exists(baseSavePath + "/ultimatepinball.malf")) { _stream = new FileStream(baseSavePath + "/ultimatepinball.malf", FileMode.Create); _formatter.Serialize(_stream, null); _stream.Close(); } // Operation Starshine Save Files // /operationstarshine.masf if (!File.Exists(baseSavePath + "/operationstarshine.masf")) { _stream = new FileStream(baseSavePath + "/operationstarshine.masf", FileMode.Create); OperationStarshineData _operationStarshineData = new OperationStarshineData(); _formatter.Serialize(_stream, _operationStarshineData); _stream.Close(); } // /operationstarshine.malf if (!File.Exists(baseSavePath + "/operationstarshine.malf")) { _stream = new FileStream(baseSavePath + "/operationstarshine.malf", FileMode.Create); StarshineLeaderboardData _operationStarshineLeaderboardData = new StarshineLeaderboardData(); _formatter.Serialize(_stream, _operationStarshineLeaderboardData); _stream.Close(); } // Quacking Time Save Files // /quackingtime.masf if (!File.Exists(baseSavePath + "/quackingtime.masf")) { _stream = new FileStream(baseSavePath + "/quackingtime.masf", FileMode.Create); QuackingTimeData _quackingTimeData = new QuackingTimeData(); _formatter.Serialize(_stream, _quackingTimeData); _stream.Close(); } // Crushing Save Files // /crushing.masf if (!File.Exists(baseSavePath + "/crushing.masf")) { _stream = new FileStream(baseSavePath + "/crushing.masf", FileMode.Create); CrushingData _crushingData = new CrushingData(); _formatter.Serialize(_stream, _crushingData); _stream.Close(); } }