78 lines
1.6 KiB
C#
78 lines
1.6 KiB
C#
|
using System;
|
||
|
using UnityEngine;
|
||
|
using System.Collections.Generic;
|
||
|
using System.IO;
|
||
|
using Newtonsoft.Json;
|
||
|
|
||
|
namespace Data
|
||
|
{
|
||
|
|
||
|
}
|
||
|
public enum AgreementTermsDataType{
|
||
|
SimplifiedChinese_1001 = 1001,
|
||
|
TraditionalChinese_1001 = 1001,
|
||
|
English_1001 = 1001,
|
||
|
SimplifiedChinese_1002 = 1002,
|
||
|
TraditionalChinese_1002 = 1002,
|
||
|
English_1002 = 1002,
|
||
|
SimplifiedChinese_1003 = 1003,
|
||
|
TraditionalChinese_1003 = 1003,
|
||
|
English_1003 = 1003,
|
||
|
|
||
|
}
|
||
|
|
||
|
[System.Serializable]
|
||
|
public class AgreementTermsData
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// ID
|
||
|
/// </summary>
|
||
|
public int ID;
|
||
|
/// <summary>
|
||
|
/// 简体中文
|
||
|
/// </summary>
|
||
|
public string SimplifiedChinese;
|
||
|
/// <summary>
|
||
|
/// 繁体中文
|
||
|
/// </summary>
|
||
|
public string TraditionalChinese;
|
||
|
/// <summary>
|
||
|
/// 英文
|
||
|
/// </summary>
|
||
|
public string English;
|
||
|
|
||
|
}
|
||
|
|
||
|
[System.Serializable]
|
||
|
public class AgreementTermsDatas
|
||
|
{
|
||
|
public List<AgreementTermsData> AgreementTermsList = new List<AgreementTermsData>();
|
||
|
}
|
||
|
|
||
|
public class AgreementTermsDataExcel
|
||
|
{
|
||
|
private const string _fileName = "AgreementTerms";
|
||
|
private string _filePath;
|
||
|
private AgreementTermsDatas _datas;
|
||
|
public AgreementTermsDatas Datas => _datas;
|
||
|
|
||
|
public AgreementTermsDataExcel()
|
||
|
{
|
||
|
_filePath = $"{Application.streamingAssetsPath}/ExcelData/{_fileName}.json";
|
||
|
var text = File.ReadAllText(_filePath);
|
||
|
_datas = JsonConvert.DeserializeObject<AgreementTermsDatas>(text);
|
||
|
}
|
||
|
|
||
|
public AgreementTermsData GetData(int id)
|
||
|
{
|
||
|
foreach (var testData in _datas.AgreementTermsList)
|
||
|
{
|
||
|
if (id == testData.ID)
|
||
|
{
|
||
|
return testData;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
throw new NullReferenceException();
|
||
|
}
|
||
|
}
|