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

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