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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. protected override bool IgnoreCollideExecutor(IGameObj targetObj)
  19. {
  20. if (targetObj.Type != GameObjType.Character)
  21. return true; // 非玩家不碰撞
  22. else if (!((Character)targetObj).IsGhost())
  23. return true; // 不是鬼不碰撞
  24. return false;
  25. }
  26. private bool powerSupply = false;
  27. public bool PowerSupply
  28. {
  29. get => powerSupply;
  30. set
  31. {
  32. lock (gameObjLock)
  33. powerSupply = value;
  34. }
  35. }
  36. private bool isOpening = false;
  37. public bool IsOpening
  38. {
  39. get => isOpening;
  40. set
  41. {
  42. lock (gameObjLock)
  43. isOpening = value;
  44. }
  45. }
  46. private int openDegree = 0;
  47. public int OpenDegree
  48. {
  49. get => openDegree;
  50. set
  51. {
  52. if (value > 0)
  53. lock (gameObjLock)
  54. openDegree = (value < GameData.degreeOfOpenedDoorway) ? value : GameData.degreeOfOpenedDoorway;
  55. else
  56. lock (gameObjLock)
  57. openDegree = 0;
  58. }
  59. }
  60. public bool IsOpen() => (OpenDegree == GameData.degreeOfOpenedDoorway);
  61. }
  62. }