System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3", "__unresolved_4", "__unresolved_5", "__unresolved_6", "__unresolved_7", "__unresolved_8", "__unresolved_9", "__unresolved_10", "__unresolved_11", "__unresolved_12", "__unresolved_13", "__unresolved_14", "__unresolved_15"], function (_export, _context) {
  "use strict";

  var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, geometry, Node, Camera, view, instantiate, v3, tween, RigidBody, MeshRenderer, Vec3, find, input, Input, Tween, PhysicsSystem, ComponentEx, Utils, TileItem, GameConst, ITEM_TYPE, WindowManager, GameEvent, MsgHints, Data, BusyLoadingManager, BUSY_TYPE, Main, levelsData, platformSystem, constants, audioManager, utils, _dec, _dec2, _class, _class2, _descriptor, _crd, Ray, ccclass, property, executeInEditMode, GameNode;

  function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }

  function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }

  function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); }

  function _reportPossibleCrUseOfComponentEx(extras) {
    _reporterNs.report("ComponentEx", "../../core/component/ComponentEx", _context.meta, extras);
  }

  function _reportPossibleCrUseOfUtils(extras) {
    _reporterNs.report("Utils", "../../core/utils/Utils", _context.meta, extras);
  }

  function _reportPossibleCrUseOfTileItem(extras) {
    _reporterNs.report("TileItem", "./TileItem", _context.meta, extras);
  }

  function _reportPossibleCrUseOfGameConst(extras) {
    _reporterNs.report("GameConst", "../../core/common/GameConst", _context.meta, extras);
  }

  function _reportPossibleCrUseOfITEM_TYPE(extras) {
    _reporterNs.report("ITEM_TYPE", "../../core/common/GameConst", _context.meta, extras);
  }

  function _reportPossibleCrUseOfWindowManager(extras) {
    _reporterNs.report("WindowManager", "../../core/manager/WindowManager", _context.meta, extras);
  }

  function _reportPossibleCrUseOfDrawStarLayer(extras) {
    _reporterNs.report("DrawStarLayer", "./gameui/DrawStarLayer", _context.meta, extras);
  }

  function _reportPossibleCrUseOfGameEvent(extras) {
    _reporterNs.report("GameEvent", "../../core/event/GameEvent", _context.meta, extras);
  }

  function _reportPossibleCrUseOfMsgHints(extras) {
    _reporterNs.report("MsgHints", "../../core/utils/MsgHints", _context.meta, extras);
  }

  function _reportPossibleCrUseOfData(extras) {
    _reporterNs.report("Data", "../../core/manager/Data", _context.meta, extras);
  }

  function _reportPossibleCrUseOfBusyLoadingManager(extras) {
    _reporterNs.report("BusyLoadingManager", "../../core/manager/BusyLoadingManager", _context.meta, extras);
  }

  function _reportPossibleCrUseOfBUSY_TYPE(extras) {
    _reporterNs.report("BUSY_TYPE", "../../core/manager/BusyLoadingManager", _context.meta, extras);
  }

  function _reportPossibleCrUseOfMain(extras) {
    _reporterNs.report("Main", "./Main", _context.meta, extras);
  }

  function _reportPossibleCrUseOflevelsData(extras) {
    _reporterNs.report("levelsData", "db://assets/data/levelsData", _context.meta, extras);
  }

  function _reportPossibleCrUseOfplatformSystem(extras) {
    _reporterNs.report("platformSystem", "db://assets/platform/platformSystem", _context.meta, extras);
  }

  function _reportPossibleCrUseOfconstants(extras) {
    _reporterNs.report("constants", "db://assets/data/constants", _context.meta, extras);
  }

  function _reportPossibleCrUseOfaudioManager(extras) {
    _reporterNs.report("audioManager", "db://assets/manager/audioManager", _context.meta, extras);
  }

  function _reportPossibleCrUseOfutils(extras) {
    _reporterNs.report("utils", "db://assets/data/utils", _context.meta, extras);
  }

  return {
    setters: [function (_unresolved_) {
      _reporterNs = _unresolved_;
    }, function (_cc) {
      _cclegacy = _cc.cclegacy;
      __checkObsolete__ = _cc.__checkObsolete__;
      __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
      _decorator = _cc._decorator;
      geometry = _cc.geometry;
      Node = _cc.Node;
      Camera = _cc.Camera;
      view = _cc.view;
      instantiate = _cc.instantiate;
      v3 = _cc.v3;
      tween = _cc.tween;
      RigidBody = _cc.RigidBody;
      MeshRenderer = _cc.MeshRenderer;
      Vec3 = _cc.Vec3;
      find = _cc.find;
      input = _cc.input;
      Input = _cc.Input;
      Tween = _cc.Tween;
      PhysicsSystem = _cc.PhysicsSystem;
    }, function (_unresolved_2) {
      ComponentEx = _unresolved_2.ComponentEx;
    }, function (_unresolved_3) {
      Utils = _unresolved_3.default;
    }, function (_unresolved_4) {
      TileItem = _unresolved_4.TileItem;
    }, function (_unresolved_5) {
      GameConst = _unresolved_5.default;
      ITEM_TYPE = _unresolved_5.ITEM_TYPE;
    }, function (_unresolved_6) {
      WindowManager = _unresolved_6.default;
    }, function (_unresolved_7) {
      GameEvent = _unresolved_7.default;
    }, function (_unresolved_8) {
      MsgHints = _unresolved_8.default;
    }, function (_unresolved_9) {
      Data = _unresolved_9.default;
    }, function (_unresolved_10) {
      BusyLoadingManager = _unresolved_10.default;
      BUSY_TYPE = _unresolved_10.BUSY_TYPE;
    }, function (_unresolved_11) {
      Main = _unresolved_11.Main;
    }, function (_unresolved_12) {
      levelsData = _unresolved_12.default;
    }, function (_unresolved_13) {
      platformSystem = _unresolved_13.default;
    }, function (_unresolved_14) {
      constants = _unresolved_14.constants;
    }, function (_unresolved_15) {
      audioManager = _unresolved_15.default;
    }, function (_unresolved_16) {
      utils = _unresolved_16.utils;
    }],
    execute: function () {
      _crd = true;

      _cclegacy._RF.push({}, "a2d93SPQfJDU4bqNJGq/PnA", "GameNode", undefined);

      __checkObsolete__(['_decorator', 'geometry', 'Node', 'Camera', 'view', 'EventTouch', 'Prefab', 'instantiate', 'v3', 'tween', 'RigidBody', 'MeshRenderer', 'Vec3', 'find', 'input', 'Input', 'Tween', 'PhysicsSystem', 'physics', 'PhysicsSystem2D', 'EPhysics2DDrawFlags', 'director']);

      ({
        Ray
      } = geometry);
      ({
        ccclass,
        property,
        executeInEditMode
      } = _decorator);

      _export("GameNode", GameNode = (_dec = ccclass('GameNode'), _dec2 = property({
        type: Node,
        tooltip: "底部的盘子"
      }), _dec(_class = (_class2 = class GameNode extends (_crd && ComponentEx === void 0 ? (_reportPossibleCrUseOfComponentEx({
        error: Error()
      }), ComponentEx) : ComponentEx) {
        constructor(...args) {
          super(...args);

          _initializerDefineProperty(this, "plate", _descriptor, this);

          this.collectpos = [];
          this.collectTiles = [];
          this.allTiles = [];
          this.optionTiles = [];
          this.lock = false;
          this.touchTileItem = null;
        }

        start() {
          setTimeout(() => {
            this.initWall();
            this.collectpos = [];
            this.GetNode("collectbox").children.map(a => {
              this.collectpos.push(a.worldPosition);
              a.active = false;
            });
          }, 100);
          (_crd && GameEvent === void 0 ? (_reportPossibleCrUseOfGameEvent({
            error: Error()
          }), GameEvent) : GameEvent).Instance().register(this, (_crd && GameConst === void 0 ? (_reportPossibleCrUseOfGameConst({
            error: Error()
          }), GameConst) : GameConst).CLEAR_ALL_BOX, () => {
            console.log("清空盒子");
            this.lock = false;
            setTimeout(() => {
              for (let i = 0; i < this.collectTiles.length; ++i) {
                this.pushBask(this.collectTiles[i].name);
              }

              this.collectTiles.map(a => {
                a.destroy();
              });
              this.collectTiles = [];
            }, 500);
          }); //提示

          (_crd && GameEvent === void 0 ? (_reportPossibleCrUseOfGameEvent({
            error: Error()
          }), GameEvent) : GameEvent).Instance().register(this, (_crd && GameConst === void 0 ? (_reportPossibleCrUseOfGameConst({
            error: Error()
          }), GameConst) : GameConst).USE_ITEM_HINT, this.prompt.bind(this));
        }

        onEnable() {
          input.on(Input.EventType.TOUCH_START, this.onTouchStart, this);
          input.on(Input.EventType.TOUCH_END, this.onTouchEnd, this);
          input.on(Input.EventType.TOUCH_MOVE, this.onTouchMove, this);
        }

        onDisable() {
          input.off(Input.EventType.TOUCH_START, this.onTouchStart, this);
          input.off(Input.EventType.TOUCH_END, this.onTouchEnd, this);
          input.off(Input.EventType.TOUCH_MOVE, this.onTouchMove, this);
        }

        moveToRightPos() {
          //移动到正确位置
          this.collectTiles.map((a, i) => {
            let tileItem = a.getComponent(_crd && TileItem === void 0 ? (_reportPossibleCrUseOfTileItem({
              error: Error()
            }), TileItem) : TileItem);
            Tween.stopAllByTarget(a);
            tween(a).to(0.3, {
              worldPosition: this.collectpos[i].clone(),
              worldScale: v3(1, 1, 1)
            }).call(() => {
              tileItem.auto_rotation = true;

              if (tileItem.removed) {
                (_crd && utils === void 0 ? (_reportPossibleCrUseOfutils({
                  error: Error()
                }), utils) : utils).remove(this.optionTiles, a);
                tween(a).to(0.25, {
                  worldPosition: tileItem.removedPos
                }, {
                  easing: 'backIn'
                }).call(async () => {
                  //最中央的播放移除特效
                  if (tileItem.playRmovedEff) {
                    //增加星星
                    let pos = this.GetNode("Main Camera").getComponent(Camera).convertToUINode(a.worldPosition, find("Canvas"));
                    let node_ani = await (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
                      error: Error()
                    }), Utils) : Utils).playSkAni("effect_hecheng", "effect", find("Canvas"), pos);
                    (_crd && audioManager === void 0 ? (_reportPossibleCrUseOfaudioManager({
                      error: Error()
                    }), audioManager) : audioManager).playOneShot((_crd && constants === void 0 ? (_reportPossibleCrUseOfconstants({
                      error: Error()
                    }), constants) : constants).audios.starCollect);
                    (_crd && platformSystem === void 0 ? (_reportPossibleCrUseOfplatformSystem({
                      error: Error()
                    }), platformSystem) : platformSystem).platform.vibrateShort();
                    (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
                      error: Error()
                    }), Utils) : Utils).flyAnim((_crd && ITEM_TYPE === void 0 ? (_reportPossibleCrUseOfITEM_TYPE({
                      error: Error()
                    }), ITEM_TYPE) : ITEM_TYPE).Star, node_ani, (_crd && Main === void 0 ? (_reportPossibleCrUseOfMain({
                      error: Error()
                    }), Main) : Main).Instance()._GameUI.starNode, 1, 0, b => {
                      if (b) {
                        node_ani.destroy();
                        (_crd && Main === void 0 ? (_reportPossibleCrUseOfMain({
                          error: Error()
                        }), Main) : Main).Instance()._GameUI.star++;
                      }
                    });
                  }

                  a.destroy();
                  this.moveToRightPos();
                  this.checkResult();
                }).start();
              }
            }).start();
          });
        }

        chooseTile(tile) {
          let chooseName = tile.name;
          this.optionTiles.push(tile); //删除点击对象从列表

          tile.getComponent(_crd && TileItem === void 0 ? (_reportPossibleCrUseOfTileItem({
            error: Error()
          }), TileItem) : TileItem).destoryCollider();

          for (var i = 0; i < this.allTiles.length; ++i) {
            if (this.allTiles[i] == tile) {
              this.allTiles.splice(i, 1);
              break;
            }
          } //插入


          let bInsert = false;

          for (var i = this.collectTiles.length - 1; i >= 0; --i) {
            if (this.collectTiles[i].name == chooseName) {
              this.collectTiles.splice(i + 1, 0, tile);
              bInsert = true;
              break;
            }
          }

          if (!bInsert) {
            this.collectTiles.push(tile);
          }

          this.moveToRightPos(); //检测要删除的

          let tmp = this.collectTiles.filter(a => {
            return a.name == chooseName;
          });

          if (tmp.length == 3) {
            for (var i = this.collectTiles.length - 1; i >= 0; --i) {
              if (this.collectTiles[i].name == chooseName) {
                let delNode = this.collectTiles[i];
                delNode.getComponent(_crd && TileItem === void 0 ? (_reportPossibleCrUseOfTileItem({
                  error: Error()
                }), TileItem) : TileItem).removed = true;
                this.collectTiles.splice(i, 1);
                delNode.getComponent(_crd && TileItem === void 0 ? (_reportPossibleCrUseOfTileItem({
                  error: Error()
                }), TileItem) : TileItem).removedPos = tmp[1].worldPosition;
                if (delNode == tmp[1]) delNode.getComponent(_crd && TileItem === void 0 ? (_reportPossibleCrUseOfTileItem({
                  error: Error()
                }), TileItem) : TileItem).playRmovedEff = true;
              }
            }
          }

          this.checkResult();
        }

        checkResult() {
          if (this.lock) return; //检测胜利和失败

          if (this.collectTiles.length >= 7) {
            this.lock = true;
            if (!(_crd && WindowManager === void 0 ? (_reportPossibleCrUseOfWindowManager({
              error: Error()
            }), WindowManager) : WindowManager).ins.isShow("OutOfBoxLayer")) (_crd && WindowManager === void 0 ? (_reportPossibleCrUseOfWindowManager({
              error: Error()
            }), WindowManager) : WindowManager).ins.open("OutOfBoxLayer");
          } else if (this.collectTiles.length == 0 && this.allTiles.length == 0) {
            this.lock = true;
            (_crd && WindowManager === void 0 ? (_reportPossibleCrUseOfWindowManager({
              error: Error()
            }), WindowManager) : WindowManager).ins.open("DrawStarLayer").then(com => {
              com.setStar((_crd && Main === void 0 ? (_reportPossibleCrUseOfMain({
                error: Error()
              }), Main) : Main).Instance()._GameUI.star);
            });
          }
        }

        onTouchStart(event) {
          if ((_crd && Main === void 0 ? (_reportPossibleCrUseOfMain({
            error: Error()
          }), Main) : Main).Instance()._GameUI.pasue) return;
          if ((_crd && Data === void 0 ? (_reportPossibleCrUseOfData({
            error: Error()
          }), Data) : Data).user.useMagnet) return;
          if (this.allTiles.length == 0) return;

          if (this.collectTiles.length >= 7) {
            return;
          }

          const p = event.getLocation();
          let camera = this.GetNode("Main Camera").getComponent(Camera);
          const r = new Ray();
          camera == null ? void 0 : camera.screenPointToRay(p.x, p.y, r);
          let b = PhysicsSystem.instance.raycastClosest(r, 1);

          if (b) {
            let collider = PhysicsSystem.instance.raycastClosestResult.collider;
            console.log(collider.node.name, collider.getComponent(RigidBody).group);
            let item = collider.node.parent.getComponent(_crd && TileItem === void 0 ? (_reportPossibleCrUseOfTileItem({
              error: Error()
            }), TileItem) : TileItem);

            if (item) {
              item.enableCollider = false;
              let pos = item.node.getWorldPosition();
              pos.y += 0.3;
              item.node.setWorldPosition(pos);
              this.touchTileItem = item;
            }
          }
        }

        onTouchEnd(event) {
          if ((_crd && Main === void 0 ? (_reportPossibleCrUseOfMain({
            error: Error()
          }), Main) : Main).Instance()._GameUI.pasue) return;
          if ((_crd && Data === void 0 ? (_reportPossibleCrUseOfData({
            error: Error()
          }), Data) : Data).user.useMagnet) return;
          if (!this.touchTileItem) return;
          if (this.allTiles.length == 0) return;

          if (this.collectTiles.length >= 7) {
            return;
          }

          const p = event.getLocation();
          let camera = this.GetNode("Main Camera").getComponent(Camera);
          const r = new Ray();
          camera == null ? void 0 : camera.screenPointToRay(p.x, p.y, r);
          let b = PhysicsSystem.instance.raycastClosest(r, 1);

          if (b) {
            let collider = PhysicsSystem.instance.raycastClosestResult.collider;
            let item = collider.node.parent.getComponent(_crd && TileItem === void 0 ? (_reportPossibleCrUseOfTileItem({
              error: Error()
            }), TileItem) : TileItem);

            if (item && item == this.touchTileItem) {
              (_crd && platformSystem === void 0 ? (_reportPossibleCrUseOfplatformSystem({
                error: Error()
              }), platformSystem) : platformSystem).platform.vibrateShort();
              this.chooseTile(item.node);
              this.touchTileItem = null;
              (_crd && audioManager === void 0 ? (_reportPossibleCrUseOfaudioManager({
                error: Error()
              }), audioManager) : audioManager).playOneShot((_crd && constants === void 0 ? (_reportPossibleCrUseOfconstants({
                error: Error()
              }), constants) : constants).audios.tap);
            } else {
              this.touchTileItem.enableCollider = true;
            }
          }
        }

        onTouchMove(event) {
          if ((_crd && Main === void 0 ? (_reportPossibleCrUseOfMain({
            error: Error()
          }), Main) : Main).Instance()._GameUI.pasue) return;
          if ((_crd && Data === void 0 ? (_reportPossibleCrUseOfData({
            error: Error()
          }), Data) : Data).user.useMagnet) return;
          if (this.allTiles.length == 0) return;

          if (this.collectTiles.length >= 7) {
            return;
          }

          const p = event.getLocation();
          let camera = this.GetNode("Main Camera").getComponent(Camera);
          const r = new Ray();
          camera == null ? void 0 : camera.screenPointToRay(p.x, p.y, r);
          let b = PhysicsSystem.instance.raycastClosest(r, 1);

          if (b) {
            let collider = PhysicsSystem.instance.raycastClosestResult.collider;
            let item = collider.node.parent.getComponent(_crd && TileItem === void 0 ? (_reportPossibleCrUseOfTileItem({
              error: Error()
            }), TileItem) : TileItem);

            if (item) {
              if (this.touchTileItem && item == this.touchTileItem) {} else {
                if (this.touchTileItem) this.touchTileItem.enableCollider = true;
                item.enableCollider = false;
                let pos = item.node.getWorldPosition();
                pos.y += 0.3; // console.log("切换")

                item.node.setWorldPosition(pos);
                this.touchTileItem = item;
              }
            } else {
              if (this.touchTileItem) {
                // console.log("无目标")
                this.touchTileItem.enableCollider = true;
                this.touchTileItem = null;
              }
            }
          }
        }

        initWall() {
          if (!PhysicsSystem.instance) return;
          const OFFSET = 25;
          let camera = this.GetNode("Main Camera").getComponent(Camera);
          const r = new Ray();
          let size = view.getCanvasSize(); //左边墙

          camera == null ? void 0 : camera.screenPointToRay(OFFSET, size.height / 2, r);

          if (PhysicsSystem.instance.raycastClosest(r)) {
            const result = PhysicsSystem.instance.raycastClosestResult;
            this.GetNode("PlaneLeft").setWorldPosition(result.hitPoint);
          } //右边墙


          camera == null ? void 0 : camera.screenPointToRay(size.width - OFFSET, size.height / 2, r);

          if (PhysicsSystem.instance.raycastClosest(r)) {
            const result = PhysicsSystem.instance.raycastClosestResult;
            this.GetNode("PlaneRight").setWorldPosition(result.hitPoint);
          } //上边墙


          camera == null ? void 0 : camera.screenPointToRay(size.width / 2, size.height - OFFSET * 4, r);

          if (PhysicsSystem.instance.raycastClosest(r)) {
            const result = PhysicsSystem.instance.raycastClosestResult;
            this.GetNode("PlaneTop").setWorldPosition(result.hitPoint);
          }

          let minx = this.GetNode("PlaneLeft").worldPosition.x;
          let maxx = this.GetNode("PlaneRight").worldPosition.x;
          let scale = (maxx - minx) / 8.461091041564941;
          this.GetNode("bottom").scale = v3(scale, scale, scale); //格子位置

          camera == null ? void 0 : camera.screenPointToRay(size.width / 2, 10, r);

          if (PhysicsSystem.instance.raycastClosest(r)) {
            const result = PhysicsSystem.instance.raycastClosestResult; //result.hitPoint

            let p = new Vec3(result.hitPoint.x, 4, result.hitPoint.z);
            this.GetNode("bottom").setWorldPosition(p);
          } //下边墙


          this.GetNode("PlaneDown").setWorldPosition(this.GetNode("bottom").worldPosition.add3f(0, 0, -2.5 * scale));
        }

        async createTiles() {
          let Margin = 0;
          let minx = this.GetNode("PlaneLeft").worldPosition.x + Margin;
          let maxx = this.GetNode("PlaneRight").worldPosition.x - Margin;
          let maxz = this.GetNode("PlaneDown").worldPosition.z + Margin;
          let minz = this.GetNode("PlaneTop").worldPosition.z - Margin;
          let obj = (_crd && levelsData === void 0 ? (_reportPossibleCrUseOflevelsData({
            error: Error()
          }), levelsData) : levelsData).getCurLevelInfo(); //数量

          let tileCount = Math.floor(obj.count / 3); // if (Data.user.lv == 1) tileCount = 2;
          // tiles = Utils.shuffle(tiles);

          let tilepools = []; // 30 /2 = 15

          let count1 = Math.floor(tileCount / 2);
          let count2 = tileCount - count1; //1从解锁池选一半

          let OpenItems = (_crd && levelsData === void 0 ? (_reportPossibleCrUseOflevelsData({
            error: Error()
          }), levelsData) : levelsData).getDeblockDatas();

          for (let i = (_crd && Data === void 0 ? (_reportPossibleCrUseOfData({
            error: Error()
          }), Data) : Data).user.openIndex - 1; i >= 0; --i) {
            tilepools.push(OpenItems[i]);
            count1--;

            if (count1 == 0) {
              break;
            }
          }

          console.log("解锁取", tileCount - (count2 + count1), "标准取", tileCount - (tileCount - (count2 + count1))); //2从标准池选一半

          let ItemNames = (_crd && levelsData === void 0 ? (_reportPossibleCrUseOflevelsData({
            error: Error()
          }), levelsData) : levelsData).getNormModelDatas();

          for (let k = count2 + count1 - 1; k >= 0; --k) {
            tilepools.push(ItemNames[k]);
          }

          tilepools = (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
            error: Error()
          }), Utils) : Utils).shuffle(tilepools);
          (_crd && Main === void 0 ? (_reportPossibleCrUseOfMain({
            error: Error()
          }), Main) : Main).Instance()._GameUI.pasue = true;
          (_crd && BusyLoadingManager === void 0 ? (_reportPossibleCrUseOfBusyLoadingManager({
            error: Error()
          }), BusyLoadingManager) : BusyLoadingManager).ins.addBusy((_crd && BUSY_TYPE === void 0 ? (_reportPossibleCrUseOfBUSY_TYPE({
            error: Error()
          }), BUSY_TYPE) : BUSY_TYPE).RES);

          for (let i = 0; i < tileCount; i++) {
            let ret = await (_crd && levelsData === void 0 ? (_reportPossibleCrUseOflevelsData({
              error: Error()
            }), levelsData) : levelsData).LoadItemPrefabByName(tilepools[i]);
            if (!ret) continue; //获取节点下的 MeshRenderer 组件 设置阴影投射模式

            ret.data.getComponentInChildren(MeshRenderer).shadowCastingMode = MeshRenderer.ShadowCastingMode.ON;

            for (let j = 0; j < 3; j++) {
              const globalIndex = (i * 3 + j) % 9;
              let lnode = this.GetNode(`l${globalIndex}`);
              tween(this.node).delay(j * 0.03).call(() => {
                let nomal_node = instantiate(ret);
                nomal_node.name = ret.name;
                let tile = nomal_node.addComponent(_crd && TileItem === void 0 ? (_reportPossibleCrUseOfTileItem({
                  error: Error()
                }), TileItem) : TileItem);
                let rigid = tile.addCollider();
                nomal_node.scale = v3(1.25, 1.25, 1.25);

                if ((_crd && Data === void 0 ? (_reportPossibleCrUseOfData({
                  error: Error()
                }), Data) : Data).user.lv == 1) {
                  nomal_node.setWorldPosition(lnode.getWorldPosition());
                  nomal_node.parent = this.node;
                  this.allTiles.push(nomal_node);
                } else {
                  let p = v3((_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
                    error: Error()
                  }), Utils) : Utils).getRandomInt(minx / 2, maxx / 2), (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
                    error: Error()
                  }), Utils) : Utils).getRandom(12, 15), (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
                    error: Error()
                  }), Utils) : Utils).getRandomInt(minz / 2, maxz / 2));
                  nomal_node.setWorldRotationFromEuler((_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
                    error: Error()
                  }), Utils) : Utils).getRandom(0, 300), (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
                    error: Error()
                  }), Utils) : Utils).getRandom(0, 300), (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
                    error: Error()
                  }), Utils) : Utils).getRandom(0, 300));
                  nomal_node.setWorldPosition(p);
                  nomal_node.parent = this.node;
                  rigid.applyImpulse(v3(0, 3, 0));
                  this.allTiles.push(nomal_node);
                }
              }).start();
            }

            if (i == tileCount - 1) {
              (_crd && BusyLoadingManager === void 0 ? (_reportPossibleCrUseOfBusyLoadingManager({
                error: Error()
              }), BusyLoadingManager) : BusyLoadingManager).ins.removeBusy((_crd && BUSY_TYPE === void 0 ? (_reportPossibleCrUseOfBUSY_TYPE({
                error: Error()
              }), BUSY_TYPE) : BUSY_TYPE).RES);
              (_crd && Main === void 0 ? (_reportPossibleCrUseOfMain({
                error: Error()
              }), Main) : Main).Instance()._GameUI.pasue = false;
            }
          }

          setTimeout(() => {
            if ((_crd && Data === void 0 ? (_reportPossibleCrUseOfData({
              error: Error()
            }), Data) : Data).user.useMagnet) {
              (_crd && Main === void 0 ? (_reportPossibleCrUseOfMain({
                error: Error()
              }), Main) : Main).Instance()._GameUI.pasue = true;
              (_crd && Data === void 0 ? (_reportPossibleCrUseOfData({
                error: Error()
              }), Data) : Data).user.magnet--;
              let p = this.GetNode("magnet").worldPosition;
              this.GetNode("magnet").worldPosition = v3(-10, p.y, p.z);
              tween(this.GetNode("magnet")).to(0.5, {
                worldPosition: v3(0, p.y, p.z)
              }).call(async () => {
                let arr = [];

                for (var i = this.allTiles.length - 1; i >= 0; --i) {
                  let pick = false;
                  let item = this.allTiles[i];
                  let tmp = arr[0];

                  if (tmp) {
                    if (tmp.name == item.name && arr.length < 3) {
                      arr.push(item);
                      pick = true;
                    }
                  } else {
                    arr.push(item);
                    pick = true;
                  }

                  if (pick) {
                    let tile = this.allTiles[i].getComponent(_crd && TileItem === void 0 ? (_reportPossibleCrUseOfTileItem({
                      error: Error()
                    }), TileItem) : TileItem);
                    tile.destoryCollider();
                    this.GetNode("magnet_content").addChild(tile.node);
                    tween(tile.node).to(0.5, {
                      worldPosition: this.GetNode(arr.length % 2 ? "m_left" : "r_left").worldPosition
                    }).start();
                    this.allTiles.splice(i, 1);
                    console.log("删除", tile.name, this.allTiles.length);
                  }
                }

                (_crd && Data === void 0 ? (_reportPossibleCrUseOfData({
                  error: Error()
                }), Data) : Data).user.useMagnet = false;
              }).delay(1.5).to(0.5, {
                worldPosition: v3(10, p.y, p.z)
              }).call(() => {
                this.GetNode("magnet_content").removeAllChildren();
                (_crd && Main === void 0 ? (_reportPossibleCrUseOfMain({
                  error: Error()
                }), Main) : Main).Instance()._GameUI.pasue = false;
                if ((_crd && Data === void 0 ? (_reportPossibleCrUseOfData({
                  error: Error()
                }), Data) : Data).user.useTime && (_crd && Data === void 0 ? (_reportPossibleCrUseOfData({
                  error: Error()
                }), Data) : Data).user.time > 0) (_crd && GameEvent === void 0 ? (_reportPossibleCrUseOfGameEvent({
                  error: Error()
                }), GameEvent) : GameEvent).Instance().dispatch((_crd && GameConst === void 0 ? (_reportPossibleCrUseOfGameConst({
                  error: Error()
                }), GameConst) : GameConst).USE_ITEM_TIME);
              }).start();
            } else {
              if ((_crd && Data === void 0 ? (_reportPossibleCrUseOfData({
                error: Error()
              }), Data) : Data).user.useTime && (_crd && Data === void 0 ? (_reportPossibleCrUseOfData({
                error: Error()
              }), Data) : Data).user.time > 0) {
                (_crd && GameEvent === void 0 ? (_reportPossibleCrUseOfGameEvent({
                  error: Error()
                }), GameEvent) : GameEvent).Instance().dispatch((_crd && GameConst === void 0 ? (_reportPossibleCrUseOfGameConst({
                  error: Error()
                }), GameConst) : GameConst).USE_ITEM_TIME);
              }
            }
          }, 2000);
        }
        /**
         * 提示
         */


        restart() {
          this.allTiles.map(a => a.destroy());
          this.allTiles = [];
          (_crd && Main === void 0 ? (_reportPossibleCrUseOfMain({
            error: Error()
          }), Main) : Main).Instance()._GameUI.star = 0;
          this.collectTiles.map(a => a.destroy());
          this.collectTiles = [];
          this.createTiles();
          this.lock = false;
        }
        /**移除*/


        remove() {
          if (this.optionTiles.length === 0 || this.lock) return; // 获取最后一个收集的物品

          const lastItem = this.optionTiles.pop();
          if (!lastItem) return;
          (_crd && utils === void 0 ? (_reportPossibleCrUseOfutils({
            error: Error()
          }), utils) : utils).remove(this.collectTiles, lastItem);
          const tile = lastItem.getComponent(_crd && TileItem === void 0 ? (_reportPossibleCrUseOfTileItem({
            error: Error()
          }), TileItem) : TileItem);
          tile.removed = false;
          tile.auto_rotation = false; //播放撤销动画

          Tween.stopAllByTarget(lastItem); //const globalIndex = Math.floor(Math.random() * 9);

          let lnode = this.GetNode(`l${4}`);
          let p = lnode.position.clone();
          tween(tile.node).to(0.35, {
            worldPosition: new Vec3(p.x, p.y + 1, p.z),
            worldScale: v3(1.25, 1.25, 1.25)
          }).call(() => {
            tile.addCollider();
            tile.enableCollider = true;
            this.allTiles.push(lastItem); //向上施加力 然后在向下重力效果

            tile.rigid.applyImpulse(v3(0, 3, 0));
            this.moveToRightPos(); // 重新排列收集框中的物品
          }).start();
        }
        /**乱序*/


        mess() {
          if (this.allTiles.length === 0 || this.lock) return;
          this.allTiles.forEach((item, index) => {
            const tileItem = item.getComponent(_crd && TileItem === void 0 ? (_reportPossibleCrUseOfTileItem({
              error: Error()
            }), TileItem) : TileItem);
            tileItem.auto_rotation = false;
            tileItem.enableCollider = true;
            Tween.stopAllByTarget(item);
            tween(item).to(0.3, {
              worldPosition: this.GetNode("l4").worldPosition.clone().add(v3(0, 1, 0)),
              worldScale: v3(1.25, 1.25, 1.25)
            }).call(() => {
              const rigid = tileItem.addCollider();
              rigid.applyImpulse(v3((_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
                error: Error()
              }), Utils) : Utils).getRandom(-3, 3), (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
                error: Error()
              }), Utils) : Utils).getRandom(5, 8), (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
                error: Error()
              }), Utils) : Utils).getRandom(-3, 3)));
              item.setWorldRotationFromEuler((_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
                error: Error()
              }), Utils) : Utils).getRandom(0, 300), (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
                error: Error()
              }), Utils) : Utils).getRandom(0, 300), (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
                error: Error()
              }), Utils) : Utils).getRandom(0, 300));
            }).start();
          }); //audioManager.playOneShot(constants.audios.shuffle);

          (_crd && platformSystem === void 0 ? (_reportPossibleCrUseOfplatformSystem({
            error: Error()
          }), platformSystem) : platformSystem).platform.vibrateShort();
        }
        /**凑齐*/


        prompt() {
          if (this.collectTiles.length <= 0) return;
          let obj = {};

          for (var i = 0; i < this.collectTiles.length; ++i) {
            let name = this.collectTiles[i].name;
            if (!obj[name]) obj[name] = 0;
            obj[name]++;
          }

          let hint_succ = false;
          let bFind = false;
          let hint_name = "";

          for (const key in obj) {
            if (obj[key] == 2) {
              hint_name = key;
              bFind = true;
              break;
            }
          } //找到两个一样


          if (bFind) {
            console.log("找到两个一样");

            for (let i = 0; i < this.allTiles.length; ++i) {
              if (this.allTiles[i].name == hint_name) {
                this.chooseTile(this.allTiles[i]);
                break;
              }
            }

            hint_succ = true;
          } else {
            if (this.collectTiles.length >= 5) {
              (_crd && MsgHints === void 0 ? (_reportPossibleCrUseOfMsgHints({
                error: Error()
              }), MsgHints) : MsgHints).show("未找到合适物品");
              return;
            } else {
              hint_name = this.collectTiles[0] ? this.collectTiles[0].name : this.allTiles[0].name;
              let lsit = this.allTiles.filter(a => {
                return a.name == hint_name;
              });
              lsit.map((a, i) => {
                setTimeout(() => {
                  this.chooseTile(a);
                }, 350 * i);
              });
              hint_succ = true;
            }
          }

          if (hint_succ) {
            (_crd && Data === void 0 ? (_reportPossibleCrUseOfData({
              error: Error()
            }), Data) : Data).user.hint--;
          }
        } //放回场景中


        async pushBask(name) {
          let Margin = 0;
          let maxz = this.GetNode("PlaneDown").worldPosition.z + Margin;
          let minz = this.GetNode("PlaneTop").worldPosition.z - Margin;
          let minx = this.GetNode("PlaneLeft").worldPosition.x + Margin;
          let maxx = this.GetNode("PlaneRight").worldPosition.x - Margin;
          let ret = await (_crd && levelsData === void 0 ? (_reportPossibleCrUseOflevelsData({
            error: Error()
          }), levelsData) : levelsData).LoadItemPrefabByName(name);
          let nomal_node = instantiate(ret);
          nomal_node.name = name;
          let tile = nomal_node.addComponent(_crd && TileItem === void 0 ? (_reportPossibleCrUseOfTileItem({
            error: Error()
          }), TileItem) : TileItem);
          let rigid = tile.addCollider();
          nomal_node.scale = v3(1.25, 1.25, 1.25);
          nomal_node.parent = this.node;
          rigid.applyImpulse(v3(0, 3, 0));
          let p = v3(minx + (maxx - minx) / 2, (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
            error: Error()
          }), Utils) : Utils).getRandom(12, 15), minz + (maxz - minz) / 2);
          nomal_node.setWorldRotationFromEuler((_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
            error: Error()
          }), Utils) : Utils).getRandom(0, 300), (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
            error: Error()
          }), Utils) : Utils).getRandom(0, 300), (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
            error: Error()
          }), Utils) : Utils).getRandom(0, 300));
          nomal_node.setWorldPosition(p);
          this.allTiles.push(nomal_node);
        }

      }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "plate", [_dec2], {
        configurable: true,
        enumerable: true,
        writable: true,
        initializer: function () {
          return null;
        }
      })), _class2)) || _class));

      _cclegacy._RF.pop();

      _crd = false;
    }
  };
});
//# sourceMappingURL=bfd690a1637bb6c11a474a7bc6e819c87ea14c3b.js.map