123456789101112131415161718 |
- {
- "code": "import { Building, buildtype } from \"./Building\";\r\nimport { EventManager, EventType } from \"./EventManager\";\r\nimport { ColliderLay } from \"./DataMaker\";\r\nimport { RigObj } from \"../Util/RigObj\";\r\nimport PoolManager from \"../Util/PoolManager\";\r\nimport { AssetManager } from \"./AssetManager\";\r\nimport { SceneManager } from \"./SceneManager\";\r\nimport { Shooter } from \"./Shooter\";\r\nimport { MonsterData } from \"./Warrior\";\r\nimport { LevelManager } from \"./LevelManager\";\r\nimport { AudioControl, VoiceType } from \"./AudioControl\";\r\nimport { TtSdk } from \"../Util/TtSdk\";\r\nexport class StandBuild extends Building {\r\n constructor() {\r\n super(...arguments);\r\n this.cut = false;\r\n }\r\n OnInit() {\r\n this.mcollider = this.cursprite.getChildAt(2).getComponent(Laya.PhysicsCollider);\r\n this.mcollider.collisionGroup = ColliderLay.obstacle;\r\n this.downsprite = this.cursprite.getChildAt(0);\r\n this.upsprite = this.cursprite.getChildAt(1);\r\n this.standnode = this.cursprite.getChildAt(3);\r\n var standpos = this.standnode.transform.position.clone();\r\n var pos = new Laya.Vector4(standpos.x, standpos.y, standpos.z, this.standnode.transform.rotationEuler.y);\r\n var shooterdata = new MonsterData(this.mdata.monsterid, pos);\r\n shooterdata.boos = this.mdata.boos;\r\n this.mshooter = Shooter.Create(shooterdata);\r\n this.mshooter.SkinShow(1, 6);\r\n this.OnReg();\r\n }\r\n OnReg() {\r\n EventManager.On(EventType.Cut, this, this.OnCut);\r\n if (this.uprig)\r\n this.uprig.Clear();\r\n if (this.downrig)\r\n this.downrig.Clear();\r\n if (this.copysprite)\r\n PoolManager.RecoverSprite3D(this.copysprite);\r\n }\r\n OnClear() {\r\n EventManager.Off(EventType.Cut, this, this.OnCut);\r\n if (this.copysprite)\r\n this.copysprite.destroy();\r\n if (!this.cut)\r\n this.mshooter.Clear();\r\n if (this.cuteffect)\r\n PoolManager.RecoverSprite3D(this.cuteffect);\r\n }\r\n OnCut(_collider) {\r\n if (this.mcollider != _collider || this.cut)\r\n return;\r\n this.BeCut();\r\n LevelManager.Instance.curlevel.gameroles.push(this.mshooter);\r\n this.mshooter.FallLand(this.cursprite.transform.position.y);\r\n }\r\n BeCut() {\r\n this.cut = true;\r\n TtSdk.Shake();\r\n AudioControl.PlayVoice(VoiceType.cut);\r\n var cutasset = AssetManager.effect.getValue(4);\r\n this.cuteffect = PoolManager.GetSprite3D(cutasset);\r\n SceneManager.mainscene.addChild(this.cuteffect);\r\n this.cuteffect.transform.position = this.upsprite.transform.position.clone();\r\n this.copysprite = PoolManager.GetSprite3D(AssetManager.BuildAsset(buildtype.stand, this.mdata.buildid));\r\n SceneManager.mainscene.addChild(this.copysprite);\r\n this.copysprite.transform.position = this.cursprite.transform.position.clone();\r\n this.copysprite.transform.rotationEuler = this.cursprite.transform.rotationEuler.clone();\r\n var dieupsprite = this.copysprite.getChildAt(1);\r\n dieupsprite.active = false;\r\n this.downrig = new RigObj(this.copysprite, null, 1);\r\n this.downrig.minhight = 1;\r\n this.downrig.AddForce(new Laya.Vector3(0, 1, 0.1), 0.5);\r\n this.downsprite.active = false;\r\n this.uprig = new RigObj(this.cursprite, () => {\r\n this.Clear();\r\n }, 1.5, 1.5);\r\n this.uprig.minhight = 1;\r\n this.uprig.AddForce(new Laya.Vector3(0, 1, 0.4), 0.5);\r\n }\r\n}\r\n",
- "references": [
- "D:/Work/samurai2-laya/laya/samuraiflash-tt/src/Main/Building.ts",
- "D:/Work/samurai2-laya/laya/samuraiflash-tt/src/Main/EventManager.ts",
- "D:/Work/samurai2-laya/laya/samuraiflash-tt/src/Main/DataMaker.ts",
- "D:/Work/samurai2-laya/laya/samuraiflash-tt/src/Util/RigObj.ts",
- "D:/Work/samurai2-laya/laya/samuraiflash-tt/src/Util/PoolManager.ts",
- "D:/Work/samurai2-laya/laya/samuraiflash-tt/src/Main/AssetManager.ts",
- "D:/Work/samurai2-laya/laya/samuraiflash-tt/src/Main/SceneManager.ts",
- "D:/Work/samurai2-laya/laya/samuraiflash-tt/src/Main/Shooter.ts",
- "D:/Work/samurai2-laya/laya/samuraiflash-tt/src/Main/Warrior.ts",
- "D:/Work/samurai2-laya/laya/samuraiflash-tt/src/Main/LevelManager.ts",
- "D:/Work/samurai2-laya/laya/samuraiflash-tt/src/Main/AudioControl.ts",
- "D:/Work/samurai2-laya/laya/samuraiflash-tt/src/Util/TtSdk.ts"
- ]
- }
|