080306dd3dbd7d30ee0bbf0743dfb62ec8f53c92 7.6 KB

123456789
  1. {
  2. "code": "var Vector3 = Laya.Vector3;\r\nimport { EventManager, EventType } from \"./EventManager\";\r\nimport { GameState, TouchState } from \"./DataMaker\";\r\nexport class InputManager {\r\n constructor() {\r\n this.curtouthstate = TouchState.none;\r\n this.touchPos = new Vector3();\r\n this.curMousePos = new Vector3(0, 0, 0);\r\n this.sliderawakesize = 5;\r\n this.curdir = new Vector3();\r\n this.curtouchpos = new Vector3();\r\n InputManager.instance = this;\r\n this.Init();\r\n }\r\n static get Instance() {\r\n return InputManager.instance;\r\n }\r\n Init() {\r\n Laya.stage.on(Laya.Event.MOUSE_DOWN, this, this.TouchEnter);\r\n Laya.stage.on(Laya.Event.MOUSE_UP, this, this.OnTouchOut);\r\n Laya.stage.on(Laya.Event.MOUSE_OUT, this, this.OnTouchOut);\r\n EventManager.GameOn(GameState.Ready, this, this.OnGameReady);\r\n EventManager.GameOn(GameState.Playing, this, this.OnGamePlaying);\r\n EventManager.GameOn(GameState.Resurrection, this, this.OnGameResurrection);\r\n EventManager.GameOn(GameState.Lose, this, this.OnGameLose);\r\n EventManager.GameOn(GameState.Win, this, this.OnGameWin);\r\n }\r\n OnGameReady() {\r\n Laya.timer.clear(this, this.OnTouchMove);\r\n this.curtouthstate = TouchState.down;\r\n InputManager.caninput = true;\r\n }\r\n OnGamePlaying() {\r\n InputManager.caninput = true;\r\n }\r\n OnGameResurrection() {\r\n Laya.timer.clear(this, this.OnTouchMove);\r\n this.curtouthstate = TouchState.down;\r\n InputManager.caninput = false;\r\n }\r\n OnGameLose() {\r\n Laya.timer.clear(this, this.OnTouchMove);\r\n this.curtouthstate = TouchState.down;\r\n InputManager.caninput = false;\r\n }\r\n OnGameWin() {\r\n Laya.timer.clear(this, this.OnTouchMove);\r\n this.curtouthstate = TouchState.down;\r\n InputManager.caninput = false;\r\n }\r\n TouchEnter(e) {\r\n this.curtouthstate = TouchState.down;\r\n EventManager.Trigger(EventType.InputState, [this.curtouthstate]);\r\n if (!InputManager.caninput)\r\n return;\r\n this.curtouchpos = new Laya.Vector3(Laya.MouseManager.instance.mouseX, Laya.MouseManager.instance.mouseY, 0);\r\n Laya.timer.clear(this, this.OnTouchMove);\r\n EventManager.InputTrigger(TouchState.down, [this.curMousePos]);\r\n Laya.timer.frameLoop(1, this, this.OnTouchMove);\r\n }\r\n OnTouchOut() {\r\n this.curtouthstate = TouchState.up;\r\n EventManager.Trigger(EventType.InputState, [this.curtouthstate]);\r\n if (!InputManager.caninput)\r\n return;\r\n Laya.timer.clear(this, this.OnTouchMove);\r\n EventManager.InputTrigger(TouchState.up);\r\n }\r\n OnTouchMove() {\r\n this.curtouthstate = TouchState.slider;\r\n EventManager.Trigger(EventType.InputState, [this.curtouthstate]);\r\n if (!InputManager.caninput)\r\n return;\r\n this.curMousePos = new Laya.Vector3(Laya.MouseManager.instance.mouseX, Laya.MouseManager.instance.mouseY, 0);\r\n var distance = Vector3.distance(this.curtouchpos, this.curMousePos);\r\n if (distance > this.sliderawakesize) {\r\n Vector3.subtract(this.curtouchpos, this.curMousePos, this.curdir);\r\n Vector3.normalize(this.curdir, this.curdir);\r\n EventManager.InputTrigger(TouchState.slider, [new Vector3(this.curdir.x, 0, this.curdir.y)]);\r\n }\r\n }\r\n}\r\nInputManager.caninput = false;\r\n//# sourceMappingURL=InputManager.js.map",
  3. "references": [
  4. "D:/Work/samurai2-laya/laya/samuraiflash-tt/src/Main/EventManager.ts",
  5. "D:/Work/samurai2-laya/laya/samuraiflash-tt/src/Main/DataMaker.ts"
  6. ],
  7. "map": "{\"version\":3,\"file\":\"InputManager.js\",\"sourceRoot\":\"\",\"sources\":[\"../../../src/Main/InputManager.ts\"],\"names\":[],\"mappings\":\"AAAA,IAAO,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;AAG9B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAC,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,UAAU,EA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