70 lines
2.0 KiB
C#
70 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using Random = UnityEngine.Random;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace BlueWaterProject
|
|
{
|
|
[Serializable]
|
|
public class ItemDropTable
|
|
{
|
|
public enum ItemDropType
|
|
{
|
|
NONE = 0,
|
|
OCEAN,
|
|
FIELD
|
|
}
|
|
|
|
[Tooltip("드랍 테이블 인덱스")]
|
|
public int idx;
|
|
|
|
[Tooltip("드랍 테이블 이름")]
|
|
public string name;
|
|
|
|
public int item1_idx;
|
|
public int item1_prob;
|
|
public int item1_min;
|
|
public int item1_max;
|
|
|
|
public int item2_idx;
|
|
public int item2_prob;
|
|
public int item2_min;
|
|
public int item2_max;
|
|
|
|
public int item3_idx;
|
|
public int item3_prob;
|
|
public int item3_min;
|
|
public int item3_max;
|
|
|
|
public int item4_idx;
|
|
public int item4_prob;
|
|
public int item4_min;
|
|
public int item4_max;
|
|
|
|
public ItemDropType item_drop_type;
|
|
|
|
public List<ItemSlot> GetDroppedItemList()
|
|
{
|
|
var newItemSlotList = new List<ItemSlot>();
|
|
|
|
CheckAndAddItem(newItemSlotList, item1_idx, item1_prob, item1_min, item1_max);
|
|
CheckAndAddItem(newItemSlotList, item2_idx, item2_prob, item2_min, item2_max);
|
|
CheckAndAddItem(newItemSlotList, item3_idx, item3_prob, item3_min, item3_max);
|
|
CheckAndAddItem(newItemSlotList, item4_idx, item4_prob, item4_min, item4_max);
|
|
|
|
return newItemSlotList;
|
|
}
|
|
|
|
private void CheckAndAddItem(List<ItemSlot> itemSlotList, int itemIdx, int probability, int min, int max)
|
|
{
|
|
if (itemIdx == 0) return;
|
|
|
|
var dropChance = Random.Range(0, 101);
|
|
if (dropChance > probability) return;
|
|
|
|
var randomCount = Random.Range(min, max + 1);
|
|
itemSlotList.Add(new ItemSlot(itemIdx, randomCount));
|
|
}
|
|
}
|
|
} |