Exemple #1
0
    IEnumerator DownloadingXML(string fileName)
    {
        while (AWS.downloadingStuff)
        {
            Debug.Log("Downloading XML ~");
#if UNITY_ANDROID
            string aeDir = Application.persistentDataPath;
#else
            string aeDir = Application.dataPath;
#endif
            if (AWS.downloadedStuff && File.Exists(aeDir + "/Serialization/XMLa/" + AWS.levelFolderName + "/" + fileName))
            {
                Debug.Log("Finished downloading XML");
                XmlSerializer serilizer = new XmlSerializer(typeof(AndroidDatabase));
                FileStream    stream    = new FileStream(aeDir + "/Serialization/XMLa/" + AWS.levelFolderName + "/" + fileName, FileMode.Open);
                androidDB = serilizer.Deserialize(stream) as AndroidDatabase;
                stream.Close();
                AWS.downloadingStuff = false;
                AWS.downloadedStuff  = false;
                DownloadAsset();
                yield break;
            }
            yield return(null);
        }
    }
Exemple #2
0
    public void UploadLevel(string fileName, AndroidDatabase androidDB)
    {
        if (!Directory.Exists(Application.dataPath + "/Serialization/XMLa/temp"))
        {
            Directory.CreateDirectory(Application.dataPath + "/Serialization/XMLa/temp");
        }
        XmlSerializer serilizer = new XmlSerializer(typeof(AndroidDatabase));
        StreamWriter  stream    = new StreamWriter(Application.dataPath + "/Serialization/XMLa/temp/" + fileName + ".xml", false, Encoding.GetEncoding("UTF-8"));

        serilizer.Serialize(stream, androidDB);
        stream.Close();
        //uploading
        AWS.AWSUploadXML(fileName);
        StartCoroutine(UploadingXML(fileName));
    }
Exemple #3
0
    public void SaveLevelButton()
    {
        LevelDatabase levelDB = new LevelDatabase();
        string        input   = uim.UIsave.transform.GetChild(0).GetChild(0).FindChild("SaveInput").GetComponent <InputField>().text;

        if (input != "")
        {
            levelDB.cameraPosition = gm.cameraPlacementObject.transform.position;
            levelDB.objectScale    = gm.myGrid[0, 0].nVisualGrid.transform.localScale;
            List <string> myBundle = new List <string>();
            foreach (Node n in gm.myGrid)
            {
                if (n.nObjects.Count > 0)
                {
                    LevelNode levelNode = new LevelNode();
                    levelNode.nodePositionX = n.nPosX;
                    levelNode.nodePositionZ = n.nPosZ;
                    for (int i = 0; i < n.nObjects.Count; i++)
                    {
                        levelNode.objectPositions.Add(n.nObjects[i].LObject.transform.position);
                        levelNode.objectRotations.Add(n.nObjects[i].LObject.transform.GetChild(0).transform.eulerAngles);
                        levelNode.objectTypes.Add(n.nObjects[i].LObjectType);
                        levelNode.objectIDs.Add(n.nObjects[i].LObject.name);
                        if (n.nObjects[i].LObject.name == "RW_RunwayNumber")
                        {
                            for (int j = 0; j < n.nObjects.Count; j++)
                            {
                                levelNode.numberStrings.Add(n.nObjects[i].LObject.transform.Find("UICanvas").transform.Find("lane_text").GetComponent <Text>().text);
                            }
                        }
                        //levelDB.objectBundleNames.Add(n.nObjects[i].bundleName);
                        myBundle.Add(n.nObjects[i].bundleName);
                    }
                    levelDB.dbList.Add(levelNode);
                }
            }
            levelDB.objectBundleNames = myBundle.Distinct().ToList();
            xmlm.SaveLevel(input, levelDB);
            uim.Status.text = "Saved Level";

            if (uim.UIsave.transform.GetChild(0).GetChild(0).FindChild("UploadToggle").GetComponent <Toggle>().isOn)
            {
                AndroidDatabase androidDB = new AndroidDatabase();
                androidDB.cameraPosition = gm.cameraPlacementObject.transform.position;
                androidDB.objectScale    = gm.myGrid[0, 0].nVisualGrid.transform.localScale;
                List <string> myBundleA = new List <string>();
                foreach (Node n in gm.myGrid)
                {
                    if (n.nObjects.Count > 0)
                    {
                        AndroidNode androidNode = new AndroidNode();
                        for (int i = 0; i < n.nObjects.Count; i++)
                        {
                            androidNode.objectPositions.Add(n.nObjects[i].LObject.transform.position);
                            androidNode.objectRotations.Add(n.nObjects[i].LObject.transform.GetChild(0).transform.eulerAngles);
                            androidNode.objectIDs.Add(n.nObjects[i].LObject.name);
                            myBundleA.Add(n.nObjects[i].bundleName);
                        }
                        androidDB.aList.Add(androidNode);
                    }
                }
                androidDB.objectBundleNames = myBundle.Distinct().ToList();
                xmlm.UploadLevel(input, androidDB);
                uim.Status.text = "Saved Level\nUploading ..";
            }
            uim.CancelSaveScreen();
        }
    }