Enhancement.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using System;
  2. using I2.Loc;
  3. namespace DatabaseModel
  4. {
  5. public class Enhancement
  6. {
  7. public string Name { get; set; }
  8. public int Lv1Price { get; set; }
  9. public int Lv1EnhanceEffect { get; set; }
  10. public int Lv2Price { get; set; }
  11. public int Lv2EnhanceEffect { get; set; }
  12. public int Lv3Price { get; set; }
  13. public int Lv3EnhanceEffect { get; set; }
  14. public int GetNextLevelPrice(int level)
  15. {
  16. switch (level)
  17. {
  18. case 0:
  19. return this.Lv1Price;
  20. case 1:
  21. return this.Lv2Price;
  22. case 2:
  23. return this.Lv3Price;
  24. case 3:
  25. return int.MaxValue;
  26. default:
  27. throw new ArgumentOutOfRangeException();
  28. }
  29. }
  30. public int GetEnhanceEffect(int level)
  31. {
  32. switch (level)
  33. {
  34. case 0:
  35. return 0;
  36. case 1:
  37. return this.Lv1EnhanceEffect;
  38. case 2:
  39. return this.Lv2EnhanceEffect;
  40. case 3:
  41. return this.Lv3EnhanceEffect;
  42. default:
  43. throw new ArgumentOutOfRangeException();
  44. }
  45. }
  46. public string GetDesc(int level)
  47. {
  48. string text = ScriptLocalization.Get(string.Format("ui/enhancement/{0}Lv{1}Desc", this.Name, level));
  49. if (string.IsNullOrEmpty(text))
  50. {
  51. text = ScriptLocalization.Get(string.Format("ui/enhancement/{0}Lv0Desc", this.Name));
  52. }
  53. return text;
  54. }
  55. public string GetNextLevelDesc(int level)
  56. {
  57. string text = ScriptLocalization.Get(string.Format("ui/enhancement/{0}Lv{1}NextLevelDesc", this.Name, level));
  58. if (string.IsNullOrEmpty(text))
  59. {
  60. text = ScriptLocalization.Get(string.Format("ui/enhancement/{0}Lv0NextLevelDesc", this.Name));
  61. }
  62. return text;
  63. }
  64. public string GetControlKeys(int level)
  65. {
  66. string text = ScriptLocalization.Get(string.Format("mobile/enhancement/{0}Lv{1}ControlKeys", this.Name, level));
  67. if (string.IsNullOrEmpty(text))
  68. {
  69. text = ScriptLocalization.Get(string.Format("mobile/enhancement/{0}Lv0ControlKeys", this.Name));
  70. }
  71. return text;
  72. }
  73. public static Enhancement FindByName(string name)
  74. {
  75. return DB.Enhancements[name];
  76. }
  77. public static Enhancement SetValue(string[] strings)
  78. {
  79. return new Enhancement
  80. {
  81. Name = strings[0],
  82. Lv1Price = int.Parse(strings[1]),
  83. Lv1EnhanceEffect = int.Parse(strings[2]),
  84. Lv2Price = int.Parse(strings[3]),
  85. Lv2EnhanceEffect = int.Parse(strings[4]),
  86. Lv3Price = int.Parse(strings[5]),
  87. Lv3EnhanceEffect = int.Parse(strings[6])
  88. };
  89. }
  90. }
  91. }