コード例 #1
0
    //function to load a previously generated and saved world.
    public void LoadWorld()
    {
        //Check too see whether the save file exists as for error correction.
        if (File.Exists(Application.persistentDataPath + "/saves/" + worldName + ".corSAV"))
        {
            BinaryFormatter bf       = new BinaryFormatter();                                                                        //Creates a new instance of a binary formatter to format the data back into the Save Structure class.
            FileStream      file     = File.Open(Application.persistentDataPath + "/saves/" + worldName + ".corSAV", FileMode.Open); //Creates a new file stream to the given save file
            SaveStructure   SaveData = (SaveStructure)bf.Deserialize(file);                                                          //converts the raw data back into the save structure class

            file.Close();                                                                                                            //Closes the filestream

            //Itteratuib through the 2d array
            for (int x = 0; x < mapWidth; x++)
            {
                for (int y = 0; y < mapHeight; y++)
                {
                    //Loads and places the tile at the given location.
                    map[x, y] = TileLoader(x, y, SaveData.map[x, y]);
                }
            }

            mainGameLoc = new Vector2(SaveData.mainGamePosX, SaveData.mainGamePosY);                                 //reads the current main game location from the save file.

            CurrentCamera.transform.position = new Vector3(SaveData.playerPositionX, SaveData.playerPositionY, -10); //gets the current camera location.
            nextCameraLoc = CurrentCamera.transform.position;                                                        //sets the camera location as the current camera location.
        }

        else
        {
            NewWorld(); //Calls new world if there is no world save present.
        }
    }
コード例 #2
0
    public void Load(SaveStructure st)
    {
        List <ClientIdea> clist = st.charactorList_Client;
        List <HunterIdea> hlist = st.charactorList_Hunter;

        charaList.Clear();
        expireCharaQue.Clear();
        visitedToday.Clear();
        for (int i = 0; i < clist.Count; i++)
        {
            clist[i].SetCharaSprite();
            charaList.Add(clist[i]);
        }
        for (int i = 0; i < hlist.Count; i++)
        {
            hlist[i].SetCharaSprite();

            if (hlist[i].DidRentalWeapon()) //무기를 빌린게 이으면 무기를 정보에 따라 뽑아 만듦.
            {
                for (int j = 0; j < hlist[i].RentalWeapon.Count; j++)
                {
                    Weapon weapon = WeaponInfoManager.GetInstance().CreateWeapon(
                        hlist[i].RentalWeapon[j].weaponType,
                        hlist[i].RentalWeapon[j].IsBroken());

                    hlist[i].RentalWeapon[j] = weapon;
                }
            }

            charaList.Add(hlist[i]);
        }
    }
コード例 #3
0
 public void Load(SaveStructure st)
 {
     mobOpen      = st.phaseMobOpen;
     evidenceOpen = st.phaseEvidenceOpen;
     upgradeOpen  = st.phaseUpgradeOpen;
     interiorOpen = st.phaseInteriorOpen;
     mobShowedUp  = st.phaseMobShowedUp;
 }
コード例 #4
0
    public Player GetPlayerData()
    {
        BinaryFormatter bf       = new BinaryFormatter();
        FileStream      file     = File.Open(Application.persistentDataPath + "/saves/" + GetLevelName() + ".corSAV", FileMode.Open);
        SaveStructure   SaveData = (SaveStructure)bf.Deserialize(file);

        file.Close();

        return(SaveData.playerData);
    }
コード例 #5
0
    public void Load(SaveStructure st)
    {
        maxThreatDic.Clear();
        MaxMonsterThreat mt = Resources.Load("Sheet/MaxMonsterThreat") as MaxMonsterThreat;

        for (int i = 0; i < mt.dataArray.Length; i++)
        {
            maxThreatDic.Add((E_Monster)mt.dataArray[i].Mob, mt.dataArray[i].Maxthreatnumber);
        }


        monsterRiskList     = st.threatState;
        huntersWhoHaveQuest = st.threatHunters;
    }
コード例 #6
0
    public static string Load()
    {
        if (File.Exists(filePath))
        {
            data     = File.ReadAllText(filePath);
            MainSave = JsonUtility.FromJson <SaveStructure>(data);
            print("File Read Successfully: " + data);
        }

        else
        {
            print("File Not Exist " + data);
        }

        return(data);
    }
コード例 #7
0
    public void saveNewData()
    {
        BinaryFormatter bf       = new BinaryFormatter();
        FileStream      file     = File.Open(Application.persistentDataPath + "/saves/" + worldName + ".corSAV", FileMode.Open);
        SaveStructure   SaveData = (SaveStructure)bf.Deserialize(file);

        file.Close();

        SaveData.playerData             = GetCurrentPlayerData();
        SaveData.playerDungeonPositionX = CurrentCamera.transform.position.x;
        SaveData.playerDungeonPositionY = CurrentCamera.transform.position.y;

        FileStream newFile = File.Open(Application.persistentDataPath + "/saves/" + worldName + ".corSAV", FileMode.Create);

        bf.Serialize(newFile, SaveData);
        newFile.Close();
    }
コード例 #8
0
    public void Load(SaveStructure st)
    {
        RenewMobEviInven(st.inventoryMobEvi);

        Dictionary <E_Weapon, int> weaponTemp = st.inventoryWeapon;

        weaponInventory = new List <weaponInven>();
        Dictionary <E_Weapon, int> .Enumerator enu = weaponTemp.GetEnumerator();
        while (enu.MoveNext())
        {
            weaponInventory.Add(
                new weaponInven(
                    WeaponInfoManager.GetInstance().CreateWeapon(enu.Current.Key),
                    enu.Current.Value
                    ));
        }
    }
コード例 #9
0
        /// <summary>
        ///     Charge les données dépuis le fichier Save.JSON
        /// </summary>
        public void LoadGameData(String fileName)
        {
            string filePath = Path.Combine(Application.persistentDataPath, fileName);

            if (File.Exists(filePath))
            {
                string dataAsJson = File.ReadAllText(filePath);
                saveStructure = JsonUtility.FromJson <SaveStructure>(dataAsJson);
                Debug.Log("données du fichier de sauvegarde chargé");
            }
            else
            {
                Debug.Log("pas de fichier de sauvegarde");
                totalCollectedItem      = 0;
                database.totalCollected = 0;
                database.score          = 0;
            }
        }
コード例 #10
0
 /// <summary>
 ///     Sauve les données dans le fichier Save.JSON
 /// </summary>
 public void SaveGameData(String fileName)
 {
     saveStructure = new SaveStructure();
     saveStructure.totalCollected = database.totalCollected;
     saveStructure.score          = database.score;
     string filePath = Path.Combine(Application.persistentDataPath, fileName);
     // if (File.Exists(filePath))
     {
         for (int i = 0; i < sceneCollectiblesDatabaseList.Count(); i++)
         {
             string SceneDataBaseListSerialized = JsonUtility.ToJson(database.SceneDataBaseList[i]);
             saveStructure.SceneDataBaseListSerialized[i] = SceneDataBaseListSerialized;
         }
         serializedSave = JsonUtility.ToJson(saveStructure);
         File.WriteAllText(filePath, serializedSave);
         Debug.Log("Sauvegarde fait dans" + filePath);
     }
 }
