0945a88a12e47c78e6da3536c89791a11e9f1da1 7.1 KB

12345678910111213141516171819202122
  1. {
  2. "code": "import { ui } from \"../ui/layaMaxUI\";\r\nimport { EventManager, EventType } from \"../GameLogic/EventManager\";\r\nimport PlayerController from \"../GameLogic/PlayerController\";\r\nimport { PlayerManager } from \"../GameLogic/PlayerManager\";\r\nimport AIController from \"../GameLogic/AIController\";\r\nimport GameManager from \"../GameLogic/GameManager\";\r\nimport { SettingController } from \"../GameLogic/SettingController\";\r\nimport Game_Tool from \"../Util/Game_Tool\";\r\nexport default class GameUi extends ui.GameUiUI {\r\n constructor() {\r\n super();\r\n this.curEnemyIndex = 0;\r\n this.enemyCount = 0;\r\n this.enemyUiboxWidth = 45;\r\n this.bulletBoxHeight = 21;\r\n this.enemyArr = [];\r\n this.bulletArr = [];\r\n this.bulletImage = [];\r\n this.tempbulletCount = 0;\r\n this.tempindex = 0;\r\n GameUi.instance = this;\r\n this.resizeHander();\r\n EventManager.on(Laya.Event.RESIZE, this, this.resizeHander);\r\n }\r\n static get Instance() {\r\n return GameUi.instance;\r\n }\r\n OnShow(data) {\r\n SettingController.Instance._playMusic();\r\n this.InitDate();\r\n this.InitHandler();\r\n this.InitUi();\r\n this.SetGuide(false);\r\n }\r\n resizeHander() {\r\n this.height = Laya.stage.height;\r\n }\r\n InitDate() {\r\n this.enemyCount = AIController.Instance.teams.length;\r\n if (!GameManager.Instance.isguide)\r\n this.enemyCount -= 2;\r\n for (let index = 0; index < this.enemyCount; index++) {\r\n this.enemyArr.push(index);\r\n }\r\n for (let index = 0; index < PlayerManager.bulletCount; index++) {\r\n this.bulletArr.push(index);\r\n }\r\n this.tempbulletCount = PlayerManager.bulletCount;\r\n }\r\n InitHandler() {\r\n EventManager.on(EventType.Event.SetAimPos, this, this.SetAimPos);\r\n EventManager.on(EventType.Event.RefreshBulletCount, this, this.RefreshBulletCount);\r\n EventManager.on(EventType.Event.RefreshRemainEnemyCount, this, this.RefreshRemainEnemyCount);\r\n EventManager.on(EventType.Event.GameShowTips, this, this.ShowCrit);\r\n this.enemyCountList.selectEnable = false;\r\n this.enemyCountList.renderHandler = Laya.Handler.create(this, this.updateItem, null, true);\r\n this.enemyCountList.array = this.enemyArr;\r\n this.bulletCountList.selectEnable = false;\r\n this.bulletCountList.renderHandler = Laya.Handler.create(this, this.updateItem, null, true);\r\n this.bulletCountList.array = this.bulletArr;\r\n this.once(Laya.Event.MOUSE_DOWN, this, this.HideTips);\r\n }\r\n HideTips() {\r\n this._tips.visible = false;\r\n }\r\n ShowCrit(p) {\r\n this.crit.pos(p.x, p.y);\r\n this.ani1.play(0, false);\r\n this.ShowTIPS();\r\n }\r\n ShowTIPS() {\r\n Laya.timer.once(200, this, () => {\r\n let skin = \"gameRes/tips_\" + Game_Tool.randomInt(1, 4) + \".png\";\r\n this.tips.skin = skin;\r\n this.ani2.play(0, false);\r\n });\r\n }\r\n updateItem() {\r\n }\r\n SetAimPos(pos) {\r\n this.aim.pos(pos.x, pos.y);\r\n }\r\n RefreshRemainEnemyCount() {\r\n if (!GameManager.Instance.isguide) {\r\n this.tempindex++;\r\n if (this.tempindex == 2) {\r\n GameManager.Instance.EndGuide(this.tempbulletCount);\r\n this.bulletCountList.visible = true;\r\n this.topBox.visible = true;\r\n }\r\n return;\r\n }\r\n let box = this.enemyCountList.getCell(this.curEnemyIndex);\r\n box.getChildAt(1).visible = true;\r\n this.curEnemyIndex++;\r\n }\r\n InitUi() {\r\n this.aim.visible = true;\r\n this.stageValue.text = \"第 \" + PlayerManager.Instance.stage + \" 关\";\r\n this.enemyCountList.width = this.enemyCount * this.enemyUiboxWidth;\r\n this.bulletCountList.height = PlayerManager.bulletCount * this.bulletBoxHeight;\r\n for (let index = PlayerManager.bulletCount - 1; index >= 0; index--) {\r\n let box = this.bulletCountList.getCell(index);\r\n let _image = box.getChildAt(1);\r\n this.bulletImage.push(_image);\r\n }\r\n this.RedWarn();\r\n }\r\n RedWarn() {\r\n if (PlayerManager.Instance.stage % 10 != 0)\r\n return;\r\n this.bossWarn.visible = true;\r\n this.red.play(0, true);\r\n Laya.timer.once(3500, this, () => {\r\n this.red.stop();\r\n this.redWarn.visible = false;\r\n });\r\n }\r\n RefreshBulletCount() {\r\n if (!GameManager.Instance.isguide)\r\n return;\r\n if (PlayerManager.bulletCount - PlayerController.Instance.curbulletCount == 0)\r\n this.bulletImage.forEach(element => {\r\n element.visible = true;\r\n });\r\n else {\r\n this.bulletImage[PlayerController.Instance.curbulletCount].visible = false;\r\n }\r\n }\r\n SetGuide(isshow) {\r\n if (GameManager.Instance.isguide)\r\n return;\r\n this.bulletCountList.visible = isshow;\r\n this.topBox.visible = isshow;\r\n GameManager.Instance.StartGuide();\r\n }\r\n OnClose() {\r\n EventManager.off(EventType.Event.RefreshBulletCount, this, this.RefreshBulletCount);\r\n EventManager.off(Laya.Event.RESIZE, this, this.resizeHander);\r\n EventManager.off(EventType.Event.SetAimPos, this, this.SetAimPos);\r\n EventManager.off(EventType.Event.RefreshRemainEnemyCount, this, this.RefreshRemainEnemyCount);\r\n EventManager.off(EventType.Event.GameShowTips, this, this.ShowCrit);\r\n GameUi.instance = null;\r\n Laya.timer.clearAll(this);\r\n }\r\n}\r\n",
  3. "references": [
  4. "D:/GitProject/GunGang/gungang_laya/gungang/src/ui/layaMaxUI.ts",
  5. "D:/GitProject/GunGang/gungang_laya/gungang/src/GameLogic/EventManager.ts",
  6. "D:/GitProject/GunGang/gungang_laya/gungang/src/GameLogic/SceneController.ts",
  7. "D:/GitProject/GunGang/gungang_laya/gungang/src/GameLogic/PlayerController.ts",
  8. "D:/GitProject/GunGang/gungang_laya/gungang/src/GameLogic/DefinedType.ts",
  9. "D:/GitProject/GunGang/gungang_laya/gungang/src/GameLogic/CameraBehavior.ts",
  10. "D:/GitProject/GunGang/gungang_laya/gungang/src/GameLogic/AimController.ts",
  11. "D:/GitProject/GunGang/gungang_laya/gungang/src/GameLogic/InputController.ts",
  12. "D:/GitProject/GunGang/gungang_laya/gungang/src/GameLogic/LevelController.ts",
  13. "D:/GitProject/GunGang/gungang_laya/gungang/src/GameLogic/PlayerManager.ts",
  14. "D:/GitProject/GunGang/gungang_laya/gungang/src/GameLogic/AIController.ts",
  15. "D:/GitProject/GunGang/gungang_laya/gungang/src/GameLogic/GameManager.ts",
  16. "D:/GitProject/GunGang/gungang_laya/gungang/src/game_module/UserModel.ts",
  17. "D:/GitProject/GunGang/gungang_laya/gungang/src/game_module/NetManager.ts",
  18. "D:/GitProject/GunGang/gungang_laya/gungang/src/GameLogic/SettingController.ts",
  19. "D:/GitProject/GunGang/gungang_laya/gungang/src/Util/Game_Tool.ts"
  20. ]
  21. }