5c204773-e6c5-40cb-83db-74590afd473e.js
3.69 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
"use strict";
cc._RF.push(module, '5c204dz5sVAy4PbdFkK/Uc+', 'GameSceneUnlockTip');
// scripts/ui/gameScene/GameSceneUnlockTip.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 SaveDataManager_1 = require("../../component/SaveDataManager");
var MainSceneData_1 = require("../../scenes/MainSceneData");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var GameSceneUnlockTip = /** @class */ (function (_super) {
__extends(GameSceneUnlockTip, _super);
function GameSceneUnlockTip() {
return _super !== null && _super.apply(this, arguments) || this;
}
//#region LIFE-CYCLE CALLBACKS:
GameSceneUnlockTip.prototype.onLoad = function () {
this._txtNum = this.node.getChildByName('btnUnlock').getComponentInChildren(cc.Label);
this._txtName = this.node.getChildByName('txtName').getComponent(cc.Label);
this._btn = this.node.getChildByName('btnUnlock');
};
// update (dt) {}
//#endregion
//#region public method
GameSceneUnlockTip.prototype.setObj = function (obj) {
this._obj = obj;
this.refresh();
};
//#endregion
//#region event
GameSceneUnlockTip.prototype.onClick = function () {
if (this._obj && !MainSceneData_1.MainSceneData.isUnlockAni) {
this.node.active = false;
if (SaveDataManager_1.SaveDataManager.ins.runtimeData.star >= this._obj.Star) {
var wpos = this._btn.convertToWorldSpaceAR(cc.v3(0, 0, 0));
if (SaveDataManager_1.SaveDataManager.ins.adjustStar(-this._obj.Star, true, wpos)) {
SaveDataManager_1.SaveDataManager.ins.unlockGameSceneObj(this._obj.ID);
}
}
}
};
//#endregion
//#region private method
GameSceneUnlockTip.prototype.refresh = function () {
this._txtName.string = this._obj.Name;
this._txtNum.string = this._obj.Star.toString();
this._btn.getComponent(cc.Button).interactable = SaveDataManager_1.SaveDataManager.ins.runtimeData.star >= this._obj.Star;
};
GameSceneUnlockTip = __decorate([
ccclass
], GameSceneUnlockTip);
return GameSceneUnlockTip;
}(cc.Component));
exports.default = GameSceneUnlockTip;
cc._RF.pop();