80 lines
3.0 KiB
C#
80 lines
3.0 KiB
C#
using CodeStage.AntiCheat.ObscuredTypes;
|
|
using Newtonsoft.Json;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class MerchantConfigTableData : TableDataBase
|
|
{
|
|
ObscuredInt _MerchantID; public int n_MerchantID { get { return _MerchantID; } set { _MerchantID = value; _MerchantID.RandomizeCryptoKey(); } }
|
|
public int n_MerchantGrade;
|
|
public string s_MerchantImg;
|
|
public int n_AppearRate;
|
|
public int n_BattleMonsterID;
|
|
ObscuredInt _ProductRandomBagID; public int n_ProductRandomBagID { get { return _ProductRandomBagID; } set { _ProductRandomBagID = value; _ProductRandomBagID.RandomizeCryptoKey(); } }
|
|
ObscuredFloat _MerchantSaleMin; public float f_MerchantSaleMin { get { return _MerchantSaleMin; } set { _MerchantSaleMin = value; _MerchantSaleMin.RandomizeCryptoKey(); } }
|
|
ObscuredFloat _MerchantSaleMax; public float f_MerchantSaleMax { get { return _MerchantSaleMax; } set { _MerchantSaleMax = value; _MerchantSaleMax.RandomizeCryptoKey(); } }
|
|
public int n_AppearTalkID;
|
|
public int n_BattleTalkID;
|
|
public int n_LeaveTalkID;
|
|
public int n_SalesTalkID;
|
|
public int n_SoldOutTalkID;
|
|
public int n_NoPurchaseTalkID;
|
|
public int n_StealFailTalkID;
|
|
public int n_DieTalkID;
|
|
|
|
public float Get_Sale()
|
|
{
|
|
// 할인 단위 (% 단위 → 0~1 단위로 변환)
|
|
int saleunit = table_GlobalValue.Ins.Get_Int("ProductDiscountUnitRate");
|
|
float step = saleunit * 0.01f; // ex) 5 → 0.05, 10 → 0.10
|
|
|
|
float min = f_MerchantSaleMin;
|
|
float max = f_MerchantSaleMax;
|
|
|
|
// 유효 범위 내에서 가능한 단계 수 계산
|
|
int startIndex = Mathf.CeilToInt(min / step);
|
|
int endIndex = Mathf.FloorToInt(max / step);
|
|
|
|
if (startIndex > endIndex)
|
|
return min; // 안전장치: 단위가 안 맞으면 최소값 반환
|
|
|
|
// 가능한 값 리스트 중 랜덤 선택
|
|
int randIndex = Random.Range(startIndex, endIndex + 1);
|
|
return randIndex * step;
|
|
}
|
|
}
|
|
|
|
public class table_MerchantConfig : table_base
|
|
{
|
|
public static table_MerchantConfig Ins;
|
|
|
|
List<MerchantConfigTableData> tableDatas;
|
|
|
|
protected override void Awake()
|
|
{
|
|
Ins = this;
|
|
base.Awake();
|
|
}
|
|
|
|
protected override void Start()
|
|
{
|
|
tableDatas = JsonConvert.DeserializeObject<List<MerchantConfigTableData>>(json_last);
|
|
|
|
for (int i = 0; i < tableDatas.Count; i++)
|
|
{
|
|
tableDatas[i].f_MerchantSaleMin *= 0.01f;
|
|
tableDatas[i].f_MerchantSaleMax *= 0.01f;
|
|
}
|
|
|
|
base.Start();
|
|
}
|
|
|
|
public List<MerchantConfigTableData> Get_DataList() { return tableDatas; }
|
|
public MerchantConfigTableData Get_Data(int id) { return tableDatas.Find(f => f.n_MerchantID == id); }
|
|
public MerchantConfigTableData Get_RandomData(int grade)
|
|
{
|
|
var list = tableDatas.FindAll(x => x.n_MerchantGrade == grade);
|
|
return DSUtil.WeightedPick(list, x => x.n_AppearRate);
|
|
}
|
|
public MerchantConfigTableData Get_RandomData() { return DSUtil.WeightedPick(tableDatas, x => x.n_AppearRate); }
|
|
} |