{
  "code": "import { EventManager, EventType } from \"./EventManager\";\r\nimport { GameState } from \"./GameManager\";\r\nexport class Queue {\r\n    constructor() {\r\n        this.players = [];\r\n        Queue.instance = this;\r\n        this.InitQueue();\r\n    }\r\n    static get Instance() {\r\n        if (Queue.instance) {\r\n            return Queue.instance;\r\n        }\r\n        else {\r\n            return new Queue();\r\n        }\r\n    }\r\n    InitQueue() {\r\n        EventManager.GameStateEventOn(GameState.Win, this, this.OnGameEnd);\r\n        EventManager.GameStateEventOn(GameState.End, this, this.OnGameOver);\r\n        EventManager.GameStateEventOn(GameState.Playing, this, this.OnGamePlaying);\r\n        EventManager.EventOn(EventType.CompleteStage, this, this.OnPlayerStageChange);\r\n    }\r\n    signup(runner) {\r\n        this.players.push(runner);\r\n    }\r\n    OnGamePlaying() {\r\n        Laya.timer.once(1000, this, () => {\r\n            Laya.timer.frameLoop(1, this, this.SortPlayer);\r\n        });\r\n    }\r\n    OnGameEnd() {\r\n        Laya.timer.clear(this, this.SortPlayer);\r\n    }\r\n    OnGameOver() {\r\n        this.players = [];\r\n        Laya.timer.clear(this, this.SortPlayer);\r\n    }\r\n    OnPlayerStageChange() {\r\n        for (var i = 0; i < this.players.length; i++) {\r\n            if (this.players[i].Ai) {\r\n                if (this.players[i].die) {\r\n                    this.players[i].Cheat();\r\n                }\r\n            }\r\n        }\r\n    }\r\n    SortPlayer() {\r\n        this.players.sort(this.Sort);\r\n        EventManager.EventTrigger(EventType.PlayerRank, [this.players]);\r\n        if (this.Champion == null || this.Champion.Id != this.players[0].Id) {\r\n            this.Champion = this.players[0];\r\n            EventManager.EventTrigger(EventType.crownchange, this.players[0].Id);\r\n            EventManager.EventTrigger(EventType.ScoreChange, this.GetPlayerScore);\r\n        }\r\n    }\r\n    get GetPlayerScore() {\r\n        for (var i = 0; i < this.players.length; i++) {\r\n            var player = this.players[i];\r\n            if (!player.Ai) {\r\n                return i + 1;\r\n            }\r\n        }\r\n    }\r\n    Sort(a, b) {\r\n        if (a.m_sprite.transform.position.z > b.m_sprite.transform.position.z) {\r\n            return -1;\r\n        }\r\n        else {\r\n            return 1;\r\n        }\r\n    }\r\n}\r\n//# sourceMappingURL=Queue.js.map",
  "references": [
    "C:/Users/admin/Desktop/runner/src/Scripts/Game/Runner.ts",
    "C:/Users/admin/Desktop/runner/src/Scripts/Game/EventManager.ts",
    "C:/Users/admin/Desktop/runner/src/Scripts/Game/GameManager.ts"
  ],
  "map": "{\"version\":3,\"file\":\"Queue.js\",\"sourceRoot\":\"\",\"sources\":[\"../../../../src/Scripts/Game/Queue.ts\"],\"names\":[],\"mappings\":\"AACA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,MAAM,OAAO,KAAK;IAGd;QAyBA,YAAO,GAAY,EAAE,CAAC;QAvBlB,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,SAAS,EAAE,CAAC;IACrB,CAAC;IACM,MAAM,KAAK,QAAQ;QAEtB,IAAG,KAAK,CAAC,QAAQ,EACjB;YACI,OAAO,KAAK,CAAC,QAAQ,CAAC;SACzB;aAED;YACI,OAAO,IAAI,KAAK,EAAE,CAAC;SACtB;IACL,CAAC;IAED,SAAS;QAEL,YAAY,CAAC,gBAAgB,CAAC,SAAS,CAAC,GAAG,EAAC,IAAI,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACjE,YAAY,CAAC,gBAAgB,CAAC,SAAS,CAAC,GAAG,EAAC,IAAI,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAClE,YAAY,CAAC,gBAAgB,CAAC,SAAS,CAAC,OAAO,EAAC,IAAI,EAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACzE,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,aAAa,EAAC,IAAI,EAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAChF,CAAC;IAID,MAAM,CAAC,M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