"use strict";
cc._RF.push(module, 'c3fcdYkt9FMtJg2+HeTUXjw', 'Opplvdai');
// Script/Opplvdai.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 Opplvdai = /** @class */ (function (_super) {
    __extends(Opplvdai, _super);
    function Opplvdai() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        /**
         * 落脚点类型 2：向右传送带
         */
        _this.KIND_FootHold = 2;
        /**
         * player是否落在落脚点上，默认false，没有
         */
        _this.isHold = false;
        _this.NodeH = 69;
        _this.GoUp = false;
        _this.main = null;
        /**
         * 落脚点对应动画
         */
        _this.Ani = null;
        _this.AniState = null;
        _this.gainSc = false;
        return _this;
    }
    Opplvdai.prototype.onLoad = function () {
        this.node.y = -500;
        this.node.x = (Math.random() * 2 - 1) * 140;
        this.Ani = this.node.getComponent(cc.Animation);
        this.AniState = this.Ani.play("Opplvdai");
        this.AniState.repeatCount = 100;
        this.AniState.speed = 2;
    };
    Opplvdai.prototype.start = function () {
    };
    Opplvdai.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 主场景
     */
    Opplvdai.prototype.init = function (main) {
        this.main = main;
    };
    /**
     * 获取落脚点类型
     */
    Opplvdai.prototype.getKind = function () {
        return this.KIND_FootHold;
    };
    Opplvdai.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;
            rootself.GoUp = true;
            return;
        }
        // this.main.Score();
        if (!Global_1.default.instance.CollisionFlag) {
            // console.log(other);
            // console.log("2检测到碰撞！！！");
            // console.log(self);
            // other.node.y = this.node.y+50;
            self.node.isHold = true;
            Global_1.default.instance.CollisionFlag = true;
        }
    };
    __decorate([
        property(Boolean)
    ], Opplvdai.prototype, "isHold", void 0);
    __decorate([
        property(Number)
    ], Opplvdai.prototype, "NodeH", void 0);
    Opplvdai = __decorate([
        ccclass
    ], Opplvdai);
    return Opplvdai;
}(cc.Component));
exports.default = Opplvdai;

cc._RF.pop();