Ejemplo n.º 1
0
    public string LoadUserBuilding()
    {
        string  query   = $"SELECT * FROM dbo.PlayerBuilding WHERE UserAccount = '{UserInfoProvider.Instance.UserAccount}'";
        DataSet dataSet = ConnectDB_GetDataSet("PlayerInfo_DB", query);

        if (dataSet == null)
        {
            return("서버에 연결할 수 없습니다.");
        }

        object[] dataArray    = dataSet.Tables[0].Rows[0].ItemArray;
        string   buildingJSON = dataArray[1].ToString();

        BuildingJSON jsonObj = JsonUtility.FromJson <BuildingJSON>(buildingJSON);

        BuildingStatus[] statuses = jsonObj.Statuses;
        if (statuses.Length == 0)
        {
            UserBuildingProvider.Instance.Initialize(null);
        }
        else
        {
            UserBuildingProvider.Instance.Initialize(statuses);
        }
        return("Success");
    }
Ejemplo n.º 2
0
    public void Save_PlayerBuilding()
    {
        BuildingJSON buildingJSON = new BuildingJSON();

        buildingJSON.Statuses = UserBuildingProvider.Instance.BuildingStatus;

        string jsonSTR = JsonUtility.ToJson(buildingJSON);
        string sql     = $"UPDATE dbo.PlayerBuilding SET BuildingStatusJSON='{jsonSTR}' WHERE UserAccount='{UserInfoProvider.Instance.UserAccount}'";

        ConnectDB_ExecuteNonQuery("PlayerInfo_DB", sql);
    }