LevelData.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System;
  5. //关卡数据
  6. public class LevelItem : IComparable<LevelItem>
  7. {
  8. #region Config Field
  9. public int LevelId = 0;//level id
  10. public int MapId = 0;//所在的地图 id
  11. public string Name = "";//小副本的名称.
  12. public string Describe = string.Empty;
  13. public Level_Type LevelType = Level_Type.Small_Level; //关卡类型
  14. private bool mbDisposed = false;
  15. private bool bValid = false;
  16. private float bossDelayEndTime = 3;
  17. private float monsterDelayEndTime = 1;
  18. private int mShowBossIntroType = 0; //是否显示boss出场表现
  19. private float mShowBossIntroUITime = 0; //boss界面开始显示的时间戳
  20. public float ShowBossIntroUITime
  21. {
  22. get { return mShowBossIntroUITime; }
  23. }
  24. private float mShowBossIntroDuration = 0; //boss入场持续总的时长
  25. public float ShowBossIntroDuration
  26. {
  27. get { return mShowBossIntroDuration; }
  28. }
  29. private int[] dropItems; //掉落的物品
  30. public int[] DropItems
  31. {
  32. get { return dropItems; }
  33. }
  34. private float showDropDuration; //显示掉落物品时长
  35. public float ShowDropDuration
  36. {
  37. get { return showDropDuration; }
  38. }
  39. public int[] PathList;
  40. public int bossBornIdx = 0;
  41. public int ShowBossIntroType
  42. {
  43. get { return mShowBossIntroType; }
  44. }
  45. //通关可获得的经验值
  46. private int mExp = 0;
  47. public int Exp
  48. {
  49. get { return mExp; }
  50. set { mExp = value; }
  51. }
  52. private int mPartnerExp;
  53. public int PartnerExp
  54. {
  55. get { return mPartnerExp; }
  56. set { mPartnerExp = value; }
  57. }
  58. private int mCruiseVal;
  59. public int CruiseVal
  60. {
  61. get { return mCruiseVal; }
  62. }
  63. private int mGold = 0;
  64. public int Gold
  65. {
  66. get { return mGold; }
  67. set { mGold = value; }
  68. }
  69. private int mEvil = 0;
  70. public int Evil
  71. {
  72. get { return mEvil; }
  73. set { mEvil = value; }
  74. }
  75. //通关可获得的zeny
  76. private int mZeny = 0;
  77. public int Zeny
  78. {
  79. get { return mZeny; }
  80. set { mZeny = value; }
  81. }
  82. private int mMonsterLv;
  83. public int MonsterLv
  84. {
  85. get { return mMonsterLv; }
  86. }
  87. private int mChallengeLv;
  88. public int ChallengeLv
  89. {
  90. get { return mChallengeLv; }
  91. }
  92. public bool HasPassed = false; //场景是否通关【kill boss】
  93. public List<int> ShowEnemyBoss;
  94. public List<int> ShowEnemyBossIntro;
  95. private List<ActorData> mMonsters;
  96. public List<ActorData> Monsters
  97. {
  98. get { return mMonsters; }
  99. }
  100. public bool Valid
  101. {
  102. get { return bValid; }
  103. }
  104. public int bossId;
  105. public int bossPos;
  106. private ActorData mBossActor;
  107. public ActorData BossActor
  108. {
  109. get { return mBossActor; }
  110. }
  111. public float BossDelayEndTime
  112. {
  113. get { return bossDelayEndTime; }
  114. }
  115. public float MonsterDelayEndTime
  116. {
  117. get { return monsterDelayEndTime; }
  118. }
  119. private int rageId;
  120. private int mDlgId;
  121. public int DlgId
  122. {
  123. get { return mDlgId; }
  124. }
  125. private string mBattleBgm;
  126. public string BattleBgm
  127. {
  128. get { return mBattleBgm; }
  129. }
  130. #endregion
  131. public LevelItem(int mapId, int levelId)
  132. {
  133. this.LevelId = levelId;
  134. this.MapId = mapId;
  135. ReadFromConfig();
  136. InitMonsterData();
  137. }
  138. void ReadFromConfig()
  139. {
  140. int miniRewardTime = GlobalConfig.Instance.GetConfigIntValue(GlobalConfig.c_miniRewardTime_cfg_id) / 60;
  141. if (miniRewardTime == 0) miniRewardTime = 1;
  142. int id = MapId * 10000 + LevelId;
  143. Dictionary<string, string> dic = ConfigMgr.Instance.getLine(id, Config.LevelCfgName);
  144. if (dic != null)
  145. {
  146. this.Name = dic["Name"];
  147. if(dic.ContainsKey("BaseExpOl"))
  148. {
  149. int.TryParse(dic["BaseExpOl"], out mExp);
  150. mExp /= miniRewardTime;
  151. }
  152. if(dic.ContainsKey("ZenyOl"))
  153. {
  154. int.TryParse(dic["ZenyOl"], out mZeny);
  155. mZeny /= miniRewardTime;
  156. }
  157. if(dic.ContainsKey("ParterOl"))
  158. {
  159. int.TryParse(dic["ParterOl"], out mPartnerExp);
  160. mPartnerExp /= miniRewardTime;
  161. }
  162. if(dic.ContainsKey("CruiseOl"))
  163. {
  164. int.TryParse(dic["CruiseOl"], out mCruiseVal);
  165. mCruiseVal /= miniRewardTime;
  166. }
  167. if (dic.ContainsKey("GoldOl"))
  168. {
  169. int.TryParse(dic["GoldOl"], out mGold);
  170. mGold /= miniRewardTime;
  171. }
  172. if(dic.ContainsKey("EvilOl"))
  173. {
  174. int.TryParse(dic["EvilOl"], out mEvil);
  175. mEvil /= miniRewardTime;
  176. }
  177. int temp;
  178. if (int.TryParse(dic["LevelType"], out temp))
  179. {
  180. this.LevelType = (Level_Type)temp;
  181. }
  182. int.TryParse(dic["BossId"], out bossId);
  183. if (dic.ContainsKey("BossDeadDelay"))
  184. {
  185. float.TryParse(dic["BossDeadDelay"], out this.bossDelayEndTime);
  186. }
  187. if (dic.ContainsKey("MonsterDeadDelay"))
  188. {
  189. float.TryParse(dic["MonsterDeadDelay"], out this.monsterDelayEndTime);
  190. }
  191. if(dic.ContainsKey("BossAnimation"))
  192. {
  193. int.TryParse(dic["BossAnimation"], out this.mShowBossIntroType);
  194. }
  195. if(dic.ContainsKey("UiShowTime"))
  196. {
  197. float.TryParse(dic["UiShowTime"], out this.mShowBossIntroUITime);
  198. }
  199. if(dic.ContainsKey("BossAnimationTime"))
  200. {
  201. float.TryParse(dic["BossAnimationTime"], out this.mShowBossIntroDuration);
  202. }
  203. if (dic.ContainsKey("Drops"))
  204. {
  205. dropItems = StringUtil.split2Int(dic["Drops"], ';');
  206. }
  207. if(dic.ContainsKey("DropTime"))
  208. {
  209. float.TryParse(dic["DropTime"], out this.showDropDuration);
  210. }
  211. if(dic.ContainsKey("BossPosition"))
  212. {
  213. int.TryParse(dic["BossPosition"], out this.bossPos);
  214. }
  215. if(dic.ContainsKey("BossRageBuffId"))
  216. {
  217. int.TryParse(dic["BossRageBuffId"], out this.rageId);
  218. }
  219. if(dic.ContainsKey("PathList"))
  220. {
  221. PathList = StringUtil.split2Int(dic["PathList"], ';');
  222. }
  223. if(dic.ContainsKey("BossBorn"))
  224. {
  225. int.TryParse(dic["BossBorn"], out bossBornIdx);
  226. }
  227. if(dic.ContainsKey("MonsterLv"))
  228. {
  229. int.TryParse(dic["MonsterLv"], out mMonsterLv);
  230. }
  231. if(dic.ContainsKey("FightLv"))
  232. {
  233. int.TryParse(dic["FightLv"], out mChallengeLv);
  234. }
  235. if(dic.ContainsKey("DlgId"))
  236. {
  237. int.TryParse(dic["DlgId"], out mDlgId);
  238. }
  239. if(dic.ContainsKey("BattleBgm"))
  240. {
  241. mBattleBgm = dic["BattleBgm"].Trim();
  242. }
  243. if(dic.ContainsKey("Monsters"))
  244. {
  245. string tempStr = dic["Monsters"];
  246. string[] strList = StringUtil.split(tempStr, ';');
  247. if(strList!=null)
  248. {
  249. mMonsters = new List<ActorData>();
  250. for (int idx =0; idx < strList.Length;idx++)
  251. {
  252. int[] intVals = StringUtil.split2Int(strList[idx], ':');
  253. if(intVals != null && intVals.Length >= 2)
  254. {
  255. int loc = intVals[0];
  256. int monsterId = intVals[1];
  257. if(loc>=1 && loc<=6 && monsterId > 0)
  258. {
  259. ActorData ad = ActorData.CreateNpcPlayerActor(MapId, LevelId, loc, monsterId, 1);
  260. ad.PositionValue = loc;
  261. mMonsters.Add(ad);
  262. }
  263. }
  264. }
  265. }
  266. }
  267. bValid = true;
  268. }
  269. }
  270. void InitMonsterData()
  271. {
  272. if (!bValid) return;
  273. if(bossId > 0)
  274. {
  275. int baseId = bossId / 1000;
  276. int bossLv = bossId - baseId * 1000;
  277. mBossActor = ActorData.CreateNpcPlayerActor(MapId, LevelId, bossPos, baseId, bossLv);
  278. mBossActor.IsBoss = true;
  279. mBossActor.PositionValue = bossPos;
  280. mBossActor.RageId = this.rageId;
  281. }
  282. }
  283. public int CompareTo(LevelItem other)
  284. {
  285. return this.LevelId - other.LevelId;
  286. }
  287. public bool UnLocked()
  288. {
  289. return true;
  290. }
  291. public void Dispose()
  292. {
  293. if (mbDisposed)
  294. return;
  295. mbDisposed = true;
  296. }
  297. }