You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Gadget.cs 5.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. using Preparation.Interface;
  2. using Preparation.Utility;
  3. using System.Threading;
  4. namespace GameClass.GameObj
  5. {
  6. public abstract class Gadget : ObjOfCharacter
  7. {
  8. public override bool IsRigid => true;
  9. public override bool IgnoreCollideExecutor(IGameObj targetObj)
  10. {
  11. if (targetObj.Type == GameObjType.Gadget || targetObj.Type == GameObjType.Bullet
  12. || targetObj.Type == GameObjType.Character || targetObj.Type == GameObjType.Chest)
  13. return true;
  14. return false;
  15. }
  16. public override ShapeType Shape => ShapeType.Square;
  17. public abstract bool IsUsable();
  18. public abstract PropType GetPropType();
  19. public Gadget(XY initPos, int radius = GameData.PropRadius) :
  20. base(initPos, radius, GameObjType.Gadget)
  21. {
  22. this.canMove = false;
  23. this.MoveSpeed = GameData.PropMoveSpeed;
  24. }
  25. }
  26. public abstract class Tool : Gadget
  27. {
  28. private bool isUsed = false;
  29. public bool IsUsed
  30. {
  31. get
  32. {
  33. lock (gameObjLock)
  34. return isUsed;
  35. }
  36. set
  37. {
  38. lock (gameObjLock)
  39. {
  40. isUsed = value;
  41. }
  42. }
  43. }
  44. public override bool IsUsable() => !IsUsed;
  45. public Tool(XY initPos) : base(initPos) { }
  46. }
  47. public abstract class Consumables : Gadget
  48. {
  49. public override bool IsUsable() => true;
  50. public Consumables(XY initPos) : base(initPos) { }
  51. }
  52. ///// <summary>
  53. ///// 坑人地雷
  54. ///// </summary>
  55. // public abstract class DebuffMine : Gadget
  56. //{
  57. // public DebuffMine(XYPosition initPos) : base(initPos) { }
  58. // }
  59. #region 所有增益道具
  60. /// <summary>
  61. /// 增加速度
  62. /// </summary>
  63. public sealed class AddSpeed : Consumables
  64. {
  65. public AddSpeed(XY initPos) :
  66. base(initPos)
  67. {
  68. }
  69. public override PropType GetPropType() => PropType.AddSpeed;
  70. }
  71. /// <summary>
  72. /// 复活甲
  73. /// </summary>
  74. public sealed class AddLifeOrClairaudience : Consumables
  75. {
  76. public AddLifeOrClairaudience(XY initPos) :
  77. base(initPos)
  78. {
  79. }
  80. public override PropType GetPropType() => PropType.AddLifeOrClairaudience;
  81. }
  82. public sealed class AddHpOrAp : Consumables
  83. {
  84. public AddHpOrAp(XY initPos) :
  85. base(initPos)
  86. {
  87. }
  88. public override PropType GetPropType() => PropType.AddHpOrAp;
  89. }
  90. public sealed class RecoveryFromDizziness : Consumables
  91. {
  92. public RecoveryFromDizziness(XY initPos) :
  93. base(initPos)
  94. {
  95. }
  96. public override PropType GetPropType() => PropType.RecoveryFromDizziness;
  97. }
  98. /// <summary>
  99. /// 矛盾
  100. /// </summary>
  101. public sealed class ShieldOrSpear : Consumables
  102. {
  103. public ShieldOrSpear(XY initPos) : base(initPos)
  104. {
  105. }
  106. public override PropType GetPropType() => PropType.ShieldOrSpear;
  107. }
  108. #endregion
  109. public sealed class Key3 : Tool
  110. {
  111. public Key3(XY initPos) : base(initPos)
  112. {
  113. }
  114. public override PropType GetPropType() => PropType.Key3;
  115. }
  116. public sealed class Key5 : Tool
  117. {
  118. public Key5(XY initPos) : base(initPos)
  119. {
  120. }
  121. public override PropType GetPropType() => PropType.Key5;
  122. }
  123. public sealed class Key6 : Tool
  124. {
  125. public Key6(XY initPos) : base(initPos)
  126. {
  127. }
  128. public override PropType GetPropType() => PropType.Key6;
  129. }
  130. public sealed class NullProp : Gadget
  131. {
  132. public override bool IsUsable() => false;
  133. public NullProp() : base(new XY(1, 1))
  134. {
  135. }
  136. public override PropType GetPropType() => PropType.Null;
  137. }
  138. // #region 所有坑人地雷
  139. ///// <summary>
  140. ///// 减速
  141. ///// </summary>
  142. // public sealed class MinusSpeed : DebuffMine
  143. //{
  144. // public MinusSpeed(XYPosition initPos) : base(initPos) { }
  145. // public override PropType GetPropType() => PropType.minusSpeed;
  146. // }
  147. ///// <summary>
  148. ///// 减少攻击力
  149. ///// </summary>
  150. // public sealed class MinusAP : DebuffMine
  151. //{
  152. // public MinusAP(XYPosition initPos) : base(initPos) { }
  153. // public override PropType GetPropType() => PropType.minusAP;
  154. // }
  155. ///// <summary>
  156. ///// 增加冷却
  157. ///// </summary>
  158. // public sealed class AddCD : DebuffMine
  159. //{
  160. // public AddCD(XYPosition initPos) : base(initPos) { }
  161. // public override PropType GetPropType() => PropType.addCD;
  162. // }
  163. // #endregion
  164. public static class PropFactory
  165. {
  166. public static Gadget GetConsumables(PropType propType, XY pos)
  167. {
  168. switch (propType)
  169. {
  170. case PropType.AddSpeed:
  171. return new AddSpeed(pos);
  172. case PropType.AddLifeOrClairaudience:
  173. return new AddLifeOrClairaudience(pos);
  174. case PropType.ShieldOrSpear:
  175. return new ShieldOrSpear(pos);
  176. case PropType.AddHpOrAp:
  177. return new AddHpOrAp(pos);
  178. case PropType.RecoveryFromDizziness:
  179. return new RecoveryFromDizziness(pos);
  180. case PropType.Key3:
  181. return new Key3(pos);
  182. case PropType.Key5:
  183. return new Key5(pos);
  184. case PropType.Key6:
  185. return new Key6(pos);
  186. default:
  187. return new NullProp();
  188. }
  189. }
  190. }
  191. }