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

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