"use strict";
cc._RF.push(module, 'd80ccPtUvFAGYjYiiCrLHt/', 'lvdai');
// Script/lvdai.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var Global_1 = require("./Global");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var lvdai = /** @class */ (function (_super) {
    __extends(lvdai, _super);
    function lvdai() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        /**
         * 落脚点类型 3/4：传送带
         */
        _this.KIND_FootHold = 0;
        /**
         * player是否落在落脚点上，默认false，没有
         */
        _this.isHold = false;
        _this.NodeH = 60;
        _this.GoUp = false;
        _this.main = null;
        /**
         * 落脚点对应动画
         */
        _this.Ani = null;
        _this.AniState = null;
        _this.gainSc = false;
        return _this;
    }
    lvdai.prototype.onLoad = function () {
        var kind = Math.random();
        this.node.y = -500;
        this.node.x = (Math.random() * 2 - 1) * 140;
        this.Ani = this.node.getComponent(cc.Animation);
        this.AniState = this.Ani.play("lvdai");
        if (kind <= 0.5) {
            this.KIND_FootHold = 3;
        }
        else {
            this.KIND_FootHold = 4;
            this.AniState.wrapMode = cc.WrapMode.Reverse; //设置动画的播放方式为倒放
        }
        this.AniState.repeatCount = 100;
        this.AniState.speed = 2;
        /**
         * 这里有点问题，设置模式貌似不奏效。一旦成功可以减小包体
         */
    };
    lvdai.prototype.start = function () {
    };
    lvdai.prototype.update = function (dt) {
        // console.log(Global.instance.CollisionFlag);
        var self = this;
        if (Global_1.default.instance.OverFlag) {
            self.enabled = false;
        }
        else {
            this.node.active = true;
            this.node.y += Global_1.default.instance.FHFallSpeed;
            if (this.node.isHold) {
                Global_1.default.instance.CollisionFlag = true;
                Global_1.default.instance.TheHolder = this.node;
            }
            if (this.node.y > 360) {
                if (this.node.isHold) {
                    this.node.isHold = false;
                    Global_1.default.instance.CollisionFlag = false;
                }
                this.node.destroy();
            }
        }
    };
    /**
     * 初始化函数
     * @param main 主场景
     */
    lvdai.prototype.init = function (main) {
        this.main = main;
    };
    /**
     * 获取落脚点类型
     */
    lvdai.prototype.getKind = function () {
        return this.KIND_FootHold;
    };
    lvdai.prototype.onCollisionEnter = function (other, self) {
        var rootself = this; //当前根节点
        if (rootself.GoUp) {
            return;
        }
        Global_1.default.instance.KIND_FootHold = this.KIND_FootHold;
        Global_1.default.instance.TheHolder = this.node;
        if (other.tag == 111) {
            // console.log("我被撞到了");
            rootself.main.Score();
            rootself.gainSc = true;
            return;
        }
        // this.main.Score();
        if (!Global_1.default.instance.CollisionFlag) {
            // console.log(other);
            // console.log("5检测到碰撞！！！");
            // console.log(self);
            self.node.isHold = true;
            Global_1.default.instance.CollisionFlag = true;
        }
    };
    __decorate([
        property(Boolean)
    ], lvdai.prototype, "isHold", void 0);
    __decorate([
        property(Number)
    ], lvdai.prototype, "NodeH", void 0);
    lvdai = __decorate([
        ccclass
    ], lvdai);
    return lvdai;
}(cc.Component));
exports.default = lvdai;

cc._RF.pop();