0e862ba8-2ecf-4ed6-bdd7-adfa5a36519c.js
4.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
"use strict";
cc._RF.push(module, '0e862uoLs9O1r3XrfpaNlGc', 'RectBlockView');
// scripts/prefabs/RectBlockView.ts
"use strict";
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
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 BlockView_1 = require("./BlockView");
var RectBlockCollider_1 = require("./RectBlockCollider");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var RectBlockView = /** @class */ (function (_super) {
__extends(RectBlockView, _super);
function RectBlockView() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this._offsetX = 0;
_this._offsetY = 0;
return _this;
//#endregion
}
Object.defineProperty(RectBlockView.prototype, "owner", {
get: function () { return this._owner; },
enumerable: false,
configurable: true
});
//#region LIFE-CYCLE CALLBACKS:
// onLoad () {}
RectBlockView.prototype.init = function (owner, mapView) {
this._offsetX = owner.viewPixelPosX - owner.pixelPos.x;
this._offsetY = owner.viewPixelPosY - owner.pixelPos.y;
this._colliderNode = this.node.getChildByName('collider');
this._colliderNode.removeFromParent();
this._colliderNode.setPosition(owner.viewPixelPosX, owner.viewPixelPosY);
mapView.colliderLayer.addChild(this._colliderNode);
this._colliderNode.getComponent(RectBlockCollider_1.default).setMainNode(this.node);
this._colliderNode.getComponent(cc.PhysicsBoxCollider).size.width = owner.widthPixel - 2; //大格子碰撞体缩小一些,避免被三角格子包围时穿透
this._colliderNode.getComponent(cc.PhysicsBoxCollider).size.height = owner.heightPixel - 2;
_super.prototype.init.call(this, owner, mapView);
this._light && this._light.setContentSize(this.owner.widthPixel, this.owner.heightPixel);
};
RectBlockView.prototype.onImageLoaded = function () {
this._img.setContentSize(this.owner.widthPixel + 6, this.owner.heightPixel + 6); //格子图片边缘有3像素的空白,撑满
};
RectBlockView.prototype.onUpdateMoveState = function () {
this._needMove = (this.node.position.y != this.owner.viewPixelPosY);
};
RectBlockView.prototype.onPositionChange = function (x, y) {
_super.prototype.onPositionChange.call(this, x, y);
var viewPosX = x + this._offsetX;
var viewPosY = y + this._offsetY;
this._img.setPosition(viewPosX + this._imgOffset.x, viewPosY + this._imgOffset.y);
this._imgEffect.setPosition(viewPosX, viewPosY);
this._txt.setPosition(viewPosX + this._txtOffset.x, viewPosY + this._txtOffset.y);
this._imgSkillIcon.setPosition(viewPosX, viewPosY);
this._colliderNode.setPosition(viewPosX, viewPosY);
this._light && this._light.setPosition(viewPosX, viewPosY);
};
RectBlockView.prototype.onDead = function () {
this._colliderNode.destroy();
_super.prototype.onDead.call(this);
};
// protected onDestroy(): void {
// this._colliderNode = null;
// }
// update (dt) {}
//#endregion
//#region public
RectBlockView.prototype.setColliderEnable = function (value) {
this._colliderNode.getComponent(cc.PhysicsCollider).enabled = value;
};
RectBlockView = __decorate([
ccclass
], RectBlockView);
return RectBlockView;
}(BlockView_1.default));
exports.default = RectBlockView;
cc._RF.pop();