コード例 #11
0
    public void DeleteSavedGame()   //저장된 게임 지워버리기.
    {
#if UNITY_ANDROID
        st        = null;
        savedDate = null;
        savedGame = false;
        savedLang = E_Language.KOREAN;
        // if (!IsThereSavedGame()) return;

        if (false == PlayGamesPlatform.Instance.localUser.authenticated)
        {
            PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().EnableSavedGames().Build();
            PlayGamesPlatform.InitializeInstance(config);
            PlayGamesPlatform.DebugLogEnabled = true;
            PlayGamesPlatform.Activate();
            Social.localUser.Authenticate((bool success, string msg) =>
            {
                if (false == success)
                {
                    Debug.Log("딜리트 실패 - 로그인 불가");
                    //   return;
                }
            });
        }

        ISavedGameClient saveClient = PlayGamesPlatform.Instance.SavedGame;
        saveClient.OpenWithAutomaticConflictResolution(Constant.saveFileNameInGPGSCloud, DataSource.ReadCacheOrNetwork, ConflictResolutionStrategy.UseMostRecentlySaved, (status, metaData) =>
        {
            if (status != SavedGameRequestStatus.Success)
            {
                Debug.Log("삭제 실패 - 메타데이타 오픈 불가");
                // return;
            }
            else
            {
                saveClient.Delete(metaData);
            }
        });
        return;
#else
        File.Delete(Constant.saveDataAllPath);
#endif
    }
コード例 #12
0
        // Request is sent by the Save System
        public void OnSaveRequest(SaveGame saveGame)
        {
            if (cachedSaveGame != saveGame)
            {
                cachedSaveGame = saveGame;
            }

            if (string.IsNullOrEmpty(saveIdentification.Value))
            {
                return;
            }

            foreach (KeyValuePair <string, ISaveable> item in saveableComponentDictionary)
            {
                int getSavedIndex = -1;

                // Skip if the component does not want to be saved
                if (item.Value.OnSaveCondition() == false)
                {
                    continue;
                }

                SaveStructure saveStructure = new SaveStructure()
                {
                    identifier = item.Key,
                    data       = item.Value.OnSave()
                };

                // Does the array location for the identifier already exist? Then overwrite it instead.
                if (!iSaveableDataIdentifiers.TryGetValue(item.Key, out getSavedIndex))
                {
                    iSaveableData.saveStructures.Add(saveStructure);
                    iSaveableDataIdentifiers.Add(item.Key, iSaveableData.saveStructures.Count - 1);
                }
                else
                {
                    iSaveableData.saveStructures[getSavedIndex] = saveStructure;
                }
            }

            saveGame.Set(saveIdentification.Value, JsonUtility.ToJson(iSaveableData));
        }
コード例 #13
0
    void Start()
    {
        filePath   = Application.dataPath + "/LocalSave" + "/" + "Save" + ".json";
        folderPath = Application.dataPath + "/LocalSave";

        if (!Directory.Exists(folderPath)) //se a pasta não existir, será criada uma nova pasta
        {
            Directory.CreateDirectory(folderPath);
        }

        if (!File.Exists(filePath)) //se o arquivo de save não existir, será criado
        {
            MainSave.maximunScore = 0;
            Save();
        }

        else
        {
            MainSave = JsonUtility.FromJson <SaveStructure>(Load());
        }
    }
コード例 #14
0
    //function to save the current world state.
    public void SaveWorld()
    {
        //error correction in the case of there being no worldName.
        if (worldName == "")
        {
            worldName = "autosave";
        }

        System.IO.Directory.CreateDirectory(Application.persistentDataPath + "/saves"); //making sure that the saves directory does exist.

        BinaryFormatter bf   = new BinaryFormatter();                                   //Creates a new instance of the binary formatter
        FileStream      file = File.Open(Application.persistentDataPath + "/saves/" + worldName + ".corSAV", FileMode.Create);

        SaveStructure SaveData = new SaveStructure();

        SaveData.worldName       = worldName;
        SaveData.playerPositionX = CurrentCamera.transform.position.x;
        SaveData.playerPositionY = CurrentCamera.transform.position.y;

        SaveData.mainGamePosX = (int)mainGameLoc.x;
        SaveData.mainGamePosY = (int)mainGameLoc.y;

        SaveData.playerDungeonPositionX = 0f;
        SaveData.playerDungeonPositionY = 0f;

        SaveData.map = new string[mapWidth, mapHeight];

        for (int x = 0; x < mapWidth; x++)
        {
            for (int y = 0; y < mapWidth; y++)
            {
                SaveData.map[x, y] = map[x, y].ToString();
            }
        }

        SaveData.playerData = GetCurrentPlayerData();

        bf.Serialize(file, SaveData);
        file.Close();
    }
コード例 #15
0
    public void Load(SaveStructure st)
    {
        Dictionary <string, Quest> savedMg = st.questDic;

        questMg = savedMg;
    }
コード例 #16
0
 public void Load(SaveStructure st)
 {
     mainTime = st.savedDate;
 }
コード例 #17
0
 public void Load(SaveStructure st)
 {
     this.distributedNames = st.distributedNames;
 }
コード例 #18
0
    public E_Language GetSavedGameLang()//저장된 게임의 세이브 데이터 날짜를 가져오기.
    {
#if UNITY_ANDROID
        if (!savedGame || st == null)
        {
            Debug.Log("랭귀지를 읽어올 수 없음");
            return(E_Language.KOREAN);
        }
        else
        {
            return(savedLang);
        }


        /*
         * if (!IsThereSavedGame()) return E_Language.KOREAN;
         *
         * if (false == PlayGamesPlatform.Instance.localUser.authenticated)
         * {
         *  PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().EnableSavedGames().Build();
         *  PlayGamesPlatform.InitializeInstance(config);
         *  PlayGamesPlatform.DebugLogEnabled = true;
         *  PlayGamesPlatform.Activate();
         *  Social.localUser.Authenticate((bool success, string msg) =>
         *  {
         *      if (false == success)
         *      {
         *          Debug.Log("겟 랭귀지 실패 - 로그인 불가");
         *          return;
         *      }
         *  });
         * }
         * ISavedGameClient saveClient = PlayGamesPlatform.Instance.SavedGame;
         * E_Language savedLang = E_Language.KOREAN;
         *
         * saveClient.OpenWithAutomaticConflictResolution(Constant.saveFileNameInGPGSCloud, DataSource.ReadCacheOrNetwork, ConflictResolutionStrategy.UseMostRecentlySaved, (status, metaData) =>
         * {
         *  if (status != SavedGameRequestStatus.Success)
         *  {
         *      Debug.Log("로드 실패 - 메타데이타 오픈 불가");
         *      //   return;
         *  }
         *  else
         *  {
         *      saveClient.ReadBinaryData(metaData, (readStatus, savedData) =>
         *      {
         *          if (readStatus == SavedGameRequestStatus.Success)
         *          {
         *              byte[] savedDataByteArr = savedData;
         *              SaveStructure st;
         *              BinaryFormatter bt = new BinaryFormatter();
         *              MemoryStream ms = new MemoryStream(savedDataByteArr);
         *              st = bt.Deserialize(ms) as SaveStructure;
         *              ms.Dispose();
         *              ms.Close();
         *              savedLang = st.lang;
         *          }
         *      });
         *  }
         * });
         *
         * return savedLang;
         */
#else
        if (IsThereSavedGame())
        {
            SaveStructure   st   = null;
            BinaryFormatter bt   = new BinaryFormatter();
            FileStream      file = File.Open(Constant.saveDataAllPath, FileMode.Open);

            if (file != null && file.Length > 0)
            {
                st = bt.Deserialize(file) as SaveStructure;
                file.Close();
                if (st == null)
                {
                    Debug.Log("겟 세이브드 데이트 - 저장 파일이 없음.");
                    return(E_Language.KOREAN);
                }
                return(st.lang);
            }
            else
            {
                file.Close();
                Debug.Log("겟 세이브드 데이트 - 저장 파일이 없음.");
                return(E_Language.KOREAN);
            }
        }

        else
        {
            return(E_Language.KOREAN);
        }
#endif
    }
