55 lines
1.7 KiB
C#
55 lines
1.7 KiB
C#
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
[Serializable]
|
|
public class HarvestConfigTableData : TableDataBase
|
|
{
|
|
public int n_Grade;
|
|
public float f_Rate;
|
|
public int n_HarvestTime;
|
|
public int n_MinAmount;
|
|
public int n_MaxAmount;
|
|
public float f_StatFruitRate;
|
|
public float f_GoldFruitRate;
|
|
}
|
|
|
|
public class table_harvestconfig : table_missionbase
|
|
{
|
|
public static table_harvestconfig Ins;
|
|
List<HarvestConfigTableData> tableDatas;
|
|
Dictionary<int, HarvestConfigTableData> dic_Data = new Dictionary<int, HarvestConfigTableData>();
|
|
List<float> grade_rate = new List<float>();
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
Ins = this;
|
|
}
|
|
|
|
protected override void Start()
|
|
{
|
|
tableDatas = JsonConvert.DeserializeObject<List<HarvestConfigTableData>>(json_last);
|
|
for (int i = 0; i < Get_DataList().Count; i++)
|
|
{
|
|
var temp = Get_DataList()[i];
|
|
grade_rate.Add(temp.f_Rate);
|
|
dic_Data.Add(temp.n_Grade, temp);
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
if (grade_rate.Sum() < 1f)
|
|
Debug.LogError($"table_harvestconfig 의 grade_rate 합계가 100%가 안됩니다.");
|
|
else if (grade_rate.Sum() > 1f)
|
|
Debug.LogError($"table_harvestconfig 의 grade_rate 합계가 100%가 넘습니다.");
|
|
#endif
|
|
|
|
base.Start();
|
|
}
|
|
|
|
public HarvestConfigTableData Get_Data_orNull(int grade) { return dic_Data[grade]; }
|
|
public HarvestConfigTableData Get_RandomData() { return Get_Data_orNull(DSUtil.Get_RandomIndex(grade_rate) + 1); }
|
|
public List<HarvestConfigTableData> Get_DataList() { return tableDatas; }
|
|
} |