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.

MapGameTimer.cs 974 B

1234567891011121314151617181920212223242526272829303132
  1. using System.Threading;
  2. using Preparation.Interface;
  3. namespace GameClass.GameObj
  4. {
  5. public partial class Map
  6. {
  7. // xfgg说:爱因斯坦说,每个坐标系都有与之绑定的时钟,(x, y, z, ict) 构成四维时空坐标,在洛伦兹变换下满足矢量性(狗头)
  8. private readonly GameTimer timer = new();
  9. public ITimer Timer => timer;
  10. public class GameTimer : ITimer
  11. {
  12. private bool isGaming = false;
  13. public bool IsGaming => isGaming;
  14. readonly object isGamingLock = new();
  15. public bool StartGame(int timeInMilliseconds)
  16. {
  17. lock (isGamingLock)
  18. {
  19. if (isGaming)
  20. return false;
  21. isGaming = true;
  22. }
  23. Thread.Sleep(timeInMilliseconds);
  24. isGaming = false;
  25. return true;
  26. }
  27. }
  28. }
  29. }