IEnumerator UploadLevel(string jsonFile) { DevEditorData level = new DevEditorData(); level = JsonUtility.FromJson<DevEditorData>(jsonFile); DynamoDBInfo requested = RequestIDs(); while (requested.listOfIndexes.Count == 0 || requested.lastIdUsed == 0) yield return null; string levelName = level.levelName; string kubicode = GenerateKubiCode(requested); // create a new upload request, input the relevant information var putItemRequest = new PutItemRequest { TableName = DatabaseInfo.userContent_tableName, Item = new Dictionary<string, AttributeValue>() { { DatabaseInfo.userContent_pKey, new AttributeValue{ S = kubicode } }, { DatabaseInfo.userContent_levelName, new AttributeValue { S = levelName } }, { DatabaseInfo.userContent_jsonFile, new AttributeValue { S = jsonFile } } } }; var response = client.PutItemAsync(putItemRequest); // if something goes wrong, debug the log message from AWS if (response.Exception != null) { Debug.Log(response.Exception.Message); } // else, the item has successfully been uploaded else { Debug.Log(levelName + " has been uploaded successfully!"); UserLevelFiles.AddToUploads(uploadLevelDropdown.captionText.text); } /* // connect to dynamoDB database and pass the request information to upload the item client.PutItemAsync(putItemRequest, (result) => { // if something goes wrong, debug the log message from AWS if (result.Exception != null) { Debug.Log(result.Exception.Message); return; } // else, the item has successfully been uploaded else { Debug.Log(levelName + " has been uploaded successfully!"); UserLevelFiles.AddToUploads(uploadLevelDropdown.captionText.text); } }, null);*/ yield return null; }
// called by UIManager void UploadLevel(string jsonFile, DevEditorData levelData) { Debug.Log("Craeting new Request"); var request = new PutItemRequest { TableName = CommunityDatabase.tableName, Item = new Dictionary <string, AttributeValue>() { { CommunityDatabase.baseTablePK, new AttributeValue { S = "12345" } }, { CommunityDatabase.baseTableSK, new AttributeValue { S = levelData.levelName } }, { CommunityDatabase.levelFile, new AttributeValue { S = jsonFile } }, { CommunityDatabase.publishDate, new AttributeValue { S = DateTime.Today.ToShortDateString() } }, // { CommunityDatabase.creatorSetDifficulty, new AttributeValue{ S = ""} } }; Debug.Log("Uploading " + levelData.levelName); client.PutItemAsync(request); var response = client.PutItemAsync(request); if (response.Exception != null) { Debug.Log(response.Exception.Message); } }
// when the player wants to upload his level directly from the editor public void UploadLevelFromEditor() { string json = SaveAndLoad.instance.GetLevelFile(); DevEditorData level = JsonUtility.FromJson <DevEditorData>(json); UploadLevel(json, level); }
private void ModifyFile() { if (!hasFile) { assetPath = AssetDatabase.GetAssetPath(levelTextFile); string json = File.ReadAllText(assetPath); levelData = JsonUtility.FromJson <DevEditorData>(json); hasFile = true; } DrawInfo(); }
IEnumerator UploadAllGameLevel() { foreach (Object level in assets) { DevEditorData levelFile = JsonUtility.FromJson<DevEditorData>(level.ToString()); var uploadRequest = new PutItemRequest { TableName = DatabaseInfo.levels_tableName, Item = new Dictionary<string, AttributeValue>() { { DatabaseInfo.levels_pKey + ".MyManBro", new AttributeValue{ S = levelFile.Kubicode} }, { DatabaseInfo.levels_levelName, new AttributeValue{ S = levelFile.levelName } }, { DatabaseInfo.levels_jsonFile, new AttributeValue{ S = level.ToString() } }, } }; var response = client.PutItemAsync(uploadRequest); // if something goes wrong, debug the log message from AWS if (response.Exception != null) Debug.Log(response.Exception.Message); // else, the item has successfully been uploaded else Debug.Log(levelFile.levelName + " has been uploaded successfully!"); /*client.PutItemAsync(uploadRequest, (result) => { // if something goes wrong, debug the log message from AWS if (result.Exception != null) { Debug.Log(result.Exception.Message); return; } // else, the item has successfully been uploaded else Debug.Log(levelFile.levelName + " has been uploaded successfully!"); }, null);*/ DatabaseInfo.CleanInfo(); yield return new WaitForSeconds(1.5f); } yield return null; }
// Load the next level (extract the file) IEnumerator LoadGameLevel() { _KUBRotation.instance.ResetRotation(); _FeedBackManager.instance.ResetVictoryFX(); PlayerMoves.instance.ResetMoves(); if (_lockRotate) { UIManager.instance.UpdateRotateButtons(true); } else { UIManager.instance.TurnOnRotate(); } string json = _levelFile.ToString(); DevEditorData levelData = JsonUtility.FromJson <DevEditorData>(json); SaveAndLoad.instance.finishedBuilding = false; SaveAndLoad.instance.ExtractGameLevel(levelData); while (!SaveAndLoad.instance.finishedBuilding) { yield return(null); } // once the level is loaded VictoryConditionManager.instance.CheckVictoryCubes(); _DataManager.instance.GameSet(); _MaterialCentral.instance.MaterialSet(); _MaterialCentral.instance.ChangeUniverse(_levelBiome); UIManager.instance.GameCanvasPriority(); yield return(null); }