76 lines
1.6 KiB
C#
76 lines
1.6 KiB
C#
using System;
|
|
using UnityEngine;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace Data
|
|
{
|
|
public enum ShoppingCartDataType{
|
|
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 ShoppingCartData
|
|
{
|
|
/// <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 ShoppingCartDatas
|
|
{
|
|
public List<ShoppingCartData> ShoppingCartList = new List<ShoppingCartData>();
|
|
}
|
|
|
|
public class ShoppingCartDataExcel
|
|
{
|
|
private const string _fileName = "ShoppingCart";
|
|
private string _filePath;
|
|
private ShoppingCartDatas _datas;
|
|
public ShoppingCartDatas Datas => _datas;
|
|
|
|
public ShoppingCartDataExcel()
|
|
{
|
|
_filePath = $"{Application.dataPath}/Res/ExcelData/{_fileName}.json";
|
|
var text = File.ReadAllText(_filePath);
|
|
_datas = JsonConvert.DeserializeObject<ShoppingCartDatas>(text);
|
|
}
|
|
|
|
public ShoppingCartData GetData(int id)
|
|
{
|
|
foreach (var testData in _datas.ShoppingCartList)
|
|
{
|
|
if (id == testData.ID)
|
|
{
|
|
return testData;
|
|
}
|
|
}
|
|
|
|
throw new NullReferenceException();
|
|
}
|
|
}} |