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.

Doorway.cs 1.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using Preparation.Interface;
  2. using Preparation.Utility;
  3. namespace GameClass.GameObj
  4. {
  5. /// <summary>
  6. /// 出口
  7. /// </summary>
  8. public class Doorway : GameObj
  9. {
  10. public Doorway(XY initPos) :
  11. base(initPos, GameData.numOfPosGridPerCell / 2, GameObjType.Doorway)
  12. {
  13. this.place = PlaceType.Doorway;
  14. this.CanMove = false;
  15. }
  16. public override bool IsRigid => true;
  17. public override ShapeType Shape => ShapeType.Square;
  18. public override bool IgnoreCollideExecutor(IGameObj targetObj)
  19. {
  20. if (!IsOpen()) return false;
  21. if (targetObj.Type != GameObjType.Character)
  22. return true; // 非玩家不碰撞
  23. return false;
  24. }
  25. private bool powerSupply = false;
  26. public bool PowerSupply
  27. {
  28. get => powerSupply;
  29. set
  30. {
  31. lock (gameObjLock)
  32. powerSupply = value;
  33. }
  34. }
  35. private bool isOpening = false;
  36. public bool IsOpening
  37. {
  38. get => isOpening;
  39. set
  40. {
  41. lock (gameObjLock)
  42. isOpening = value;
  43. }
  44. }
  45. private int openDegree = 0;
  46. public int OpenDegree
  47. {
  48. get => openDegree;
  49. set
  50. {
  51. if (value > 0)
  52. lock (gameObjLock)
  53. openDegree = (value < GameData.degreeOfOpenedDoorway) ? value : GameData.degreeOfOpenedDoorway;
  54. else
  55. lock (gameObjLock)
  56. openDegree = 0;
  57. }
  58. }
  59. public bool IsOpen() => (OpenDegree == GameData.degreeOfOpenedDoorway);
  60. }
  61. }