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.

Generator.cs 1.4 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using Preparation.Utility;
  2. namespace GameClass.GameObj
  3. {
  4. /// <summary>
  5. /// 发电机
  6. /// </summary>
  7. public class Generator : GameObj
  8. {
  9. public Generator(XY initPos) :
  10. base(initPos, GameData.numOfPosGridPerCell / 2, GameObjType.Generator)
  11. {
  12. this.place = PlaceType.Generator;
  13. this.CanMove = false;
  14. }
  15. public override bool IsRigid => true;
  16. public override ShapeType Shape => ShapeType.Square;
  17. private int degreeOfRepair = 0;
  18. public int DegreeOfRepair
  19. {
  20. get => degreeOfRepair;
  21. set
  22. {
  23. lock (gameObjLock)
  24. {
  25. if (degreeOfRepair < GameData.degreeOfFixedGenerator)//不允许正常破坏已经修好的发电机
  26. if (value < 0) degreeOfRepair = 0;
  27. else degreeOfRepair = value > GameData.degreeOfFixedGenerator ? GameData.degreeOfFixedGenerator : value;
  28. }
  29. }
  30. }
  31. public bool Repair(int addDegree)
  32. {
  33. if (DegreeOfRepair == GameData.degreeOfFixedGenerator) return false;
  34. DegreeOfRepair += addDegree;
  35. if (DegreeOfRepair == GameData.degreeOfFixedGenerator)
  36. return true;
  37. else return false;
  38. }
  39. }
  40. }