コード例 #19
0
    public InGameTime GetSavedDate()//저장된 게임의 세이브 데이터 날짜를 가져오기.
    {
#if UNITY_ANDROID
        if (st == null || !savedGame)
        {
            Debug.Log("겟세이브드데이트 - 세이브 데이타가 존재하지 않음 또는 " + savedGame);
            return(null);
        }
        Debug.Log("겟세이브드데이트 반환" + savedDate);
        return(savedDate);

        /*
         * if (!IsThereSavedGame()) return null;
         *
         * if (false == PlayGamesPlatform.Instance.localUser.authenticated)
         * {
         *  PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().EnableSavedGames().Build();
         *  PlayGamesPlatform.InitializeInstance(config);
         *  PlayGamesPlatform.DebugLogEnabled = true;
         *  PlayGamesPlatform.Activate();
         *  Social.localUser.Authenticate((bool success, string msg) =>
         *  {
         *      if (false == success)
         *      {
         *          Debug.Log("겟데이트 실패 - 로그인 불가");
         *          return;
         *      }
         *  });
         * }
         * ISavedGameClient saveClient = PlayGamesPlatform.Instance.SavedGame;
         * InGameTime savedDate = null;
         * Debug.Log("세이브 있고, 지금 날짜 받으러 왔어.");
         *
         * saveClient.OpenWithAutomaticConflictResolution(Constant.saveFileNameInGPGSCloud, DataSource.ReadCacheOrNetwork, ConflictResolutionStrategy.UseMostRecentlySaved, (status, metaData) =>
         * {
         *  if (status != SavedGameRequestStatus.Success)
         *  {
         *      Debug.Log("날짜 로드 실패 - 메타데이타 오픈 불가");
         *      return;
         *  }
         *  saveClient.ReadBinaryData(metaData, (readStatus, savedData) =>
         *  {
         *      if (readStatus == SavedGameRequestStatus.Success)
         *      {
         *          byte[] savedDataByteArr = savedData;
         *          Debug.Log("날짜 로드 스테이터스는 성공, 저장된 바이트 렝쓰 = "+ savedDataByteArr.Length);
         *
         *          SaveStructure st;
         *          BinaryFormatter bt = new BinaryFormatter();
         *          MemoryStream ms = new MemoryStream(savedDataByteArr);
         *          st = bt.Deserialize(ms) as SaveStructure;
         *
         *          savedDate = st.savedDate;
         *          Debug.Log("날짜 뽑기 위해 디시리얼라이즈도 했고,  그 날짜는" + savedDate);
         *          ms.Dispose();
         *          ms.Close();
         *      }
         *  });
         * });
         * Debug.Log("최종 반환 날짜는" + savedDate);
         * return savedDate;
         *
         */
#else
        if (IsThereSavedGame())
        {
            SaveStructure   st   = null;
            BinaryFormatter bt   = new BinaryFormatter();
            FileStream      file = File.Open(Constant.saveDataAllPath, FileMode.Open);

            if (file != null && file.Length > 0)
            {
                st = bt.Deserialize(file) as SaveStructure;
                file.Close();
                if (st == null)
                {
                    Debug.Log("겟 세이브드 데이트 - 저장 파일이 없음.");
                    return(null);
                }
                return(st.savedDate);
            }
            else
            {
                file.Close();
                Debug.Log("겟 세이브드 데이트 - 저장 파일이 없음.");
                return(null);
            }
        }

        else
        {
            return(null);
        }
#endif
    }
コード例 #20
0
    public void Init()
    {
        if (false == PlayGamesPlatform.Instance.localUser.authenticated)
        {
            PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().EnableSavedGames().Build();
            PlayGamesPlatform.InitializeInstance(config);
            PlayGamesPlatform.DebugLogEnabled = true;
            PlayGamesPlatform.Activate();
            Social.localUser.Authenticate((bool success, string msg) =>
            {
                if (false == success)
                {
                    Debug.Log(" 실패 - 로그인 불가");
                    return;
                }
            });
        }
        st        = null;
        savedGame = false;
        savedDate = null;
        savedLang = E_Language.ENGLISH;


        ISavedGameClient saveClient = PlayGamesPlatform.Instance.SavedGame;
        object           n          = new object();

        lock (n)
        {
            saveClient.OpenWithAutomaticConflictResolution(Constant.saveFileNameInGPGSCloud, DataSource.ReadCacheOrNetwork, ConflictResolutionStrategy.UseMostRecentlySaved, (status, metaData) =>
            {
                if (status == SavedGameRequestStatus.Success)
                {
                    Debug.Log("세이브매니저 이닛 - 게임 오픈 성공");
                    saveClient.ReadBinaryData(metaData, (readStatus, savedByteArr) =>
                    {
                        if (readStatus == SavedGameRequestStatus.Success)
                        {
                            Debug.Log("세이브매니저 이닛 - 게임 읽어오기 성공");
                            if (savedByteArr.Length == 0)
                            {
                                Debug.Log("세이브매니저 이닛 - 게임 읽어오기 성공 - 바이트 데이타 길이가 0 이라서 빠져나감.");
                                savedGame = false;
                                savedDate = null;
                                savedLang = E_Language.ENGLISH;
                                GameManager.GetInstance().SendMessage("saveInitDone");
                                return;
                            }
                            BinaryFormatter bt = new BinaryFormatter();
                            MemoryStream ms    = new MemoryStream(savedByteArr);
                            st = bt.Deserialize(ms) as SaveStructure;
                            if (st != null)
                            {
                                savedGame = true;
                                savedDate = InGameTime.DeepCopy(st.savedDate);
                                savedLang = st.lang;
                                Debug.Log("세이브매니저 이닛 - 게임 읽어오기 저장한 애 읽어오기 까지 성공 저장날짜=" + savedDate + "저장 언어" + savedLang);
                                GameManager.GetInstance().SendMessage("saveInitDone");
                            }
                            else
                            {
                                Debug.Log("세이브매니저 이닛 - 게임 읽어오기 저장한 애 읽어오기에서 실패");
                                savedGame = false;
                                savedDate = null;
                                savedLang = E_Language.ENGLISH;
                                GameManager.GetInstance().SendMessage("saveInitDone");
                            }
                            ms.Dispose();
                            ms.Close();
                        }
                        else
                        {
                            savedGame = false;
                            savedDate = null;
                            savedLang = E_Language.ENGLISH;
                            Debug.Log("세이브매니저 이닛 - 게임 읽어오기자체가 실패");
                            GameManager.GetInstance().SendMessage("saveInitDone");
                        }
                    });
                }
            });
        }
    }
