123456789 |
- {
- "code": "var Vector3 = Laya.Vector3;\r\nimport { Mathf } from \"../Util/Mathf\";\r\nimport { PoolManager } from \"./PoolManager\";\r\nimport GameManager from \"./GameManager\";\r\nexport class PlayerBullet extends Laya.Script3D {\r\n constructor() {\r\n super(...arguments);\r\n this.isStartCollider = false;\r\n this.speed = 2;\r\n this.forW = Mathf.VecZero;\r\n this.quaternion1 = new Laya.Quaternion;\r\n }\r\n onAwake() {\r\n this.selfobj = this.owner;\r\n this.tran = this.selfobj.transform;\r\n this.isStartCollider = false;\r\n }\r\n SetStartP(t, tarPos) {\r\n Laya.timer.once(1000, this, this.Des);\r\n this.isStartCollider = true;\r\n this.tran.position = t.position.clone();\r\n Vector3.subtract(tarPos, this.tran.position, this.forW);\r\n Vector3.normalize(this.forW, this.forW);\r\n this.forW = new Vector3(this.forW.x * this.speed, this.forW.y * this.speed, this.forW.z * this.speed);\r\n Laya.Quaternion.lookAt(tarPos, this.tran.position, new Vector3(0, 1, 0), this.quaternion1);\r\n this.quaternion1.invert(this.quaternion1);\r\n this.tran.rotation = this.quaternion1.clone();\r\n Laya.timer.frameLoop(1, this, this._MOVE);\r\n }\r\n _MOVE() {\r\n if (GameManager.Instance.isgamePause)\r\n return;\r\n this.tran.translate(this.forW, false);\r\n }\r\n onTriggerEnter() {\r\n if (!this.isStartCollider)\r\n return;\r\n this.Des();\r\n console.log(\"玩家子弹碰撞\");\r\n }\r\n Des() {\r\n PoolManager.Instance.SetDisableObject(this.selfobj);\r\n this.destroy();\r\n }\r\n onDestroy() {\r\n Laya.timer.clearAll(this);\r\n }\r\n}\r\n",
- "references": [
- "D:/GitProject/GunGang/gungang_laya/gungang/src/Util/Mathf.ts",
- "D:/GitProject/GunGang/gungang_laya/gungang/src/GameLogic/PoolManager.ts",
- "D:/GitProject/GunGang/gungang_laya/gungang/src/GameLogic/GameManager.ts"
- ]
- }
|