DeviceMgr.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using Newtonsoft.Json;
  6. /* 设备管理者(弓和箭的种类) */
  7. public class DeviceMgr
  8. {
  9. static DeviceMgr _ins = null;
  10. public static DeviceMgr ins {
  11. get {
  12. if (_ins == null) {
  13. _ins = new DeviceMgr();
  14. }
  15. return _ins;
  16. }
  17. }
  18. Hashtable deviceConfigs = new Hashtable();
  19. DeviceMgr()
  20. {
  21. CacheDeviceConfig<DeviceBow1000>();
  22. CacheDeviceConfig<DeviceBow1001>();
  23. CacheDeviceConfig<DeviceArrow2000>();
  24. }
  25. void CacheDeviceConfig<T>() where T : DeviceConfig
  26. {
  27. DeviceConfig deviceConfig = System.Activator.CreateInstance<T>();
  28. deviceConfigs.Add(deviceConfig.id, deviceConfig);
  29. }
  30. void CacheDeviceConfig(int id, DeviceConfig deviceConfig)
  31. {
  32. deviceConfigs.Add(id, deviceConfig);
  33. }
  34. public void UseDevice(DeviceInfo deviceInfo)
  35. {
  36. }
  37. public int GetCurrentBowPound()
  38. {
  39. return 0;
  40. }
  41. }
  42. public class DeviceInfo
  43. {
  44. public int id = 0;
  45. public bool inuse = false;
  46. [JsonIgnore]
  47. public DeviceConfig config = null;
  48. }
  49. public class DeviceConfig
  50. {
  51. public int id = 0;
  52. public int name = 0;
  53. public int detail = 0;
  54. public int difficulty = 0;
  55. public int model = 0;
  56. public int type = 0;
  57. }
  58. public class DeviceBowConfig : DeviceConfig {
  59. public int pound = 0;
  60. }
  61. public class DeviceBow1000 : DeviceBowConfig {
  62. public DeviceBow1000()
  63. {
  64. id = 1000;
  65. name = 201000;
  66. detail = 211000;
  67. difficulty = 3;
  68. model = 1;
  69. type = 1;
  70. pound = 18;
  71. }
  72. }
  73. public class DeviceBow1001 : DeviceBowConfig {
  74. public DeviceBow1001()
  75. {
  76. id = 1001;
  77. name = 201001;
  78. detail = 211001;
  79. difficulty = 5;
  80. model = 1;
  81. type = 1;
  82. pound = 25;
  83. }
  84. }
  85. public class DeviceArrow2000 : DeviceConfig {
  86. public DeviceArrow2000()
  87. {
  88. id = 2000;
  89. name = 201002;
  90. detail = 211002;
  91. difficulty = 3;
  92. model = 2;
  93. type = 2;
  94. }
  95. }