Commit a3463f7f authored by shujianhe's avatar shujianhe

添加对外的游戏进度读写接口

parent aad11f31
......@@ -8,7 +8,7 @@ public class AreaInfoUseData
public short clickX;
public short clickY;
}
public class GameScenUserData
public class GameScenUserInfo
{
public string img = "";//线图
public string json = "";//数据
......
......@@ -392,6 +392,47 @@ public class utilsTools
public static void replayGameProcessById(string id,GameObject gameObject,List<Tuple<short,float,float>> playOrders)
{
}
public static bool setGameScenUserInfo(string id,string lineUrl,string colorUrl,string jsonUrl)
{
string gameSaveKey = "gameUserData_" + id.ToString();
string oldData = utilsDB.getDBStringDataByKey(gameSaveKey, "");
if (oldData.Equals("") == false)
{
var data = JsonUtility.FromJson<GameScenUserInfo>(oldData);
return data.id.Equals(id);
}
GameScenUserInfo gameScenUserDataInfo = new GameScenUserInfo();
gameScenUserDataInfo.img = lineUrl;
gameScenUserDataInfo.finishImg = colorUrl;
gameScenUserDataInfo.json = jsonUrl;
gameScenUserDataInfo.id = id;
utilsDB.setDBJsonDataByKey(gameSaveKey, JsonUtility.ToJson(gameScenUserDataInfo));
return true;
}
public static GameScenUserInfo getGameScenUserInfo(string id)
{
string gameSaveKey = "gameUserData_" + id.ToString();
string oldData = utilsDB.getDBStringDataByKey(gameSaveKey, "");
if (oldData.Equals("") == false)
{
var data = JsonUtility.FromJson<GameScenUserInfo>(oldData);
return data;
}
return null;
}
public static bool saveGameScenUserInfo(GameScenUserInfo gameScenUserInfo)
{
string gameSaveKey = "gameUserData_" + gameScenUserInfo.id;
string oldData = utilsDB.getDBStringDataByKey(gameSaveKey, "");
if (oldData.Equals("") == false)
{
return false;
}
var data = JsonUtility.FromJson<GameScenUserInfo>(oldData);
if (data.id.Equals(gameScenUserInfo.id) == false) return false;
utilsDB.setDBJsonDataByKey(gameSaveKey, JsonUtility.ToJson(gameScenUserInfo));
return true;
}
public static Vector2 ScreenToUILocalPos(RectTransform transform, Vector2 mousePos, Camera canvasCam = null)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment