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.

Chest.cs 1.5 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using Preparation.Interface;
  2. using Preparation.Utility;
  3. using System;
  4. namespace GameClass.GameObj
  5. {
  6. /// <summary>
  7. /// 箱子
  8. /// </summary>
  9. public class Chest : Immovable, IChest
  10. {
  11. public Chest(XY initPos) :
  12. base(initPos, GameData.numOfPosGridPerCell / 2, GameObjType.Chest)
  13. {
  14. }
  15. public override bool IsRigid => true;
  16. public override ShapeType Shape => ShapeType.Square;
  17. private readonly Gadget[] propInChest = new Gadget[GameData.maxNumOfPropInChest] { new NullProp(), new NullProp() };
  18. public Gadget[] PropInChest => propInChest;
  19. private long openStartTime = 0;
  20. public long OpenStartTime
  21. {
  22. get
  23. {
  24. lock (gameObjLock) return openStartTime;
  25. }
  26. }
  27. private Character? whoOpen = null;
  28. public Character? WhoOpen
  29. {
  30. get
  31. {
  32. lock (gameObjLock) return whoOpen;
  33. }
  34. }
  35. public bool Open(Character character)
  36. {
  37. lock (gameObjLock)
  38. {
  39. if (whoOpen != null) return false;
  40. openStartTime = Environment.TickCount64;
  41. whoOpen = character;
  42. }
  43. return true;
  44. }
  45. public void StopOpen()
  46. {
  47. lock (gameObjLock)
  48. {
  49. whoOpen = null;
  50. }
  51. }
  52. }
  53. }