Esempio n. 1
0
    public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
    {
        if (!(value is string v))
        {
            throw new NullReferenceException();
        }

        if (!v.ToUpperInvariant().Contains("E+"))
        {
            return((ScUInt128)UInt128.Parse(v));
        }

        var vd = BigInteger.Parse(v);

        if (vd >= 0 && vd <= UInt128BigInteger.ToBigInteger(UInt128.MaxValue))
        {
            return((ScUInt128)UInt128BigInteger.FromBigInteger(vd));
        }

        throw new ArgumentOutOfRangeException();
    }
Esempio n. 2
0
    public byte[] SerializeSaveData()
    {
        var dict = new RemoteSaveDictionary();
        // 직전 단계에서 PlatformInterface.instance.saveLoadManager.SaveFileName에다가 썼다.
        // 쓰면서 save slot을 1 증가시켰으니까, 직전에 쓴 파일을 읽어오고 싶으면
        // PlatformInterface.instance.saveLoadManager.LoadFileName을 써야 한다.
        // 저장하는 키는 'save.dat'로 고정이다. (하위호환성)
        var localSaveFileName = SaveLoadManager.GetSaveLoadFileNameOnly(0);

        ConDebug.Log($"Saving '{SaveLoadManager.LoadFileName}' to a dict key '{localSaveFileName}'");
        dict[localSaveFileName]     = File.ReadAllBytes(SaveLoadManager.LoadFileName);
        dict[ACCOUNT_LEVEL_KEY]     = BitConverter.GetBytes(ResourceManager.instance.accountLevel);
        dict[ACCOUNT_LEVEL_EXP_KEY] = BitConverter.GetBytes(ResourceManager.instance.accountLevelExp);
        dict[ACCOUNT_GEM_KEY]       = UInt128BigInteger.ToBigInteger(ResourceManager.instance.accountGem).ToByteArray();
        dict[ACCOUNT_GOLD_RATE_KEY] =
            UInt128BigInteger.ToBigInteger(ResourceManager.instance.accountGoldRate).ToByteArray();
        dict[SAVE_DATE_KEY] = BitConverter.GetBytes(DateTime.Now.Ticks);
        var binFormatter = new BinaryFormatter();
        var memStream    = new MemoryStream();

        binFormatter.Serialize(memStream, dict);
        return(memStream.ToArray());
    }
Esempio n. 3
0
    public CloudMetadata GetCloudMetadataFromBytes(byte[] byteArr)
    {
        var remoteSaveDict = DeserializeSaveData(byteArr);

        if (remoteSaveDict == null)
        {
            return(null);
        }

        return(new CloudMetadata
        {
            level = GetInt32FromRemoteSaveDict(remoteSaveDict,
                                               ACCOUNT_LEVEL_KEY),
            levelExp = GetInt32FromRemoteSaveDict(remoteSaveDict,
                                                  ACCOUNT_LEVEL_EXP_KEY),
            gem = UInt128BigInteger.FromBigInteger(GetBigIntegerFromRemoteSaveDict(remoteSaveDict,
                                                                                   ACCOUNT_GEM_KEY)),
            goldRate = UInt128BigInteger.FromBigInteger(GetBigIntegerFromRemoteSaveDict(remoteSaveDict,
                                                                                        ACCOUNT_GOLD_RATE_KEY)),
            saveDate = GetInt64FromRemoteSaveDict(remoteSaveDict,
                                                  SAVE_DATE_KEY)
        });
    }