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

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 => openStartTime;
  21. private Character? whoOpen = null;
  22. public Character? WhoOpen => whoOpen;
  23. public bool Open(Character character)
  24. {
  25. lock (GameObjReaderWriterLock)
  26. {
  27. if (whoOpen != null) return false;
  28. openStartTime = Environment.TickCount64;
  29. whoOpen = character;
  30. }
  31. return true;
  32. }
  33. public void StopOpen()
  34. {
  35. lock (GameObjReaderWriterLock)
  36. {
  37. whoOpen = null;
  38. }
  39. }
  40. }
  41. }