123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- "use strict";
- cc._RF.push(module, 'aa287RDrGdFu4EArMpW55C/', 'tanhuang');
- // Script/tanhuang.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 tanhuang = /** @class */ (function (_super) {
- __extends(tanhuang, _super);
- function tanhuang() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- /**
- * 落脚点类型 2:tanhuang
- */
- _this.KIND_FootHold = 2;
- /**
- * player是否落在落脚点上,默认false,没有
- */
- _this.isHold = false;
- _this.NodeH = 60;
- _this.GoUp = false;
- _this.gainSc = false; //弹簧加分标志
- _this.main = null;
- /**
- * 落脚点对应动画
- */
- _this.Ani = null;
- _this.AniState = null;
- return _this;
- }
- tanhuang.prototype.onLoad = function () {
- this.node.y = -500;
- this.node.x = (Math.random() * 2 - 1) * 140;
- this.Ani = this.node.getComponent(cc.Animation);
- this.gainSc = false;
- };
- tanhuang.prototype.start = function () {
- this.Ding = this.main.node.getChildByName("BgNode").getChildByName("LifeDing").getChildByName("ding");
- };
- tanhuang.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 主场景
- */
- tanhuang.prototype.init = function (main) {
- this.main = main;
- };
- /**
- * 获取落脚点类型
- */
- tanhuang.prototype.getKind = function () {
- return this.KIND_FootHold;
- };
- /**
- * 碰撞
- * @param other 碰撞主体player
- * @param self 碰撞主体落脚点tanhuang
- */
- tanhuang.prototype.onCollisionEnter = function (other, self) {
- var rootself = this;
- if (rootself.GoUp) {
- return;
- }
- if (rootself.main == null) {
- rootself.main = Global_1.default.instance.getMN();
- }
- if (other.tag === 111) {
- if (rootself.gainSc == false) {
- rootself.main.Score();
- rootself.gainSc = true;
- rootself.GoUp = true;
- }
- return;
- }
- else {
- Global_1.default.instance.KIND_FootHold = rootself.KIND_FootHold;
- if (!Global_1.default.instance.CollisionFlag) {
- Global_1.default.instance.CollisionFlag = true;
- Global_1.default.instance.TheHolder = rootself.node;
- rootself.isHold = true;
- other.node.y = self.node.y + 60;
- var spawn = void 0;
- spawn = cc.spawn(cc.callFunc(function () {
- if (rootself.Ani == null) {
- return;
- }
- rootself.AniState = rootself.Ani.play("tanhuang");
- rootself.AniState.speed = 0.8;
- }), cc.callFunc(function () {
- other.node.runAction(cc.moveBy(0.15, 0, 50));
- Global_1.default.instance.CollisionFlag = false;
- rootself.isHold = false;
- other.node.getComponent("Playcontroler").enabled = false;
- }));
- rootself.scheduleOnce(function () {
- other.node.getComponent("Playcontroler").enabled = true;
- }, 0.27);
- rootself.scheduleOnce(function () {
- // console.log(Global.instance.CollisionFlag+"5")
- Global_1.default.instance.CollisionFlag = false;
- rootself.isHold = false;
- rootself.Ani.stop();
- }, 0.41);
- other.node.runAction(spawn);
- }
- }
- };
- __decorate([
- property(Boolean)
- ], tanhuang.prototype, "isHold", void 0);
- __decorate([
- property(Number)
- ], tanhuang.prototype, "NodeH", void 0);
- tanhuang = __decorate([
- ccclass
- ], tanhuang);
- return tanhuang;
- }(cc.Component));
- exports.default = tanhuang;
- cc._RF.pop();
|