"use strict"; cc._RF.push(module, 'fdf2c730yhID6Z3U8e9U0kb', 'BaseProp'); // Script/prop/BaseProp.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 gameScene_1 = require("../gameScene"); var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; var BaseProp = /** @class */ (function (_super) { __extends(BaseProp, _super); function BaseProp() { return _super !== null && _super.apply(this, arguments) || this; } BaseProp_1 = BaseProp; /** * 初始化数据 * @param element json道具数据 */ BaseProp.prototype.SetData = function (element) { this.TransfromSet(element, this.node); this.node.x = Number(element.x); this.node.y = Number(element.y); if (element.wid) this.node.width = Number(element.wid); if (element.path) this.SetTexture(element.path); if (element.hei) this.node.height = Number(element.hei); if (element.ang) this.node.angle = Number(element.ang); if (element.scaleX) this.node.scaleX = Number(element.scaleX); // console.log('element:', element) this.SetPhyBox(); this.SpecicalSet(element); }; /** * 道具内部特殊设置 * @param element */ BaseProp.prototype.SpecicalSet = function (element) { }; /** * 设置物理盒子宽高同步 */ BaseProp.prototype.SetPhyBox = function () { if (this.node.getComponent(cc.PhysicsBoxCollider)) { var phyBox = this.node.getComponent(cc.PhysicsBoxCollider); phyBox.size.width = this.node.width; phyBox.size.height = this.node.height; phyBox.apply(); } }; /** * 触发函数 * @param flag 是否dead */ BaseProp.prototype.TriggerFunc = function (flag) { if (flag === void 0) { flag = true; } if (flag) gameScene_1.default.instance.GameFail(); }; BaseProp.prototype.SetOtherDoor = function (other) { console.log('SetOtherDoor:super'); }; /** * 传送门设置 */ BaseProp.prototype.TransfromSet = function (element, nodes) { if (element.num == 'O') { if (!gameScene_1.default.instance.tempTransform) gameScene_1.default.instance.tempTransform = nodes; else { gameScene_1.default.instance.tempTransform.getComponent(BaseProp_1).SetOtherDoor(nodes); this.SetOtherDoor(gameScene_1.default.instance.tempTransform); gameScene_1.default.instance.tempTransform = null; } } }; BaseProp.prototype.SetTexture = function (tex) { var self = this; // console.log('装饰:', tex) this.GetTexture('texture/' + tex).then(function (res) { self.node.getComponent(cc.Sprite).spriteFrame = res; self.node.width = res._originalSize.width; self.node.height = res._originalSize.height; }); }; BaseProp.prototype.GetTexture = function (name) { var self = this; return new Promise(function (resolve) { cc.loader.loadRes(name, cc.SpriteFrame, function (err, spriteFrame) { if (err) { console.log("err", err); } else { resolve(spriteFrame); } }); }); }; var BaseProp_1; BaseProp = BaseProp_1 = __decorate([ ccclass ], BaseProp); return BaseProp; }(cc.Component)); exports.default = BaseProp; cc._RF.pop();