コード例 #21
0
    public bool LoadGame()  //이닛 후에 불려져야함.
    {
#if UNITY_ANDROID
        if (st == null || !savedGame)
        {
            Debug.Log("로드게임 - 세이브 데이타가 존재하지 않음 또는 " + savedGame);
            return(false);
        }


        if (false == PlayGamesPlatform.Instance.localUser.authenticated)
        {
            PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().EnableSavedGames().Build();
            PlayGamesPlatform.InitializeInstance(config);
            PlayGamesPlatform.DebugLogEnabled = true;
            PlayGamesPlatform.Activate();
            Social.localUser.Authenticate((bool success, string msg) =>
            {
                if (false == success)
                {
                    Debug.Log("로드 실패 - 로그인 불가");
                    return;
                }
            });
        }
        ISavedGameClient saveClient = PlayGamesPlatform.Instance.SavedGame;
        saveClient.OpenWithAutomaticConflictResolution(Constant.saveFileNameInGPGSCloud, DataSource.ReadCacheOrNetwork, ConflictResolutionStrategy.UseMostRecentlySaved, (status, metaData) =>
        {
            if (status != SavedGameRequestStatus.Success)
            {
                Debug.Log("로드 실패 - 메타데이타 오픈 불가");
                return;
            }
            saveClient.ReadBinaryData(metaData, (readStatus, savedData) =>
            {
                if (readStatus == SavedGameRequestStatus.Success)
                {
                    Debug.Log("바이너리 데이타 리드 읽기 성공!");
                    byte[] savedDataByteArr = savedData;

                    BinaryFormatter bt = new BinaryFormatter();
                    MemoryStream ms    = new MemoryStream(savedDataByteArr);
                    st = bt.Deserialize(ms) as SaveStructure;
                    ms.Dispose();
                    ms.Close();

                    if (st == null)
                    {
                        Debug.Log("리드는 했으나 스트럭쳐가 널임.");
                    }
                }
                else
                {
                    Debug.Log("바이너리 데이타 리드 읽기 실패!");
                    saveClient.ShowSelectSavedGameUI("리드가 안됨.", 5, false, false, (stq, md) => { });
                }
            });
        });
        if (st == null)
        {
            Debug.Log("리드 실패");
            return(false);
        }
#else
        BinaryFormatter bt   = new BinaryFormatter();
        FileStream      file = File.Open(Constant.saveDataAllPath, FileMode.Open);

        if (file != null && file.Length > 0)
        {
            st = bt.Deserialize(file) as SaveStructure;
            file.Close();
            if (st == null)
            {
                Debug.Log("파일이 없음.");
                return(false);
            }
        }
        else
        {
            file.Close();
            return(false);
        }
#endif
        Debug.Log("로드 게임");
        //  LanguageManager.GetInstance().SetLanguage(st.lang);   언어설정은 새로 할 수 있게.
        GoldManager.GetInstance().SetGold(st.golds);
        GameEndJudgeManager.GetInstance().Load(st);
        InGameTimeManager.GetInstance().Load(st);
        CharactorManager.GetInstance().Load(st);
        QuestManager.GetInstance().Load(st);
        Inventory.GetInstance().Load(st);
        WholeMonsterRiskManager.GetInstance().Load(st);
        PhaseManager.GetInstance().Load(st);
        TextManager.GetInstance().Load(st);

        return(true);
    }
コード例 #22
0
    public void SaveGame()
    {
        SaveStructure saveST = new SaveStructure();

        saveST.SavePrepare();
#if UNITY_ANDROID
        if (false == PlayGamesPlatform.Instance.localUser.authenticated)
        {
            PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().EnableSavedGames().Build();
            PlayGamesPlatform.InitializeInstance(config);
            PlayGamesPlatform.DebugLogEnabled = true;
            PlayGamesPlatform.Activate();
            Social.localUser.Authenticate((bool success, string msg) =>
            {
                if (false == success)
                {
                    Debug.Log("저장 실패 - 로그인 불가");
                    return;
                }
            });
        }
        Debug.Log("로그인 돼있음");
        BinaryFormatter bt = new BinaryFormatter();
        MemoryStream    ms = new MemoryStream();
        bt.Serialize(ms, saveST);
        byte[] savingData = ms.ToArray();
        Debug.Log("시리얼라이즈 - 현재 세이빙 데이타 랭쓰" + savingData.Length);
        ms.Dispose();
        ms.Close();
        Debug.Log("시리얼라이즈 완료 , 스트림 클로즈 후 " + savingData.Length);
        ISavedGameClient saveClient = PlayGamesPlatform.Instance.SavedGame;


        saveClient.OpenWithAutomaticConflictResolution(Constant.saveFileNameInGPGSCloud, DataSource.ReadCacheOrNetwork, ConflictResolutionStrategy.UseMostRecentlySaved, (status, metaData) =>
        {
            if (status != SavedGameRequestStatus.Success)
            {
                Debug.Log("저장 실패 - 메타데이타 오픈 불가");
                return;
            }
            Debug.Log("메타데이타 오픈.");

            SavedGameMetadataUpdate updatedMetaData = new SavedGameMetadataUpdate.Builder().WithUpdatedDescription(DateTime.Now + "at saved").Build();
            Debug.Log("저장 준비- 현재 세이빙데이타 렝쓰 " + savingData.Length);
            saveClient.CommitUpdate(metaData, updatedMetaData, savingData, (saveStatus, newMetaData) =>
            {
                if (status != SavedGameRequestStatus.Success)
                {
                    Debug.Log("저장 실패 - 저장이 불가");
                    //    return;
                }
                else
                {
                    st        = saveST;
                    savedLang = saveST.lang;
                    savedGame = true;
                    savedDate = InGameTime.DeepCopy(saveST.savedDate);
                    Debug.Log("저장 성공");
                }
            });
        });
#else
        BinaryFormatter bt   = new BinaryFormatter();
        FileStream      file = File.Create(Constant.saveDataAllPath);
        bt.Serialize(file, saveST);
        file.Close();
#endif
    }
