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.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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, PlaceType.Null, GameObjType.Generator)
  11. {
  12. this.CanMove = false;
  13. }
  14. public override bool IsRigid => true;
  15. public override ShapeType Shape => ShapeType.Square;
  16. private int degreeOfFRepair = 0;
  17. public int DegreeOfFRepair
  18. {
  19. get => degreeOfFRepair;
  20. set
  21. {
  22. lock (gameObjLock)
  23. {
  24. if (degreeOfFRepair < GameData.degreeOfFixedGenerator)//不允许正常破坏已经修好的发电机
  25. if (value < 0) degreeOfFRepair = 0;
  26. else degreeOfFRepair = value > GameData.degreeOfFixedGenerator ? GameData.degreeOfFixedGenerator : value;
  27. }
  28. }
  29. }
  30. public bool Repair(int addDegree)
  31. {
  32. if (DegreeOfFRepair == GameData.degreeOfFixedGenerator) return false;
  33. DegreeOfFRepair += addDegree;
  34. if (DegreeOfFRepair == GameData.degreeOfFixedGenerator)
  35. return true;
  36. else return false;
  37. }
  38. }
  39. }