"use strict";
cc._RF.push(module, '6716cKnH+ZFHoUln1bHKGgS', 'dici');
// Script/dici.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 NewClass = /** @class */ (function (_super) {
    __extends(NewClass, _super);
    function NewClass() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        /**
         * 落脚点类型 6：地刺
         */
        _this.KIND_FootHold = 6;
        /**
         * player是否落在落脚点上，默认false，没有
         */
        _this.isHold = false;
        _this.NodeH = 80;
        _this.GoUp = false;
        _this.main = null;
        /**
         * 落脚点对应动画
         */
        _this.Ani = null;
        _this.AniState = null;
        _this.gainSc = false;
        _this.InjuredF = false;
        return _this;
    }
    // LIFE-CYCLE CALLBACKS:
    NewClass.prototype.onLoad = function () {
        this.node.y = -500;
        this.node.x = (Math.random() * 2 - 1) * 140;
        this.Ani = this.node.getComponent(cc.Animation);
    };
    NewClass.prototype.start = function () {
    };
    NewClass.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) {
                    Global_1.default.instance.CollisionFlag = false;
                    this.node.isHold = false;
                }
                this.node.destroy();
            }
        }
    };
    /**
     * 初始化函数
     * @param main 主场景
     */
    NewClass.prototype.init = function (main) {
        this.main = main;
    };
    /**
    * 获取落脚点类型
    */
    NewClass.prototype.getKind = function () {
        return this.KIND_FootHold;
    };
    NewClass.prototype.onCollisionEnter = function (other, self) {
        var rootself = this;
        if (rootself.GoUp) {
            return;
        }
        if (other.tag == 111) {
            console.log("我被撞到了");
            rootself.main.Score();
            rootself.gainSc = true;
            return;
        }
        else {
            Global_1.default.instance.TheHolder = this.node;
            Global_1.default.instance.KIND_FootHold = this.KIND_FootHold;
            rootself.node.isHold = true;
            self.node.isHold = true;
            if (!rootself.InjuredF) {
                Global_1.default.instance.Injured = true;
                rootself.InjuredF = true;
            }
            // this.main.Score();
            if (!Global_1.default.instance.CollisionFlag) {
                Global_1.default.instance.CollisionFlag = true;
                rootself.node.isHold = true;
                self.node.isHold = true;
                rootself.AniState = rootself.Ani.play("dici");
                rootself.AniState.repeatCount = 100;
            }
        }
    };
    __decorate([
        property(Boolean)
    ], NewClass.prototype, "isHold", void 0);
    __decorate([
        property(Number)
    ], NewClass.prototype, "NodeH", void 0);
    NewClass = __decorate([
        ccclass
    ], NewClass);
    return NewClass;
}(cc.Component));
exports.default = NewClass;
/**
 * 地刺的问题貌似还没有解决
 * 不知道哪里有问题
 * 地刺的问题到底是碰撞标志位被修改了。
 *
 */

cc._RF.pop();