コード例 #23
0
    IEnumerator SaveInfoAPI()
    {
        if (mc.uinfo.patient_temp.tests[0].valid)
        {
            yield return(StartCoroutine("TokenRequestAPI"));

            List <IMultipartFormSection> formData = new List <IMultipartFormSection>();
            formData.Add(new MultipartFormDataSection("token", token));
            formData.Add(new MultipartFormDataSection("partner", partner));//

            Debug.Log("paciente[nombre]: " + mc.uinfo.patient_temp.PatientName +
                      "\npaciente[nif]: " + mc.uinfo.patient_temp.PatientDNI +
                      "\nmedico[nombre]: " + mc.uinfo.userName +
                      "\nmedico[referencia]: " + mc.uinfo.docCode +
                      "\ntest[igm]: " + mc.uinfo.patient_temp.tests[0].Result_igm +
                      "\ntest[igg]: " + mc.uinfo.patient_temp.tests[0].Result_igg);
            formData.Add(new MultipartFormDataSection("paciente[nombre]", mc.uinfo.patient_Info.PatientName + AddDemoEnding()));
            formData.Add(new MultipartFormDataSection("paciente[nif]", mc.uinfo.patient_Info.PatientDNI + AddDemoEnding()));
            formData.Add(new MultipartFormDataSection("paciente[email]", mc.uinfo.patient_Info.PatientEmail + AddDemoEnding()));
            formData.Add(new MultipartFormDataSection("paciente[telefono]", mc.uinfo.patient_Info.PatientPhone + AddDemoEnding()));

            formData.Add(new MultipartFormDataSection("medico[nombre]", mc.uinfo.userName + AddDemoEnding()));
            switch (mc.uinfo.userT)
            {
            case MainController.userType.Lab:
                formData.Add(new MultipartFormDataSection("medico[referencia]", mc.uinfo.LabNICA + AddDemoEnding()));
                break;

            case MainController.userType.Doctor:
                formData.Add(new MultipartFormDataSection("medico[nif]", mc.uinfo.userDNI + AddDemoEnding()));
                formData.Add(new MultipartFormDataSection("medico[referencia]", mc.uinfo.docCode + AddDemoEnding()));
                break;

            case MainController.userType.Hospital:
                formData.Add(new MultipartFormDataSection("medico[nombre]", mc.uinfo.hospitalName + AddDemoEnding()));
                formData.Add(new MultipartFormDataSection("medico[nif]", mc.uinfo.DSACode + AddDemoEnding()));
                break;

            default:
                break;
            }

            if (mc.uinfo.patient_temp.PatientCountry == null || mc.uinfo.patient_temp.PatientCountry == "")
            {
                formData.Add(new MultipartFormDataSection("test[pais]", "USA"));
            }
            else
            {
                formData.Add(new MultipartFormDataSection("test[pais]", mc.uinfo.patient_temp.PatientCountry));
            }

            formData.Add(new MultipartFormDataSection("test[asintomatico]", mc.uinfo.patient_Info.Sintomatic));

            //formData.Add(new MultipartFormDataSection("test[fecha]", DateTime.Today.ToShortDateString()));//
            formData.Add(new MultipartFormDataSection("test[tipo]", "RAPIDO"));//Posibles valores: PCR, RAPIDO, ELISA

            formData.Add(new MultipartFormDataSection("test[igm]", mc.uinfo.patient_temp.tests[0].Result_igm));
            formData.Add(new MultipartFormDataSection("test[igg]", mc.uinfo.patient_temp.tests[0].Result_igg));



            UnityWebRequest www = UnityWebRequest.Post("https://app.immunitypass.es/save", formData);
            yield return(www.SendWebRequest());

            if (www.isNetworkError)
            {
                Debug.Log(www.error);
            }
            else
            {
                SaveStructure response = SaveStructure.CreateFromJSON(www.downloadHandler.text);
                if (response.success == "false")
                {
                    Debug.Log("Error API: " + response.error.message);
                }
                url = response.payload.url;
                Debug.Log("Save Form upload complete!");

                uic.GenerateQR(url);
            }
        }
        if (mc.uinfo.patient_temp.tests[1].valid)
        {
            yield return(StartCoroutine("TokenRequestAPI"));

            List <IMultipartFormSection> formData = new List <IMultipartFormSection>();
            formData.Add(new MultipartFormDataSection("token", token));
            formData.Add(new MultipartFormDataSection("partner", partner));//

            formData.Add(new MultipartFormDataSection("paciente[nombre]", mc.uinfo.patient_Info.PatientName + AddDemoEnding()));
            formData.Add(new MultipartFormDataSection("paciente[nif]", mc.uinfo.patient_Info.PatientDNI + AddDemoEnding()));
            formData.Add(new MultipartFormDataSection("paciente[email]", mc.uinfo.patient_Info.PatientEmail + AddDemoEnding()));
            formData.Add(new MultipartFormDataSection("paciente[telefono]", mc.uinfo.patient_Info.PatientPhone + AddDemoEnding()));

            formData.Add(new MultipartFormDataSection("medico[nombre]", mc.uinfo.userName + AddDemoEnding()));
            switch (mc.uinfo.userT)
            {
            case MainController.userType.Lab:
                formData.Add(new MultipartFormDataSection("medico[referencia]", mc.uinfo.LabNICA + AddDemoEnding()));
                break;

            case MainController.userType.Doctor:
                formData.Add(new MultipartFormDataSection("medico[nif]", mc.uinfo.userDNI + AddDemoEnding()));
                formData.Add(new MultipartFormDataSection("medico[referencia]", mc.uinfo.docCode + AddDemoEnding()));
                break;

            case MainController.userType.Hospital:
                formData.Add(new MultipartFormDataSection("medico[nombre]", mc.uinfo.hospitalName + AddDemoEnding()));
                formData.Add(new MultipartFormDataSection("medico[nif]", mc.uinfo.DSACode + AddDemoEnding()));
                break;

            default:
                break;
            }

            if (mc.uinfo.patient_temp.PatientCountry == null || mc.uinfo.patient_temp.PatientCountry == "")
            {
                formData.Add(new MultipartFormDataSection("test[pais]", "USA"));
            }
            else
            {
                formData.Add(new MultipartFormDataSection("test[pais]", mc.uinfo.patient_temp.PatientCountry));
            }

            formData.Add(new MultipartFormDataSection("test[asintomatico]", mc.uinfo.patient_Info.Sintomatic));

            //formData.Add(new MultipartFormDataSection("test[fecha]", DateTime.Today.ToShortDateString()));//
            formData.Add(new MultipartFormDataSection("test[tipo]", "PCR"));//Posibles valores: PCR, RAPIDO, ELISA
            formData.Add(new MultipartFormDataSection("test[resultado]", mc.uinfo.patient_temp.tests[1].testResult));



            UnityWebRequest www = UnityWebRequest.Post("https://app.immunitypass.es/save", formData);
            yield return(www.SendWebRequest());

            if (www.isNetworkError)
            {
                Debug.Log(www.error);
            }
            else
            {
                SaveStructure response = SaveStructure.CreateFromJSON(www.downloadHandler.text);
                url = response.payload.url;
                Debug.Log("Save Form upload complete!");

                uic.GenerateQR(url);
            }
        }
        if (mc.uinfo.patient_temp.tests[2].valid)
        {
            yield return(StartCoroutine("TokenRequestAPI"));

            List <IMultipartFormSection> formData = new List <IMultipartFormSection>();
            formData.Add(new MultipartFormDataSection("token", token));
            formData.Add(new MultipartFormDataSection("partner", partner));//

            formData.Add(new MultipartFormDataSection("paciente[nombre]", mc.uinfo.patient_Info.PatientName + AddDemoEnding()));
            formData.Add(new MultipartFormDataSection("paciente[nif]", mc.uinfo.patient_Info.PatientDNI + AddDemoEnding()));
            formData.Add(new MultipartFormDataSection("paciente[email]", mc.uinfo.patient_Info.PatientEmail + AddDemoEnding()));
            formData.Add(new MultipartFormDataSection("paciente[telefono]", mc.uinfo.patient_Info.PatientPhone + AddDemoEnding()));

            formData.Add(new MultipartFormDataSection("medico[nombre]", mc.uinfo.userName + AddDemoEnding()));
            switch (mc.uinfo.userT)
            {
            case MainController.userType.Lab:
                formData.Add(new MultipartFormDataSection("medico[referencia]", mc.uinfo.LabNICA + AddDemoEnding()));
                break;

            case MainController.userType.Doctor:
                formData.Add(new MultipartFormDataSection("medico[nif]", mc.uinfo.userDNI + AddDemoEnding()));
                formData.Add(new MultipartFormDataSection("medico[referencia]", mc.uinfo.docCode + AddDemoEnding()));
                break;

            case MainController.userType.Hospital:
                formData.Add(new MultipartFormDataSection("medico[nombre]", mc.uinfo.hospitalName + AddDemoEnding()));
                formData.Add(new MultipartFormDataSection("medico[nif]", mc.uinfo.DSACode + AddDemoEnding()));
                break;

            default:
                break;
            }

            if (mc.uinfo.patient_temp.PatientCountry == null || mc.uinfo.patient_temp.PatientCountry == "")
            {
                formData.Add(new MultipartFormDataSection("test[pais]", "USA"));
            }
            else
            {
                formData.Add(new MultipartFormDataSection("test[pais]", mc.uinfo.patient_temp.PatientCountry));
            }

            formData.Add(new MultipartFormDataSection("test[asintomatico]", mc.uinfo.patient_Info.Sintomatic));

            formData.Add(new MultipartFormDataSection("test[tipo]", "ELISA"));//Posibles valores: PCR, RAPIDO, ELISA

            formData.Add(new MultipartFormDataSection("test[igm]", mc.uinfo.patient_temp.tests[2].Result_igm));
            formData.Add(new MultipartFormDataSection("test[igg]", mc.uinfo.patient_temp.tests[2].Result_igg));

            formData.Add(new MultipartFormDataSection("test[valor_igm]", mc.uinfo.patient_temp.tests[2].Valor_igm));
            formData.Add(new MultipartFormDataSection("test[valor_igg]", mc.uinfo.patient_temp.tests[2].Valor_igg));



            UnityWebRequest www = UnityWebRequest.Post("https://app.immunitypass.es/save", formData);
            yield return(www.SendWebRequest());

            if (www.isNetworkError)
            {
                Debug.Log(www.error);
            }
            else
            {
                SaveStructure response = SaveStructure.CreateFromJSON(www.downloadHandler.text);
                url = response.payload.url;
                Debug.Log("Save Form upload complete!");

                uic.GenerateQR(url);
            }
        }
        if (mc.uinfo.patient_temp.tests[3].valid)
        {
            yield return(StartCoroutine("TokenRequestAPI"));

            List <IMultipartFormSection> formData = new List <IMultipartFormSection>();
            formData.Add(new MultipartFormDataSection("token", token));
            formData.Add(new MultipartFormDataSection("partner", partner));//

            formData.Add(new MultipartFormDataSection("paciente[nombre]", mc.uinfo.patient_Info.PatientName + AddDemoEnding()));
            formData.Add(new MultipartFormDataSection("paciente[nif]", mc.uinfo.patient_Info.PatientDNI + AddDemoEnding()));
            formData.Add(new MultipartFormDataSection("paciente[email]", mc.uinfo.patient_Info.PatientEmail + AddDemoEnding()));
            formData.Add(new MultipartFormDataSection("paciente[telefono]", mc.uinfo.patient_Info.PatientPhone + AddDemoEnding()));

            formData.Add(new MultipartFormDataSection("medico[nombre]", mc.uinfo.userName + AddDemoEnding()));
            switch (mc.uinfo.userT)
            {
            case MainController.userType.Lab:
                formData.Add(new MultipartFormDataSection("medico[referencia]", mc.uinfo.LabNICA + AddDemoEnding()));
                break;

            case MainController.userType.Doctor:
                formData.Add(new MultipartFormDataSection("medico[nif]", mc.uinfo.userDNI + AddDemoEnding()));
                formData.Add(new MultipartFormDataSection("medico[referencia]", mc.uinfo.docCode + AddDemoEnding()));
                break;

            case MainController.userType.Hospital:
                formData.Add(new MultipartFormDataSection("medico[nombre]", mc.uinfo.hospitalName + AddDemoEnding()));
                formData.Add(new MultipartFormDataSection("medico[nif]", mc.uinfo.DSACode + AddDemoEnding()));
                break;

            default:
                break;
            }

            if (mc.uinfo.patient_temp.PatientCountry == null || mc.uinfo.patient_temp.PatientCountry == "")
            {
                formData.Add(new MultipartFormDataSection("test[pais]", "USA"));
            }
            else
            {
                formData.Add(new MultipartFormDataSection("test[pais]", mc.uinfo.patient_temp.PatientCountry));
            }

            formData.Add(new MultipartFormDataSection("test[asintomatico]", mc.uinfo.patient_Info.Sintomatic));

            //formData.Add(new MultipartFormDataSection("test[fecha]", DateTime.Today.ToShortDateString()));//
            formData.Add(new MultipartFormDataSection("test[tipo]", "ANTIGENOS"));//Posibles valores: PCR, RAPIDO, ELISA
            formData.Add(new MultipartFormDataSection("test[resultado]", mc.uinfo.patient_temp.tests[3].testResult));



            UnityWebRequest www = UnityWebRequest.Post("https://app.immunitypass.es/save", formData);
            yield return(www.SendWebRequest());

            if (www.isNetworkError)
            {
                Debug.Log(www.error);
            }
            else
            {
                SaveStructure response = SaveStructure.CreateFromJSON(www.downloadHandler.text);
                url = response.payload.url;
                Debug.Log("Save Form upload complete!");

                uic.GenerateQR(url);
            }
        }
        if (mc.uinfo.patient_temp.tests[4].valid)
        {
            yield return(StartCoroutine("TokenRequestAPI"));

            List <IMultipartFormSection> formData = new List <IMultipartFormSection>();
            formData.Add(new MultipartFormDataSection("token", token));
            formData.Add(new MultipartFormDataSection("partner", partner));//

            Debug.Log("paciente[nombre]: " + mc.uinfo.patient_temp.PatientName +
                      "\npaciente[nif]: " + mc.uinfo.patient_temp.PatientDNI +
                      "\nmedico[nombre]: " + mc.uinfo.userName +
                      "\nmedico[referencia]: " + mc.uinfo.docCode +
                      "\ntest[igm]: " + mc.uinfo.patient_temp.tests[4].Result_igm +
                      "\ntest[igg]: " + mc.uinfo.patient_temp.tests[4].Result_igg);
            formData.Add(new MultipartFormDataSection("paciente[nombre]", mc.uinfo.patient_Info.PatientName + AddDemoEnding()));
            formData.Add(new MultipartFormDataSection("paciente[nif]", mc.uinfo.patient_Info.PatientDNI + AddDemoEnding()));
            formData.Add(new MultipartFormDataSection("paciente[email]", mc.uinfo.patient_Info.PatientEmail + AddDemoEnding()));
            formData.Add(new MultipartFormDataSection("paciente[telefono]", mc.uinfo.patient_Info.PatientPhone + AddDemoEnding()));

            formData.Add(new MultipartFormDataSection("medico[nombre]", mc.uinfo.userName + AddDemoEnding()));
            switch (mc.uinfo.userT)
            {
            case MainController.userType.Lab:
                formData.Add(new MultipartFormDataSection("medico[referencia]", mc.uinfo.LabNICA + AddDemoEnding()));
                break;

            case MainController.userType.Doctor:
                formData.Add(new MultipartFormDataSection("medico[nif]", mc.uinfo.userDNI + AddDemoEnding()));
                formData.Add(new MultipartFormDataSection("medico[referencia]", mc.uinfo.docCode + AddDemoEnding()));
                break;

            case MainController.userType.Hospital:
                formData.Add(new MultipartFormDataSection("medico[nombre]", mc.uinfo.hospitalName + AddDemoEnding()));
                formData.Add(new MultipartFormDataSection("medico[nif]", mc.uinfo.DSACode + AddDemoEnding()));
                break;

            default:
                break;
            }


            if (mc.uinfo.patient_temp.PatientCountry == null || mc.uinfo.patient_temp.PatientCountry == "")
            {
                formData.Add(new MultipartFormDataSection("test[pais]", "USA"));
            }
            else
            {
                formData.Add(new MultipartFormDataSection("test[pais]", mc.uinfo.patient_temp.PatientCountry));
            }

            formData.Add(new MultipartFormDataSection("test[asintomatico]", mc.uinfo.patient_Info.Sintomatic));

            //formData.Add(new MultipartFormDataSection("test[fecha]", DateTime.Today.ToShortDateString()));//
            formData.Add(new MultipartFormDataSection("test[tipo]", "INMUNOCROMA"));//Posibles valores: PCR, RAPIDO, ELISA

            formData.Add(new MultipartFormDataSection("test[igm]", mc.uinfo.patient_temp.tests[4].Result_igm));
            formData.Add(new MultipartFormDataSection("test[igg]", mc.uinfo.patient_temp.tests[4].Result_igg));



            UnityWebRequest www = UnityWebRequest.Post("https://app.immunitypass.es/save", formData);
            yield return(www.SendWebRequest());

            if (www.isNetworkError)
            {
                Debug.Log(www.error);
            }
            else
            {
                SaveStructure response = SaveStructure.CreateFromJSON(www.downloadHandler.text);
                if (response.success == "false")
                {
                    Debug.Log("Error API: " + response.error.message);
                }
                url = response.payload.url;
                Debug.Log("Save Form upload complete!");

                uic.GenerateQR(url);
            }
        }
        if (mc.uinfo.patient_temp.tests[5].valid) // DSA
        {
            yield return(StartCoroutine("TokenRequestAPI"));

            List <IMultipartFormSection> formData = new List <IMultipartFormSection>();
            formData.Add(new MultipartFormDataSection("token", token));
            formData.Add(new MultipartFormDataSection("partner", partner));

            formData.Add(new MultipartFormDataSection("paciente[nombre]", mc.uinfo.patient_Info.PatientName + AddDemoEnding()));
            formData.Add(new MultipartFormDataSection("paciente[nif]", mc.uinfo.patient_Info.PatientDNI + AddDemoEnding()));
            formData.Add(new MultipartFormDataSection("paciente[email]", mc.uinfo.patient_Info.PatientEmail + AddDemoEnding()));
            formData.Add(new MultipartFormDataSection("paciente[telefono]", mc.uinfo.patient_Info.PatientPhone + AddDemoEnding()));

            if (mc.uinfo.patient_temp.PatientCountry == null || mc.uinfo.patient_temp.PatientCountry == "")
            {
                formData.Add(new MultipartFormDataSection("test[pais]", "USA"));
            }
            else
            {
                formData.Add(new MultipartFormDataSection("test[pais]", mc.uinfo.patient_temp.PatientCountry));
            }

            switch (mc.uinfo.userT)
            {
            case MainController.userType.Lab:
                formData.Add(new MultipartFormDataSection("medico[nombre]", mc.uinfo.userName + AddDemoEnding()));
                formData.Add(new MultipartFormDataSection("medico[referencia]", mc.uinfo.LabNICA + AddDemoEnding()));
                break;

            case MainController.userType.Doctor:
                formData.Add(new MultipartFormDataSection("medico[nombre]", mc.uinfo.userName + AddDemoEnding()));
                formData.Add(new MultipartFormDataSection("medico[nif]", mc.uinfo.userDNI + AddDemoEnding()));
                formData.Add(new MultipartFormDataSection("medico[referencia]", mc.uinfo.docCode + AddDemoEnding()));
                break;

            case MainController.userType.Hospital:
                formData.Add(new MultipartFormDataSection("medico[nombre]", mc.uinfo.hospitalName + AddDemoEnding()));
                formData.Add(new MultipartFormDataSection("medico[nif]", mc.uinfo.DSACode + AddDemoEnding()));
                break;

            default:
                break;
            }

            formData.Add(new MultipartFormDataSection("test[asintomatico]", mc.uinfo.patient_Info.Sintomatic));

            formData.Add(new MultipartFormDataSection("test[tipo]", "DSA"));//Posibles valores: PCR, RAPIDO, ELISA, SALIVA, DSA

            formData.Add(new MultipartFormDataSection("test[resultado]", mc.uinfo.patient_temp.tests[5].testResult));

            UnityWebRequest www = UnityWebRequest.Post("https://app.immunitypass.es/save", formData);
            yield return(www.SendWebRequest());

            if (www.isNetworkError)
            {
                Debug.Log(www.error);
            }
            else
            {
                SaveStructure response = SaveStructure.CreateFromJSON(www.downloadHandler.text);
                if (response.success == "false")
                {
                    Debug.Log("Error API: " + response.error.message);
                }
                url = response.payload.url;
                Debug.Log("Save Form upload complete!");

                uic.GenerateQR(url);
            }
        }
        if (mc.uinfo.patient_temp.tests[6].valid) // SALIVA
        {
            yield return(StartCoroutine("TokenRequestAPI"));

            List <IMultipartFormSection> formData = new List <IMultipartFormSection>();
            formData.Add(new MultipartFormDataSection("token", token));
            formData.Add(new MultipartFormDataSection("partner", partner));

            formData.Add(new MultipartFormDataSection("paciente[nombre]", mc.uinfo.patient_Info.PatientName + AddDemoEnding()));
            formData.Add(new MultipartFormDataSection("paciente[nif]", mc.uinfo.patient_Info.PatientDNI + AddDemoEnding()));
            formData.Add(new MultipartFormDataSection("paciente[email]", mc.uinfo.patient_Info.PatientEmail + AddDemoEnding()));
            formData.Add(new MultipartFormDataSection("paciente[telefono]", mc.uinfo.patient_Info.PatientPhone + AddDemoEnding()));

            if (mc.uinfo.patient_temp.PatientCountry == null || mc.uinfo.patient_temp.PatientCountry == "")
            {
                formData.Add(new MultipartFormDataSection("test[pais]", "USA"));
            }
            else
            {
                formData.Add(new MultipartFormDataSection("test[pais]", mc.uinfo.patient_temp.PatientCountry));
            }

            switch (mc.uinfo.userT)
            {
            case MainController.userType.Lab:
                formData.Add(new MultipartFormDataSection("medico[nombre]", mc.uinfo.userName + AddDemoEnding()));
                formData.Add(new MultipartFormDataSection("medico[referencia]", mc.uinfo.LabNICA + AddDemoEnding()));
                break;

            case MainController.userType.Doctor:
                formData.Add(new MultipartFormDataSection("medico[nombre]", mc.uinfo.userName + AddDemoEnding()));
                formData.Add(new MultipartFormDataSection("medico[nif]", mc.uinfo.userDNI + AddDemoEnding()));
                formData.Add(new MultipartFormDataSection("medico[referencia]", mc.uinfo.docCode + AddDemoEnding()));
                break;

            case MainController.userType.Hospital:
                formData.Add(new MultipartFormDataSection("medico[nombre]", mc.uinfo.hospitalName + AddDemoEnding()));
                formData.Add(new MultipartFormDataSection("medico[nif]", mc.uinfo.DSACode + AddDemoEnding()));
                break;

            default:
                break;
            }

            formData.Add(new MultipartFormDataSection("test[asintomatico]", mc.uinfo.patient_Info.Sintomatic));

            formData.Add(new MultipartFormDataSection("test[tipo]", "SALIVA"));//Posibles valores: PCR, RAPIDO, ELISA, SALIVA, DSA

            formData.Add(new MultipartFormDataSection("test[resultado]", mc.uinfo.patient_temp.tests[6].testResult));

            UnityWebRequest www = UnityWebRequest.Post("https://app.immunitypass.es/save", formData);
            yield return(www.SendWebRequest());

            if (www.isNetworkError)
            {
                Debug.Log(www.error);
            }
            else
            {
                SaveStructure response = SaveStructure.CreateFromJSON(www.downloadHandler.text);
                if (response.success == "false")
                {
                    Debug.Log("Error API: " + response.error.message);
                }
                url = response.payload.url;
                Debug.Log("Save Form upload complete!");

                uic.GenerateQR(url);
            }
        }
    }
