System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2"], function (_export, _context) {
  "use strict";

  var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Component, Prefab, instantiate, Node, Vec3, Label, PlayerController, platform, _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _crd, ccclass, property, GameState, GameManager;

  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 randomNum(minNum, maxNum) {
    switch (arguments.length) {
      case 1:
        return parseInt(String(Math.random() * minNum + 1), 10);
        break;

      case 2:
        return parseInt(String(Math.random() * (maxNum - minNum + 1)) + minNum, 10);
        break;

      default:
        return 0;
        break;
    }
  }

  function _reportPossibleCrUseOfPlayerController(extras) {
    _reporterNs.report("PlayerController", "./PlayerController", _context.meta, extras);
  }

  function _reportPossibleCrUseOfplatform(extras) {
    _reporterNs.report("platform", "./platform", _context.meta, extras);
  }

  return {
    setters: [function (_unresolved_) {
      _reporterNs = _unresolved_;
    }, function (_cc) {
      _cclegacy = _cc.cclegacy;
      __checkObsolete__ = _cc.__checkObsolete__;
      __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
      _decorator = _cc._decorator;
      Component = _cc.Component;
      Prefab = _cc.Prefab;
      instantiate = _cc.instantiate;
      Node = _cc.Node;
      Vec3 = _cc.Vec3;
      Label = _cc.Label;
    }, function (_unresolved_2) {
      PlayerController = _unresolved_2.PlayerController;
    }, function (_unresolved_3) {
      platform = _unresolved_3.platform;
    }],
    execute: function () {
      _crd = true;

      _cclegacy._RF.push({}, "94b35uxswhFgYqBHBQd9bbP", "GameManager", undefined);

      __checkObsolete__(['_decorator', 'Component', 'Prefab', 'instantiate', 'Node', 'CCInteger', 'Vec3', 'Label', 'log', 'Vec2']);

      ({
        ccclass,
        property
      } = _decorator);

      (function (GameState) {
        GameState[GameState["GS_INIT"] = 0] = "GS_INIT";
        GameState[GameState["GS_PLAYING"] = 1] = "GS_PLAYING";
        GameState[GameState["GS_END"] = 2] = "GS_END";
      })(GameState || (GameState = {}));

      ;

      _export("GameManager", GameManager = (_dec = ccclass("GameManager"), _dec2 = property({
        type: Prefab
      }), _dec3 = property({
        type: Node
      }), _dec4 = property({
        type: _crd && PlayerController === void 0 ? (_reportPossibleCrUseOfPlayerController({
          error: Error()
        }), PlayerController) : PlayerController
      }), _dec5 = property({
        type: Node
      }), _dec6 = property({
        type: Label
      }), _dec(_class = (_class2 = class GameManager extends Component {
        constructor() {
          super(...arguments);

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

          _initializerDefineProperty(this, "bg", _descriptor2, this);

          _initializerDefineProperty(this, "roadLength", _descriptor3, this);

          this._road = [];
          this.initPos = 0;

          _initializerDefineProperty(this, "playerCtrl", _descriptor4, this);

          _initializerDefineProperty(this, "startMenu", _descriptor5, this);

          _initializerDefineProperty(this, "stepsLabel", _descriptor6, this);
        }

        start() {
          var _this$playerCtrl, _this$playerCtrl2, _this$playerCtrl3;

          this.generateRoad();
          (_this$playerCtrl = this.playerCtrl) == null ? void 0 : _this$playerCtrl.node.on('JumpEnd', this.onPlayerJumpEnd, this);
          (_this$playerCtrl2 = this.playerCtrl) == null ? void 0 : _this$playerCtrl2.node.on('JumpFull', this.onPlayerJumpFull, this);
          this.playerCtrl.setInputActive(true);
          this.initPos = (_this$playerCtrl3 = this.playerCtrl) == null ? void 0 : _this$playerCtrl3.node.getPosition().y;
        }

        generateRoad() {
          // this.node.removeAllChildren();
          this._road = []; // 确定好每一级台阶高度

          for (var i = 0; i < this.roadLength - 1; i++) {
            var y = -200 + 370 * i;

            this._road.push(y);
          }

          for (var j = 0; j < this._road.length; j++) {
            var block = this.spawnBlockByType();
            block.getComponent(_crd && platform === void 0 ? (_reportPossibleCrUseOfplatform({
              error: Error()
            }), platform) : platform).setSpeed(randomNum(10, 20));

            if (block) {
              this.node.addChild(block);
              block.setPosition(randomNum(-100, 100), this._road[j], 0);
            }
          }
        }

        spawnBlockByType() {
          var block = null; // 赛道类型为实路才生成

          block = instantiate(this.platformPrfb);
          return block;
        }

        onPlayerJumpEnd() {
          console.log('跳跃结束');
        }

        onPlayerJumpFull() {
          console.log('掉落地面'); // window.location.href = '../'
        }

        init() {}

        update(deltaTime) {
          var _this$playerCtrl4;

          var distance = Math.floor(((_this$playerCtrl4 = this.playerCtrl) == null ? void 0 : _this$playerCtrl4.node.getPosition().y) - this.initPos);
          console.log(this.bg.getPosition().y);
          this.bg.setPosition(new Vec3(0, distance, 0)); // if(distance>0){
          //     this.bg.setPosition(new Vec3(0,this.bg.getPosition().y+1,0))
          // }else if(distance<0){
          //     this.bg.setPosition(new Vec3(0,this.bg.getPosition().y-1,0))
          // }
        }

      }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "platformPrfb", [_dec2], {
        configurable: true,
        enumerable: true,
        writable: true,
        initializer: function initializer() {
          return null;
        }
      }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "bg", [_dec3], {
        configurable: true,
        enumerable: true,
        writable: true,
        initializer: function initializer() {
          return null;
        }
      }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "roadLength", [property], {
        configurable: true,
        enumerable: true,
        writable: true,
        initializer: function initializer() {
          return 50;
        }
      }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "playerCtrl", [_dec4], {
        configurable: true,
        enumerable: true,
        writable: true,
        initializer: function initializer() {
          return null;
        }
      }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "startMenu", [_dec5], {
        configurable: true,
        enumerable: true,
        writable: true,
        initializer: function initializer() {
          return null;
        }
      }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "stepsLabel", [_dec6], {
        configurable: true,
        enumerable: true,
        writable: true,
        initializer: function initializer() {
          return null;
        }
      })), _class2)) || _class));

      _cclegacy._RF.pop();

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