"use strict";
cc._RF.push(module, '3b92asAQBZGJZpKL/qRD3e3', 'GD');
// Script/GD.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 GD = /** @class */ (function (_super) {
    __extends(GD, _super);
    function GD() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        /**
         * 落脚点类型 1：向左传送带
         */
        _this.KIND_FootHold = 0;
        /**
         * player是否落在落脚点上，默认false，没有
         */
        _this.isHold = false;
        _this.NodeH = 70;
        _this.GoUp = false;
        _this.main = null;
        /**
         * 落脚点对应动画
         */
        _this.Ani = null;
        _this.AniState = null;
        _this.LifeDing = null;
        _this.gainSc = false;
        return _this;
    }
    GD.prototype.onLoad = function () {
        this.node.y = -500;
        // this.KIND_FootHold==7
    };
    GD.prototype.start = function () {
        var moveStartT = 0;
        var moveEndT = 0;
        if (this.KIND_FootHold == 1) {
            // this.KIND_FootHold = 1;   
            this.node.x = (Math.random() * 2 - 1) * 140;
        }
        if (this.KIND_FootHold == 7) {
            // this.KIND_FootHold = 7;
            this.node.x = (Math.random() * 2 - 1) * 140;
        }
        if (this.KIND_FootHold == 1) {
            this.node.getChildByName("gd").getComponent("CliGD").enabled = false;
        }
        else {
            this.node.getChildByName("gd").getComponent("CliGD").enabled = true;
        }
        this.LifeDing = this.main.LifeDing.children;
    };
    GD.prototype.update = function (dt) {
        // console.log(Global.instance.CollisionFlag);
        var self = this;
        // console.log("状态："+ self.node.active+"，位置："+self.node.x);
        if (Global_1.default.instance.OverFlag) {
            self.enabled = false;
        }
        else {
            this.node.active = true;
            if (this.node.isHold) {
                Global_1.default.instance.CollisionFlag = true;
                Global_1.default.instance.TheHolder = this.node;
                this.node.y += Global_1.default.instance.FHFallSpeed;
            }
            else {
                this.node.y += Global_1.default.instance.FHFallSpeed;
            }
            if (this.node.y > 360) {
                if (this.node.isHold) {
                    this.node.isHold = false;
                    Global_1.default.instance.CollisionFlag = false;
                }
                this.node.destroy();
            }
        }
    };
    GD.prototype.MoveThis = function () {
    };
    /**
     * 初始化函数
     * @param main 主场景
     */
    GD.prototype.init = function (main, kind) {
        this.main = main;
        this.KIND_FootHold = kind;
    };
    /**
     * 获取落脚点类型
     */
    GD.prototype.getKind = function () {
        return this.KIND_FootHold;
    };
    GD.prototype.onCollisionEnter = function (other, self) {
        var rootself = this;
        if (rootself.GoUp) {
            return;
        }
        if (other.tag == 111) {
            // console.log("我被撞到了");
            rootself.main.Score();
            rootself.gainSc = true;
            rootself.GoUp = true;
            return;
        }
        Global_1.default.instance.TheHolder = this.node;
        Global_1.default.instance.KIND_FootHold = this.KIND_FootHold;
        Global_1.default.instance.CollisionFlag = true;
        this.node.isHold = true;
        // this.main.Score();
    };
    __decorate([
        property(Boolean)
    ], GD.prototype, "isHold", void 0);
    __decorate([
        property(Number)
    ], GD.prototype, "NodeH", void 0);
    GD = __decorate([
        ccclass
    ], GD);
    return GD;
}(cc.Component));
exports.default = GD;

cc._RF.pop();