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.

EmergencyExit.cs 1.1 kB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using Preparation.Interface;
  2. using Preparation.Utility;
  3. namespace GameClass.GameObj
  4. {
  5. /// <summary>
  6. /// 紧急出口
  7. /// </summary>
  8. public class EmergencyExit : Immovable
  9. {
  10. public EmergencyExit(XY initPos) :
  11. base(initPos, GameData.numOfPosGridPerCell / 2, GameObjType.EmergencyExit)
  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 (!CanOpen) return true;
  19. if (!IsOpen) return false;
  20. if (targetObj.Type != GameObjType.Character)
  21. return true; // 非玩家不碰撞
  22. return false;
  23. }
  24. public AtomicBool CanOpen { get; } = new(false);
  25. private bool isOpen = false;
  26. public bool IsOpen
  27. {
  28. get => isOpen;
  29. set
  30. {
  31. lock (gameObjLock)
  32. isOpen = value;
  33. }
  34. }
  35. }
  36. }