コード例 #24
0
        public void MarshalTest()
        {
            UnityEngine.Debug.Log("MarshalTest");
            SaveStructure testStruct = new SaveStructure();

            testStruct.location_x = 7;
            testStruct.location_y = 2;
            testStruct.location_z = 3;

            testStruct.c0_min = 2;
            testStruct.c0_max = 3;

            testStruct.heightmap = new float[20 * 20];
            testStruct.heightmap[testStruct.heightmap.Length - 1] = 123;

            testStruct.blocks_type_c0 = new byte[20 * 20 * 128];
            testStruct.blocks_iso_c0  = new float[20 * 20 * 128];
            testStruct.blocks_type_c0[testStruct.blocks_type_c0.Length - 1] = 5;
            testStruct.blocks_iso_c0[testStruct.blocks_iso_c0.Length - 1]   = 4.44f;

            testStruct.blocks_type_c1 = new byte[20 * 20 * 128];
            testStruct.blocks_iso_c1  = new float[20 * 20 * 128];
            testStruct.blocks_type_c1[testStruct.blocks_type_c1.Length - 1] = 8;
            testStruct.blocks_iso_c1[testStruct.blocks_iso_c1.Length - 1]   = 33.3f;

            //MemoryStream stream = new MemoryStream();

            FileStream stream = new FileStream(@"D:\Users\jon\Documents\test_data.dat", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);

            /*testStruct.blocks_c0 = new SaveBlock[20 * 20 * 128];
             * testStruct.blocks_c0[0] = new SaveBlock(5, 4.44f);
             *
             * testStruct.blocks_c1 = new SaveBlock[20 * 20 * 128];
             * testStruct.blocks_c1[0] = new SaveBlock(4, 3.33f);*/

            Stopwatch fullwatch = new Stopwatch();

            fullwatch.Start();

            Stopwatch watch1 = new Stopwatch();

            watch1.Start();


            testStruct.Serialize(stream);

            UnityEngine.Debug.Log("stream length: " + stream.Length);

            /*IntPtr pnt = Marshal.AllocHGlobal(size);
             * byte[] buf = new byte[size];
             *
             * Marshal.StructureToPtr(testStruct, pnt, false);
             * Marshal.Copy(pnt, buf, 0, buf.Length);*/

            watch1.Stop();

            /*byte[] tmp = new byte[stream.Length];
             * stream.Seek(0, SeekOrigin.Begin);
             * stream.Read(tmp, 0, tmp.Length);
             * Logger.Log(BitConverter.ToString(tmp));
             * stream.Close();
             * stream.Dispose();
             * stream = new MemoryStream(tmp);*/
            //stream.Seek(0, SeekOrigin.Begin);
            stream.Close();
            stream = new FileStream(@"D:\Users\jon\Documents\test_data.dat", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);

            Stopwatch watch2 = new Stopwatch();

            watch2.Start();

            testStruct = new SaveStructure();
            testStruct.Deserialize(stream);
            stream.Close();

            /*IntPtr pnt2 = Marshal.AllocHGlobal(Marshal.SizeOf(testStruct));
             * Marshal.Copy(buf, 0, pnt2, buf.Length);
             * testStruct = (SaveStructure)Marshal.PtrToStructure(pnt2, typeof(SaveStructure));*/

            watch2.Stop();
            fullwatch.Stop();

            Logger.Log("Structure To Byte: " + watch1.Elapsed);
            Logger.Log("Byte To Structure: " + watch2.Elapsed);
            Logger.Log("Full Test: " + fullwatch.Elapsed);

            Logger.Log("Marshal location_x: " + testStruct.location_x);
            Logger.Log("Marshal location_y: " + testStruct.location_y);
            Logger.Log("Marshal location_z: " + testStruct.location_z);

            Logger.Log("Marshal min: " + testStruct.c0_min);
            Logger.Log("Marshal max: " + testStruct.c0_max);

            Logger.Log("Marshal heightmap[0]: " + testStruct.heightmap[testStruct.heightmap.Length - 1]);
            Logger.Log("Marshal blocks_type_c0[0]: " + testStruct.blocks_type_c0[testStruct.blocks_type_c0.Length - 1]);
            Logger.Log("Marshal blocks_iso_c0[0]: " + testStruct.blocks_iso_c0[testStruct.blocks_iso_c0.Length - 1]);
            Logger.Log("Marshal blocks_type_c1[0]: " + testStruct.blocks_type_c1[testStruct.blocks_type_c1.Length - 1]);
            Logger.Log("Marshal blocks_iso_c1[0]: " + testStruct.blocks_iso_c1[testStruct.blocks_iso_c1.Length - 1]);

            /*Logger.Log("Marshal test: " + testStruct.blocks_c0[1].type);
             * Logger.Log("Marshal test: " + testStruct.blocks_c1[1].iso);*/
        }
コード例 #25
0
 public void Load(SaveStructure st)
 {
     goldRunOutContinuityDays = st.goldRunOutContinuityDays;
     threatMaxContinuityDays  = st.threatMaxContinuityDays;
 }