Commit ec88adb8 authored by 15김민규's avatar 15김민규

enemyManager가 data를 읽어들이는 것 수정. 이젠 droptable만 읽을 것임. 현재 방의 enemy 소환 위치를 긁어오는데 성공.

parent dc8a1958
스테이지,ID,이름,드랍하지 않음,생명석 1개,생명석 2개,생명석 3개,생명석 4개,생명석 5개,금 포션,자수정 포션,습작 아이템,범작,수작,걸작 아이템,습작 애드온,범작,수작,걸작 애드온
고대유적,,,,,,,,,,,,,,,,,,
고대유적,42,전갈,7,4,1,0,0,0,0,0,2,0,0,0,2,1,0,0
고대유적,101,고블린,7,4,1,0,0,0,0,0,2,0,0,0,2,1,0,0
고대유적,102,고블린 보초병,4,3,0,0,0,0,0,0,0,0,0,0,1,0,0,0
고대유적,103,날쌘 고블린,3,5,1,0,0,0,0,0,2,0,0,0,2,1,0,0
고대유적,1050,나태한 고블린,3,5,1,0,0,0,0,0,1,0,0,0,1,3,0,0
고대유적,104,고블린 챔피언,1,8,4,2,0,0,3,0,2,4,2,0,2,1,0,0
고대유적,1060,밤의 사제,0,2,1,0,0,0,3,0,2,6,3,0,1,5,2,0
고대유적,1070,고물 보블린,0,3,0,0,0,0,3,0,1,7,5,1,2,6,4,1
고대유적,111,거대 거미,2,4,3,1,0,0,0,0,2,1,0,0,2,2,0,0
고대유적,112,독 거미,3,4,1,0,0,0,0,0,1,0,0,0,1,1,0,0
고대유적,121,도둑 까마귀,0,3,1,0,0,0,4,0,5,2,1,0,7,4,1,0
고대유적,113,야생 늑대,1,2,4,1,0,0,0,0,1,3,1,0,2,3,1,0
고대유적,1140,고블린 라이더,1,3,5,1,0,0,3,0,3,4,1,0,3,3,1,0
고대유적,122,흡혈 박쥐,3,3,1,0,0,0,0,0,2,1,0,0,3,1,0,0
고대유적,1230,새끼 박쥐,5,4,0,0,0,0,0,0,1,0,0,0,2,0,0,0
고대유적,115,엘리게이터-1,1,4,6,3,1,0,2,0,5,5,3,1,3,1,1,0
고대유적,116,엘리게이터-2,1,4,6,3,1,0,2,0,5,5,3,1,3,1,1,0
고대유적,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,
라거 섬,,,,,,,,,,,,,,,,,,
라거 섬,,,,,,,,,,,,,,,,,,
라거 섬,,,,,,,,,,,,,,,,,,
라거 섬,,,,,,,,,,,,,,,,,,
라거 섬,,,,,,,,,,,,,,,,,,
라거 섬,,,,,,,,,,,,,,,,,,
라거 섬,,,,,,,,,,,,,,,,,,
라거 섬,,,,,,,,,,,,,,,,,,
라거 섬,,,,,,,,,,,,,,,,,,
라거 섬,,,,,,,,,,,,,,,,,,
라거 섬,,,,,,,,,,,,,,,,,,
도시,,,,,,,,,,,,,,,,,,
도시,,고위 마법사,,,,,,,,,,,,,,,,
도시,,황실 기사,,,,,,,,,,,,,,,,
도시,,학자,,,,,,,,,,,,,,,,
도시,,보초병,,,,,,,,,,,,,,,,
도시,,일반 마법사,,,,,,,,,,,,,,,,
도시,,폰,,,,,,,,,,,,,,,,
도시,,나이트,,,,,,,,,,,,,,,,
도시,,비숍,,,,,,,,,,,,,,,,
도시,,룩,,,,,,,,,,,,,,,,
도시,,심복,,,,,,,,,,,,,,,,
도시,,성직자,,,,,,,,,,,,,,,,
도시,,고위 성직자,,,,,,,,,,,,,,,,
도시,,정예 기사,,,,,,,,,,,,,,,,
폐허,,,,,,,,,,,,,,,,,,
폐허,,용암 융합체,,,,,,,,,,,,,,,,
폐허,,백골 야수,,,,,,,,,,,,,,,,
폐허,,백골 마법사,,,,,,,,,,,,,,,,
폐허,,언데드 학자,,,,,,,,,,,,,,,,
폐허,,언데드 성직자,,,,,,,,,,,,,,,,
폐허,,묘비왕자,,,,,,,,,,,,,,,,
폐허,,,,,,,,,,,,,,,,,,
폐허,,,,,,,,,,,,,,,,,,
폐허,,,,,,,,,,,,,,,,,,
폐허,,,,,,,,,,,,,,,,,,
폐허,,,,,,,,,,,,,,,,,,
폐허,,,,,,,,,,,,,,,,,,
공통,,,,,,,,,,,,,,,,,,
공통,,,,,,,,,,,,,,,,,,
공통,,,,,,,,,,,,,,,,,,
공통,,,,,,,,,,,,,,,,,,
공통,,,,,,,,,,,,,,,,,,
공통,,,,,,,,,,,,,,,,,,
공통,,,,,,,,,,,,,,,,,,
공통,,,,,,,,,,,,,,,,,,
공통,,,,,,,,,,,,,,,,,,
공통,,,,,,,,,,,,,,,,,,
공통,,,,,,,,,,,,,,,,,,
공통,,,,,,,,,,,,,,,,,,
공통,,,,,,,,,,,,,,,,,,
공통,,,,,,,,,,,,,,,,,,
공통,,,,,,,,,,,,,,,,,,
공통,,,,,,,,,,,,,,,,,,
공통,,,,,,,,,,,,,,,,,,
\ No newline at end of file
fileFormatVersion: 2
guid: d9afd12fd1d36c44ca21c7240fa5fdf4
guid: 6216895c658a2af40890a4446cc10a8c
TextScriptImporter:
externalObjects: {}
userData:
......
monsterid,name,itemid,prob
1,몬스터1,2,0.3
2,몬스터2,5,0.5
3,몬스터3,4,1
\ No newline at end of file
This diff is collapsed.
fileFormatVersion: 2
guid: c7a987df794900341bf68b8263f6e205
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
fileFormatVersion: 2
guid: 7f2a5cd3b45ab364a9b2e39e41de53e2
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 3eeb43e73bfaf1f48901afcdbe4f6d11
guid: 8c086f6d5e8a93542b5b6d3d56d87609
folderAsset: yes
DefaultImporter:
externalObjects: {}
......
......@@ -3,126 +3,69 @@ using System.Collections.Generic;
using System.IO;
using System.Text;
using UnityEngine;
using UnityEngine.Assertions;
public class EnemyManager : Singleton<EnemyManager>
{
// static variable
// about action
public enum State
{
Idle,
Track,
Attack
} // 상속을 통해 수정할 가능성 높음. 염두만 해 두자.
public enum EnemyData { Health, Weight, Height, Width, DetectRange,
AtkRange, AtkDistance, AtkDelay, PjtSpeed, MoveSpeed,
Damage } //Atk = Attack, Pjt = Projectile(투사체)
/* 기본적으로 각 경우에 대해 가지는 값은 양수일 것
* 하지만 특별한 경우가 있음
* 1. DetectRange(감지 범위) : DetectRange가 -1이면 방 전체를 감지한다는 뜻. -2이면 현재 에너미가 있는 플랫폼 전체, -3이면 플랫폼 전방만 감지를 뜻 함.
* 2. AtkRange(공격 범위) : -1이면 현재 위치한 플랫폼 전체를 의미, -2이면 플랫폼 전방만 의미.
* 3. AtkDistance(공격 사거리) : -1이면 현재 위치한 플랫폼 끝까지 의미.
* 4. AtkDelay(공격 딜레이) : -1이면 무한 즉, 단 1회 공격함.
*/
public delegate void Action();
// data
// dictionary
public readonly Dictionary<int, Dictionary<ItemType, int>> dropTableByID;
public readonly Dictionary<int, Dictionary<State, Action>> actionDictByID;
public readonly Dictionary<int, Dictionary<EnemyData, float>> enemyDataByID;
// data of drop item
public TextAsset dropTableData;
public Dictionary<int, int[]> dropTableByID = new Dictionary<int, int[]>();
public GameObject[] dropItemList; // insert drop item here(on right order)
// enemy prefab
public GameObject[] enemyPrefab;
public GameObject enemyPrefab;
// method
// constructor
protected EnemyManager()
// Constructor - protect calling raw constructor
protected EnemyManager() { }
// Awake
private void Awake()
{
string dropTableDataPath = "";
string actionTableDataPath = "";
LoadDropTable(dropTableData);
}
LoadDropTable(dropTableDataPath);
// Spawn Enemy to Map
public void SpawnEnemy()
{
GameObject spawnLocation = MapManager.currentRoom.roomInGame.transform.Find("enemy location").gameObject;
}
// Load Dictionary
private void LoadDropTable(string dataPath)
private void LoadDropTable(TextAsset dataFile)
{
StreamReader strReader = new StreamReader(dataPath, Encoding.UTF8);
string[] linesFromText = dataFile.text.Split('\n');
string[] cellValue = null;
string tableLine = null;
strReader.ReadLine();
Dictionary<ItemType, int> dropItemInfo = new Dictionary<ItemType, int>();
while ((tableLine = strReader.ReadLine()) != null)
{
if (string.IsNullOrEmpty(tableLine)) return;
int IDindex = 1; // index of monster ID is 1
int skipDistance = 3; // (Reason for 3): skip StageName, MonsterID, MonsterName (3 elements)
cellValue = tableLine.Split(',');
for (int i = 1; i < linesFromText.Length; i++) // (Reason i = 1): skip first line
{
cellValue = linesFromText[i].Split(',');
int enemyID = -1;
int[] weight = {-1};
int sum = 0;
int[] cumulatedWeight = { -1 };
int.TryParse(cellValue[0], out enemyID);
for(int i=1;i<17;i++)
{
int.TryParse(cellValue[i+1], out weight[i]);
}
for(int i=0;i<16;i++)
{
sum += weight[i];
cumulatedWeight[i] = sum;
}
for(int i=0;i<16;i++)
{
dropItemInfo.Add((ItemType)i, cumulatedWeight[i]);
}
int.TryParse(cellValue[IDindex], out enemyID);
Assert.AreNotEqual(-1, enemyID); // case -1: read error
if (enemyID == 0) { continue; } // case 0: blank
dropTableByID.Add(enemyID, dropItemInfo);
}
}
// Load ALL CSV Data
private void LoadEnemyData(string dataPath)
{
StreamReader strReader = new StreamReader(dataPath, Encoding.UTF8);
string[] cellValue = null;
string tableLine = null;
strReader.ReadLine();
Dictionary<EnemyData, float> EnemyInfo = new Dictionary<EnemyData, float>();
while ((tableLine = strReader.ReadLine()) != null)
{
cellValue = tableLine.Split(',');
int dropTableLength = cellValue.Length - skipDistance;
Assert.AreEqual(dropTableLength, dropItemList.Length);
int[] dropTable = new int[dropTableLength];
int enemyID = -1;
float[] enemyData = { 0.0f };
int.TryParse(cellValue[0], out enemyID);
for(int i = 0;i<11;i++)
{
float.TryParse(cellValue[i + 2], out enemyData[i]);
}
int cumulated = 0;
for(int i=0;i<12;i++)
for (int j = 0; j < dropTableLength; j++)
{
EnemyInfo.Add((EnemyData)i, enemyData[i]);
int weight = -1;
int.TryParse(cellValue[j + skipDistance], out weight);
Assert.AreNotEqual(-1, weight);
cumulated += weight;
dropTable[j] = cumulated;
}
enemyDataByID.Add(enemyID, EnemyInfo);
dropTableByID.Add(enemyID, dropTable);
}
}
// called by gameManager to Spawn enemy
// little temporary. Many change will be exist.
public void SpawnEnemy()
{
Vector2 playerPosition = GameObject.Find("Player").transform.position;
Instantiate(enemyPrefab, playerPosition + new Vector2(7, 0), Quaternion.identity);
}
}
......@@ -6,6 +6,7 @@ using UnityEngine.UI;
public class Test : MonoBehaviour {
MapManager mapManager;
EnemyManager enemyManager;
TetriminoSpawner tetriminoSpawner;
public static Vector3 tetrisCameraCoord = new Vector3(180, 0, -1);
public static float tetrisMapSize = 300;
......@@ -50,6 +51,10 @@ public class Test : MonoBehaviour {
{
MapManager.currentRoom.ClearRoom();
}
public void SummonEnemy()
{
enemyManager.SpawnEnemy();
}
public GameObject upDoor;
public GameObject downDoor;
......@@ -108,7 +113,7 @@ public class Test : MonoBehaviour {
private void Awake()
{
//leftDoor.GetComponent<Animator>().SetInteger("doorPosition", 3);
enemyManager = EnemyManager.Instance;
mapManager = GameObject.Find("MapManager").GetComponent<MapManager>();
tetriminoSpawner = GameObject.Find("TetriminoSpawner").GetComponent<TetriminoSpawner>();
}
......
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