91 lines
1.9 KiB
C#
91 lines
1.9 KiB
C#
|
using System;
|
||
|
using UnityEngine;
|
||
|
using System.Collections.Generic;
|
||
|
using System.IO;
|
||
|
using Newtonsoft.Json;
|
||
|
|
||
|
namespace Data
|
||
|
{
|
||
|
public enum NoteBookInformationDataType{
|
||
|
Desc_1001 = 1001,
|
||
|
BookChinName_1001 = 1001,
|
||
|
BookEnglishName_1001 = 1001,
|
||
|
BookPrice_1001 = 1001,
|
||
|
Design_1001 = 1001,
|
||
|
Discount_1001 = 1001,
|
||
|
Desc_1002 = 1002,
|
||
|
BookChinName_1002 = 1002,
|
||
|
BookEnglishName_1002 = 1002,
|
||
|
BookPrice_1002 = 1002,
|
||
|
Design_1002 = 1002,
|
||
|
Discount_1002 = 1002,
|
||
|
|
||
|
}
|
||
|
|
||
|
[System.Serializable]
|
||
|
public class NoteBookInformationData
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// ID
|
||
|
/// </summary>
|
||
|
public int ID;
|
||
|
/// <summary>
|
||
|
/// 描述
|
||
|
/// </summary>
|
||
|
public string Desc;
|
||
|
/// <summary>
|
||
|
/// 笔记本中文名字
|
||
|
/// </summary>
|
||
|
public string BookChinName;
|
||
|
/// <summary>
|
||
|
/// 笔记本英文名字
|
||
|
/// </summary>
|
||
|
public string BookEnglishName;
|
||
|
/// <summary>
|
||
|
/// 笔记本价格
|
||
|
/// </summary>
|
||
|
public int BookPrice;
|
||
|
/// <summary>
|
||
|
/// 设计价格
|
||
|
/// </summary>
|
||
|
public int Design;
|
||
|
/// <summary>
|
||
|
/// 优惠
|
||
|
/// </summary>
|
||
|
public int Discount;
|
||
|
|
||
|
}
|
||
|
|
||
|
[System.Serializable]
|
||
|
public class NoteBookInformationDatas
|
||
|
{
|
||
|
public List<NoteBookInformationData> NoteBookInformationList = new List<NoteBookInformationData>();
|
||
|
}
|
||
|
|
||
|
public class NoteBookInformationDataExcel
|
||
|
{
|
||
|
private const string _fileName = "NoteBookInformation";
|
||
|
private string _filePath;
|
||
|
private NoteBookInformationDatas _datas;
|
||
|
public NoteBookInformationDatas Datas => _datas;
|
||
|
|
||
|
public NoteBookInformationDataExcel()
|
||
|
{
|
||
|
_filePath = $"{Application.dataPath}/Res/ExcelData/{_fileName}.json";
|
||
|
var text = File.ReadAllText(_filePath);
|
||
|
_datas = JsonConvert.DeserializeObject<NoteBookInformationDatas>(text);
|
||
|
}
|
||
|
|
||
|
public NoteBookInformationData GetData(int id)
|
||
|
{
|
||
|
foreach (var testData in _datas.NoteBookInformationList)
|
||
|
{
|
||
|
if (id == testData.ID)
|
||
|
{
|
||
|
return testData;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
throw new NullReferenceException();
|
||
|
}
|
||
|
}}
|