{
  "code": "import { GameManager } from \"./GameManager\";\r\nvar Vector2 = Laya.Vector2;\r\nexport default class Ball extends Laya.Script {\r\n    constructor() {\r\n        super();\r\n        this.TargetArray = [];\r\n        this.cleared = false;\r\n        this.mark = false;\r\n        this.clear = false;\r\n        Ball.ins = this;\r\n    }\r\n    static get Instance() {\r\n        if (Ball.ins) {\r\n            return Ball.ins;\r\n        }\r\n        else {\r\n            return new Ball();\r\n        }\r\n    }\r\n    onAwake() {\r\n    }\r\n    onEnable() {\r\n        this.TargetArray = [];\r\n        this.cleared = false;\r\n        this.owner.on(Laya.Event.CLICK, this, this.ClickBall);\r\n    }\r\n    onUpdate() {\r\n        if (this.clear) {\r\n            let _rig = this.owner.getComponent(Laya.RigidBody);\r\n            let _collider = this.owner.getComponent(Laya.CircleCollider);\r\n            _collider.isSensor = true;\r\n            _collider.enabled = false;\r\n            _rig.enabled = false;\r\n            this.Move(GameManager.Instance.TargetPosition);\r\n            this.cleared = true;\r\n        }\r\n    }\r\n    onDestroy() {\r\n        this.owner.off(Laya.Event.CLICK, this, this.TweenMerge);\r\n    }\r\n    onTriggerEnter(other) {\r\n        let targetparent = other.owner;\r\n        if (targetparent.name != \"RightCollider\" && targetparent.name != \"LeftCollider\" && targetparent.name != \"BottomCollider\") {\r\n            let num = targetparent.getChildByName(\"num\");\r\n            let ownernum = this.owner.getChildByName(\"num\");\r\n            if (Number(num.value) == Number(ownernum.value)) {\r\n                this.TargetArray.push(targetparent);\r\n            }\r\n        }\r\n    }\r\n    onTriggerStay(other) {\r\n        let targetparent = other.owner;\r\n        if (targetparent.name != \"RightCollider\" && targetparent.name != \"LeftCollider\" && targetparent.name != \"BottomCollider\") {\r\n            let num = targetparent.getChildByName(\"num\");\r\n            let ownernum = this.owner.getChildByName(\"num\");\r\n            if (Number(num.value) == Number(ownernum.value)) {\r\n                this.TargetArray.push(targetparent);\r\n            }\r\n        }\r\n    }\r\n    onTriggerExit(other) {\r\n        let targetparent = other.owner;\r\n        if (targetparent.name != \"RightCollider\" && targetparent.name != \"LeftCollider\" && targetparent.name != \"BottomCollider\") {\r\n            for (let i = this.TargetArray.length - 1; i > -1; i--) {\r\n                if (this.TargetArray[i] == other) {\r\n                    this.TargetArray.splice(i, 1);\r\n                }\r\n            }\r\n        }\r\n    }\r\n    Move(_position) {\r\n        if (!this.cleared) {\r\n            let owner = this.owner;\r\n            let move = Laya.Tween.to(this.owner, {\r\n                x: _position.x, y: _position.y, update: new Laya.Handler(this, function () {\r\n                })\r\n            }, 200, Laya.Ease.linearInOut, Laya.Handler.create(this, () => {\r\n                move.clear();\r\n                this.owner.removeSelf();\r\n                this.owner.destroy();\r\n            }));\r\n        }\r\n    }\r\n    TweenMerge() {\r\n    }\r\n    ClickBall() {\r\n        console.log(\"点击到球了--\");\r\n        for (let j = this.TargetArray.length - 1; j > -1; j--) {\r\n            if (this.TargetArray[j].destroyed) {\r\n                this.TargetArray.splice(j, 1);\r\n            }\r\n        }\r\n        let owner = this.owner;\r\n        GameManager.Instance.TargetPosition = new Vector2(owner.x, owner.y);\r\n        this.DisPose(owner);\r\n        for (let i = 0; i < this.TargetArray.length; i++) {\r\n        }\r\n    }\r\n    DisPose(_node) {\r\n        let ball = _node.getComponent(Ball);\r\n        if (ball.TargetArray.length > 0) {\r\n            for (let i = 0; i < ball.TargetArray.length; i++) {\r\n                if (ball.TargetArray[i].getComponent(Ball).mark)\r\n                    continue;\r\n                let target = ball.TargetArray[i];\r\n                let ball2 = target.getComponent(Ball);\r\n                if (ball2.TargetArray.length > 0) {\r\n                    for (let j = 0; j < ball2.TargetArray.length; j++) {\r\n                        if (ball2.TargetArray[j] == _node) {\r\n                            continue;\r\n                        }\r\n                        ball2.clear = true;\r\n                        ball2.mark = true;\r\n                        this.DisPose(ball2.TargetArray[j]);\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n//# sourceMappingURL=Ball.js.map",
  "references": [
    "E:/LayaProject/BlastToMerge/src/Tool/GameTools.ts",
    "E:/LayaProject/BlastToMerge/src/Main/GameManager.ts",
    "E:/LayaProject/BlastToMerge/src/View/InGameView.ts"
  ],
  "map": "{\"version\":3,\"file\":\"Ball.js\",\"sourceRoot\":\"\",\"sources\":[\"../../../src/Main/Ball.ts\"],\"names\":[],\"mappings\":\"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,IAAO,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;AAE9B,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,IAAI,CAAC,MAAM;IASzC;QACI,KAAK,EAAE,CAAC;QAPL,gBAAW,GAAG,EAAE,CAAC;QACf,YAAO,GAAG,KAAK,CAAC;QAElB,SAAI,GAAG,KAAK,CAAC;QAEZ,UAAK,GAAG,KAAK,CAAC;QAGlB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC;IACpB,CAAC;IACM,MAAM,KAAK,QAAQ;QACtB,IAAG,IAAI,CAAC,GAAG,EAAC;YACR,OAAO,IAAI,CAAC,GAAG,CAAA;SAClB;aACG;YACA,OAAO,IAAI,IAAI,EAAE,CAAC;SACrB;IACL,CAAC;IACD,OAAO;IAEP,CAAC;IACD,QAAQ;QACJ,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAC,IAAI,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAIxD,CAAC;IACD,QAAQ;QACJ,IAAG,IAAI,CAAC,KAAK,EAAC;YACV,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAmB,CAAC;YACrE,IAAI,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,cAAc,CAAwB,CAAC;YACpF,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC;YAC1B,SAAS,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