Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
tetra-tower
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Oenos
tetra-tower
Commits
49c72235
Commit
49c72235
authored
Jan 11, 2019
by
18김상언
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
드랍 아이템 데이터 파싱하는 LoadDropTable 다시한번 수정함
parent
7e47c8c8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
69 deletions
+36
-69
EnemyManager.cs
Assets/Scripts/Characters/EnemyManager.cs
+36
-69
No files found.
Assets/Scripts/Characters/EnemyManager.cs
View file @
49c72235
...
...
@@ -6,7 +6,7 @@ using System.Text;
public
class
EnemyManager
:
Singleton
<
EnemyManager
>
{
// static variable
// static variable
// about action
public
enum
State
{
...
...
@@ -21,27 +21,15 @@ public class EnemyManager : Singleton<EnemyManager>
LegendaryAdd
}
public
delegate
void
Action
();
// about drop item
public
struct
DropItemInfo
{
public
readonly
int
id
;
public
readonly
float
prob
;
public
DropItemInfo
(
int
inputID
,
float
inputProb
)
{
id
=
inputID
;
prob
=
inputProb
;
}
}
// data
// data
// dictionary
public
readonly
Dictionary
<
int
,
D
ropItemInfo
>
dropTableByID
;
public
readonly
Dictionary
<
int
,
D
ictionary
<
ItemType
,
int
>
>
dropTableByID
;
public
readonly
Dictionary
<
int
,
Dictionary
<
State
,
Action
>>
actionDictByID
;
// method
// method
// constructor
protected
EnemyManager
()
{
...
...
@@ -49,7 +37,6 @@ public class EnemyManager : Singleton<EnemyManager>
string
actionTableDataPath
=
""
;
LoadDropTable
(
dropTableDataPath
);
LoadActionTable
(
actionTableDataPath
);
}
// Load Dictionary
...
...
@@ -59,6 +46,7 @@ public class EnemyManager : Singleton<EnemyManager>
string
[]
cellValue
=
null
;
string
tableLine
=
null
;
strReader
.
ReadLine
();
Dictionary
<
ItemType
,
int
>
dropItemInfo
=
new
Dictionary
<
ItemType
,
int
>();
while
((
tableLine
=
strReader
.
ReadLine
())
!=
null
)
{
...
...
@@ -66,67 +54,46 @@ public class EnemyManager : Singleton<EnemyManager>
cellValue
=
tableLine
.
Split
(
','
);
int
monsterID
=
-
1
;
int
itemID
=
-
1
;
float
prob
=
-
1.0f
;
int
.
TryParse
(
cellValue
[
0
],
out
monsterID
);
int
.
TryParse
(
cellValue
[
2
],
out
itemID
);
float
.
TryParse
(
cellValue
[
3
],
out
prob
);
DropItemInfo
dropItemInfo
=
new
DropItemInfo
(
itemID
,
prob
);
dropTableByID
.
Add
(
monsterID
,
dropItemInfo
);
}
}
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
[]
weight
=
{-
1
};
int
sum
=
0
;
int
[]
cumulatedWeight
=
{
-
1
};
int
.
TryParse
(
cellValue
[
0
],
out
enemyID
);
for
(
int
i
=
0
;
i
<
parseData
.
Length
;
i
++)
for
(
int
i
=
1
;
i
<
17
;
i
++)
{
float
.
TryParse
(
cellValue
[
i
+
1
],
out
parseData
[
i
]);
// dic.add 여기에 쓰고
int
.
TryParse
(
cellValue
[
i
+
1
],
out
weight
[
i
]);
}
//지금 쓰인 경우가 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
)
for
(
int
i
=
0
;
i
<
16
;
i
++)
{
dropItem
=
(
ItemType
)
i
;
prob
=
parseData
[
i
];
break
;
}
nRnd
-=
parseData
[
i
];
sum
+=
weight
[
i
];
cumulatedWeight
[
i
]
=
sum
;
}
/* 이 경우가 데이터만 파싱할때인데
* 그럴려면 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]);
for
(
int
i
=
0
;
i
<
16
;
i
++)
{
dropItemInfo
.
Add
((
ItemType
)
i
,
cumulatedWeight
[
i
]);
}
dropTableByID.Add(enemyID, dic);
*/
dropTableByID
.
Add
(
enemyID
,
dropItemInfo
);
}
}
private
void
LoadActionTable
(
string
dataPath
)
// Load ALL CSV Data
private
void
LoadEnemyData
(
string
dataPath
)
{
StreamReader
strReader
=
new
StreamReader
(
dataPath
,
Encoding
.
UTF8
);
string
[]
cellValue
=
null
;
string
tableLine
=
null
;
strReader
.
ReadLine
();
while
((
tableLine
=
strReader
.
ReadLine
())
!=
null
)
{
cellValue
=
tableLine
.
Split
(
','
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment