Ejemplo n.º 1
0
    public static void Load()
    {
        string           path = Application.persistentDataPath + "/player.pushcube";
        PlayerDataFormat data = null;

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open);
            data = formatter.Deserialize(stream) as PlayerDataFormat;
            stream.Close();
        }
        if (data != null)
        {
            PlayerData.currentStage     = data.currentStage;
            PlayerData.currentCharacter = data.currentCharacter;
            PlayerData.goldCube         = data.goldCube;
            PlayerData.undoCount        = data.undoCount;
            PlayerData.undoTryCount     = data.undoTryCount;
            PlayerData.retryCount       = data.retryCount;
            PlayerData.moveCount        = data.moveCount;
            PlayerData.getGoldCubeCount = data.getGoldCubeCount;
            PlayerData.totalPlayTime    = data.totalPlayTime;
            PlayerData.stageInfo        = data.stageInfo;
            PlayerData.havingCharacters = data.havingCharacters;
            PlayerData.isRemoveAd       = data.isRemoveAd;
        }
        else
        {
            Debug.LogWarning("유저 데이터를 찾을 수 없습니다. " + path);
            Init();
        }
    }
Ejemplo n.º 2
0
 //an inclass semi constructor
 //no need for constructor because of XML formatting
 private void CreateNewPlayerEntry()
 {
     TempPlayerData                 = new PlayerDataFormat();
     TempPlayerData.id              = "P" + PlayersDB.Players.Count;
     TempPlayerData.UserName        = UserNameEntered;
     TempPlayerData.Password        = PasswordToSave.GetComponent <InputField>().text;
     TempPlayerData.points          = 0;
     TempPlayerData.MaxLevel        = 1;
     TempPlayerData.LastLevelPassed = 0;
     TempPlayerData.Time            = 0f;
 }
Ejemplo n.º 3
0
 //check user name validation in list of players
 private bool CheckIfUserNameExistsInDB()
 {
     UserNameEntered = UsernameInput.GetComponent <Text>().text; //get user name from input field in scene
                                                                 //checks if username already exists in DB
     for (int i = 0; i < PlayersDB.Players.Count; i++)
     {
         if (PlayersDB.Players[i].UserName.ToString().Equals(UserNameEntered))
         {
             TempPlayerData = PlayersDB.Players[i];
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 4
0
    public static void Save()
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/player.pushcube";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        PlayerDataFormat data = new PlayerDataFormat();

        try
        {
            formatter.Serialize(stream, data);
        }
        catch (SerializationException e)
        {
            Debug.LogError("유저 데이터 저장 실패 > " + e.Message);
            throw;
        }
        finally
        {
            stream.Close();
            Debug.Log("유저 데이터 로컬 저장완료.");
        }
    }