EnemyAttrData.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using System;
  2. namespace DatabaseModel
  3. {
  4. [Serializable]
  5. public class EnemyAttrData
  6. {
  7. public string sceneName { get; set; }
  8. public int level { get; set; }
  9. public int maxHp { get; set; }
  10. public int atk { get; set; }
  11. public float atkSpeed { get; set; }
  12. public int maxSP { get; set; }
  13. public float scanSpeed { get; set; }
  14. public float moveSpeed { get; set; }
  15. public int flyHeight { get; set; }
  16. public int enemyId { get; set; }
  17. public int counterAttack { get; set; }
  18. public int counterAttackProbPercentage { get; set; }
  19. public int actionInterruptPoint { get; set; }
  20. public int baseDefence { get; set; }
  21. public int dropCoins { get; set; }
  22. public int dropExp { get; set; }
  23. public EnemyType enemyType
  24. {
  25. get
  26. {
  27. return (EnemyType)this.enemyId;
  28. }
  29. }
  30. public static EnemyAttrData FindBySceneNameAndType(string sceneName, EnemyType enemyId)
  31. {
  32. bool flag = false;
  33. EnemyAttrData enemyAttrData = null;
  34. for (int i = 0; i < DB.EnemyAttrData.Count; i++)
  35. {
  36. if (DB.EnemyAttrData[i].enemyId == (int)enemyId)
  37. {
  38. flag = true;
  39. if (DB.EnemyAttrData[i].sceneName == sceneName)
  40. {
  41. return DB.EnemyAttrData[i];
  42. }
  43. if (DB.EnemyAttrData[i].sceneName == "-1")
  44. {
  45. enemyAttrData = DB.EnemyAttrData[i];
  46. }
  47. }
  48. }
  49. if (!flag)
  50. {
  51. throw new IndexOutOfRangeException("enemyId" + enemyId + "不存在");
  52. }
  53. if (enemyAttrData != null)
  54. {
  55. return enemyAttrData;
  56. }
  57. throw new IndexOutOfRangeException();
  58. }
  59. public static EnemyAttrData SetValue(string[] strings)
  60. {
  61. return new EnemyAttrData
  62. {
  63. sceneName = strings[0],
  64. enemyId = int.Parse(strings[1]),
  65. level = int.Parse(strings[2]),
  66. maxHp = int.Parse(strings[3]),
  67. atk = int.Parse(strings[4]),
  68. atkSpeed = float.Parse(strings[5]),
  69. maxSP = int.Parse(strings[6]),
  70. scanSpeed = float.Parse(strings[7]),
  71. moveSpeed = float.Parse(strings[8]),
  72. flyHeight = int.Parse(strings[9]),
  73. counterAttack = int.Parse(strings[10]),
  74. counterAttackProbPercentage = int.Parse(strings[11]),
  75. actionInterruptPoint = int.Parse(strings[12]),
  76. baseDefence = int.Parse(strings[13]),
  77. dropCoins = int.Parse(strings[14]),
  78. dropExp = int.Parse(strings[15])
  79. };
  80. }
  81. }
  82. }