52 lines
952 B
C#
52 lines
952 B
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using BITKit;
|
|
using UnityEngine;
|
|
|
|
|
|
namespace BITFALL.Industry
|
|
{
|
|
[Serializable]
|
|
[CustomType(typeof(IDataStorage))]
|
|
public struct GameDataStorage:IDataStorage,IProperty
|
|
{
|
|
[SerializeField] private bool readOnly;
|
|
[SerializeField] private string data;
|
|
[SerializeField] private bool encrypted;
|
|
[SerializeField] private string key;
|
|
|
|
public bool ReadOnly
|
|
{
|
|
get => readOnly;
|
|
set => readOnly = value;
|
|
}
|
|
public string Data
|
|
{
|
|
get => data;
|
|
set => data = value;
|
|
}
|
|
public bool Encrypted
|
|
{
|
|
get => encrypted;
|
|
set => encrypted = value;
|
|
}
|
|
public bool TryDecrypt(string key)
|
|
{
|
|
if (string.Equals(this.key, key) is false) return false;
|
|
encrypted = false;
|
|
return true;
|
|
}
|
|
public string Key
|
|
{
|
|
get => key;
|
|
set => key = value;
|
|
}
|
|
public override string ToString()
|
|
{
|
|
return Encrypted ? "数据已被加密" : data;
|
|
}
|
|
}
|
|
|
|
}
|