OneShotOneKill/Assets/Script/Table/Tables/table_CreateMapConfig.cs

170 lines
6.1 KiB
C#

using Newtonsoft.Json;
using System.Collections.Generic;
using Random = UnityEngine.Random;
public class CreateMapConfigTableData : TableDataBase
{
public string s_MapConfigID;
public int n_StageType;
public int n_AppearMonsterGroup;
public int n_AppearBossGroup;
public float f_Monster;
public int n_MobNodeMin;
public int n_MobNodeMax;
public float f_BuffDebuff;
public int n_BuffDebuffMin;
public int n_BuffDebuffMax;
public float f_CampFire;
public int n_CampMin;
public int n_CampMax;
public float f_Merchant;
public int n_MerchantMin;
public int n_MerchantMax;
public float f_Treasure;
public int n_TreasureMin;
public int n_TreasureMax;
public float f_NPC;
public int n_NPCMin;
public int n_NPCMax;
public float f_Mine;
public int n_MineMin;
public int n_MineMax;
public float f_TwoWay;
public int n_TwoWayMin;
public int n_TwoWayMax;
public float f_Nothing;
public int n_NothingMin;
public int n_NothingMax;
public float f_Random;
public int n_RandomMin;
public int n_RandomMax;
public Dictionary<eStageNodeType, float> dic_Rate = new Dictionary<eStageNodeType, float>();
public List<float> list_rate = new List<float>(); // 랜덤 인덱스 선택에 필요
public int TotalMin, TotalMax;
public int Get_Min(eStageNodeType nodeType)
{
switch (nodeType)
{
case eStageNodeType.Mob: return n_MobNodeMin;
case eStageNodeType.Treasure: return n_TreasureMin;
case eStageNodeType.Merchant: return n_MerchantMin;
case eStageNodeType.NPC: return n_NPCMin;
case eStageNodeType.Sanctuary: return n_MineMin;
case eStageNodeType.BuffDebuff: return n_BuffDebuffMin;
case eStageNodeType.TwoWay: return n_TwoWayMin;
case eStageNodeType.Campfire: return n_CampMin;
case eStageNodeType.Nothing: return n_NothingMin;
case eStageNodeType.Random: return n_RandomMin;
}
return 0;
}
public int Get_Max(eStageNodeType nodeType)
{
switch (nodeType)
{
case eStageNodeType.Mob: return n_MobNodeMax;
case eStageNodeType.Treasure: return n_TreasureMax;
case eStageNodeType.Merchant: return n_MerchantMax;
case eStageNodeType.NPC: return n_NPCMax;
case eStageNodeType.Sanctuary: return n_MineMax;
case eStageNodeType.BuffDebuff: return n_BuffDebuffMax;
case eStageNodeType.TwoWay: return n_TwoWayMax;
case eStageNodeType.Campfire: return n_CampMax;
case eStageNodeType.Nothing: return n_NothingMax;
case eStageNodeType.Random: return n_RandomMax;
}
return 0;
}
public int Get_NodeCount_byMinMax(eStageNodeType nodeType) { return Random.Range(Get_Min(nodeType), Get_Max(nodeType) + 1); }
}
public class table_CreateMapConfig : table_base
{
public static table_CreateMapConfig Ins;
List<CreateMapConfigTableData> tableDatas;
protected override void Awake()
{
Ins = this;
base.Awake();
}
protected override void Start()
{
tableDatas = JsonConvert.DeserializeObject<List<CreateMapConfigTableData>>(json_last);
for (int i = 0; i < tableDatas.Count; i++)
{
var temp = tableDatas[i];
temp.dic_Rate.Add(eStageNodeType.Mob, temp.f_Monster * 0.01f);
temp.dic_Rate.Add(eStageNodeType.Treasure, temp.f_Treasure * 0.01f);
temp.dic_Rate.Add(eStageNodeType.Merchant, temp.f_Merchant * 0.01f);
temp.dic_Rate.Add(eStageNodeType.NPC, temp.f_NPC * 0.01f);
temp.dic_Rate.Add(eStageNodeType.Sanctuary, temp.f_Mine * 0.01f);
temp.dic_Rate.Add(eStageNodeType.BuffDebuff, temp.f_BuffDebuff * 0.01f);
temp.dic_Rate.Add(eStageNodeType.TwoWay, temp.f_TwoWay * 0.01f);
temp.dic_Rate.Add(eStageNodeType.Campfire, temp.f_CampFire * 0.01f);
temp.dic_Rate.Add(eStageNodeType.Nothing, temp.f_Nothing * 0.01f);
temp.dic_Rate.Add(eStageNodeType.Boss, 0f);
temp.dic_Rate.Add(eStageNodeType.Random, temp.f_Random * 0.01f);
temp.list_rate.Add(temp.f_Monster * 0.01f);
temp.list_rate.Add(temp.f_Treasure * 0.01f);
temp.list_rate.Add(temp.f_Merchant * 0.01f);
temp.list_rate.Add(temp.f_NPC * 0.01f);
temp.list_rate.Add(temp.f_Mine * 0.01f);
temp.list_rate.Add(temp.f_BuffDebuff * 0.01f);
temp.list_rate.Add(temp.f_TwoWay * 0.01f);
temp.list_rate.Add(temp.f_CampFire * 0.01f);
temp.list_rate.Add(temp.f_Nothing * 0.01f);
temp.list_rate.Add(0f);
temp.list_rate.Add(temp.f_Random * 0.01f);
temp.TotalMin = temp.n_MobNodeMin
+ temp.n_BuffDebuffMin
+ temp.n_CampMin
+ temp.n_MerchantMin
+ temp.n_TreasureMin
+ temp.n_NPCMin
+ temp.n_MineMin
+ temp.n_TwoWayMin
+ temp.n_NothingMin
+ temp.n_RandomMin;
temp.TotalMax = temp.n_MobNodeMax
+ temp.n_BuffDebuffMax
+ temp.n_CampMax
+ temp.n_MerchantMax
+ temp.n_TreasureMax
+ temp.n_NPCMax
+ temp.n_MineMax
+ temp.n_TwoWayMax
+ temp.n_NothingMax
+ temp.n_RandomMax;
}
base.Start();
}
public List<CreateMapConfigTableData> Get_DataList() { return tableDatas; }
public CreateMapConfigTableData Get_Data(string id) { return Get_DataList().Find(f => f.s_MapConfigID == id); }
public CreateMapConfigTableData Get_FisrtData(int world, int stage)
{
var lst = tableDatas.FindAll(f => f.n_StageType == world);
return lst[lst.Count >= stage ? stage - 1 : 0];
}
}