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.

Window.cs 1.8 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using Preparation.Interface;
  2. using Preparation.Utility;
  3. namespace GameClass.GameObj
  4. {
  5. /// <summary>
  6. /// 窗
  7. /// </summary>
  8. public class Window : Immovable, IWindow
  9. {
  10. public Window(XY initPos) :
  11. base(initPos, GameData.numOfPosGridPerCell / 2, GameObjType.Window)
  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 (targetObj.Type != GameObjType.Character)
  19. return true; // 非玩家不碰撞
  20. if (whoIsClimbing != null && targetObj == whoIsClimbing)
  21. {
  22. return true;
  23. }
  24. return false;
  25. }
  26. private XY stage = new(0, 0);
  27. public XY Stage
  28. {
  29. get
  30. {
  31. lock (gameObjLock)
  32. return stage;
  33. }
  34. }
  35. private Character? whoIsClimbing = null;
  36. public Character? WhoIsClimbing
  37. {
  38. get
  39. {
  40. lock (gameObjLock)
  41. return whoIsClimbing;
  42. }
  43. }
  44. public bool TryToClimb(ICharacter character)
  45. {
  46. lock (gameObjLock)
  47. if (whoIsClimbing == null)
  48. {
  49. stage = new(0, 0);
  50. whoIsClimbing = (Character)character;
  51. return true;
  52. }
  53. else return false;
  54. }
  55. public void FinishClimbing()
  56. {
  57. lock (gameObjLock)
  58. whoIsClimbing = null;
  59. }
  60. public void Enter2Stage(XY xy)
  61. {
  62. lock (gameObjLock)
  63. stage = xy;
  64. }
  65. }
  66. }