Commit 7e47c8c8 authored by 18김상언's avatar 18김상언

드랍 아이템이랑 확률 정하는거 수정함

Dictionary 형태에 따라 코드가 달라질 수 있음(2가지) -> 하나는 그냥 쓰고 주석으로 하나 표시해둠(EnemyItemList 함수에 있음)
기존의 LoadDropTable은 삭제되거나 EnemyItemList와 함께 어떻게 수정되어야 함
parent 049b5e77
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
......@@ -14,6 +15,11 @@ public class EnemyManager : Singleton<EnemyManager>
Attack
} // 상속을 통해 수정할 가능성 높음. 염두만 해 두자.
public enum ItemType { None, OneStone, TwoStone, ThreeStone, FourStone,
FiveStone, GoldPotion, AmethystPotion, CommonItem, RareItem,
EpicItem, LegendaryItem, CommonAdd, RareAdd, EpicAdd,
LegendaryAdd }
public delegate void Action();
// about drop item
public struct DropItemInfo
......@@ -73,6 +79,52 @@ public class EnemyManager : Singleton<EnemyManager>
}
}
private void EnemyItemList(string dataPath)
{
StreamReader strReader = new StreamReader(dataPath, Encoding.UTF8);
string[] cellValue = null;
string tableLine = null;
strReader.ReadLine();
while ((tableLine = strReader.ReadLine()) != null) return;
{
cellValue = tableLine.Split(',');
// 여기에 dic 쓰고
int enemyID = -1;
float[] parseData = new float[Enum.GetValues(typeof(ItemType)).Length];
int.TryParse(cellValue[0], out enemyID);
for (int i = 0; i < parseData.Length; i++)
{
float.TryParse(cellValue[i + 1], out parseData[i]);
// dic.add 여기에 쓰고
}
//지금 쓰인 경우가 EnemyManager 자체에서 아이템 선택하는 경우
float nRnd = UnityEngine.Random.Range(0, 1);
ItemType dropItem = ItemType.None;
float prob = parseData[(int)ItemType.None];
for(int i=0;i<parseData.Length;i++)
{
if (parseData[i] > nRnd)
{
dropItem = (ItemType)i;
prob = parseData[i];
break;
}
nRnd -= parseData[i];
}
/* 이 경우가 데이터만 파싱할때인데
* 그럴려면 dropTableByID가 Dictionary<int, Dictionary<ItemList, float>> 형태가 돼야함
Dictionary<ItemList, float> dic = new Dictionary<ItemList, float>();
for (int i = 0; i < parseData.Length; i++) {
dic.Add((ItemList)i, parseData[i]);
}
dropTableByID.Add(enemyID, dic);
*/
}
}
private void LoadActionTable(string dataPath)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment