186 lines
6.7 KiB
JavaScript
186 lines
6.7 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '805c6nf399HWZeuWnNB9CTH', 'GameOver');
|
|
// Script/GameOver.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 _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;
|
|
_this.count = null;
|
|
_this.time = null;
|
|
_this.selfNode = null;
|
|
_this.one = null;
|
|
_this.two = null;
|
|
_this.three = null;
|
|
_this.four = null;
|
|
_this.five = null;
|
|
return _this;
|
|
}
|
|
// onLoad () {}
|
|
NewClass.prototype.start = function () {
|
|
this.count.string = cc.fx.GameConfig.GM_INFO.score + "";
|
|
var yes = 0;
|
|
var successList = cc.fx.GameConfig.GM_INFO.successList;
|
|
if (successList.length > 0) {
|
|
var success = 0;
|
|
for (var i = 0; i < successList.length; i++) {
|
|
if (successList[i] == true)
|
|
success += 1;
|
|
}
|
|
yes = success / successList.length;
|
|
}
|
|
yes = Math.floor(yes * 1000) / 10;
|
|
this.time.string = yes + "%";
|
|
this.init();
|
|
};
|
|
//初始化数据
|
|
NewClass.prototype.init = function () {
|
|
this.listData = [];
|
|
this.selfData = null;
|
|
this.one.active = false;
|
|
this.two.active = false;
|
|
this.three.active = false;
|
|
this.four.active = false;
|
|
this.five.active = false;
|
|
var urlNow = window.location.href;
|
|
if (this.containsTrain(urlNow)) {
|
|
this.node.getChildByName("again").active = false;
|
|
this.node.getChildByName("back").active = false;
|
|
this.node.getChildByName("finishi").active = true;
|
|
}
|
|
else {
|
|
this.node.getChildByName("again").active = true;
|
|
this.node.getChildByName("back").active = true;
|
|
this.node.getChildByName("finishi").active = false;
|
|
}
|
|
this.getRank();
|
|
};
|
|
//打开排行榜
|
|
NewClass.prototype.openRank = function () {
|
|
cc.director.loadScene("RankScene");
|
|
};
|
|
//重新开始玩
|
|
NewClass.prototype.again = function () {
|
|
cc.fx.GameConfig.GM_INFO.round = 0;
|
|
cc.fx.GameConfig.GM_INFO.level = 0;
|
|
cc.fx.GameConfig.GM_INFO.stepTimeList = 0;
|
|
cc.fx.GameConfig.GM_INFO.successList = [];
|
|
cc.fx.GameConfig.GM_INFO.fen = 0;
|
|
cc.fx.GameConfig.GM_INFO.score = 0;
|
|
cc.fx.GameConfig.GM_INFO.min_Steps = 0;
|
|
cc.fx.GameConfig.GM_INFO.min_Time = 0;
|
|
cc.fx.GameConfig.TIME_INFO.totalTime = 120;
|
|
cc.director.loadScene("GameScene");
|
|
};
|
|
//判断来源
|
|
NewClass.prototype.containsTrain = function (str) {
|
|
return /from=train/i.test(str);
|
|
};
|
|
//获取排行榜
|
|
NewClass.prototype.getRank = function () {
|
|
var _this = this;
|
|
//获取排行榜数据 所需数据量
|
|
var dataFile = {
|
|
length: 5
|
|
};
|
|
cc.fx.GameTool.getRank(dataFile, function (data) { return _this.getRankData(data); });
|
|
};
|
|
//打开排行榜
|
|
NewClass.prototype.jumpFinishi = function () {
|
|
var url = "https://train.sparkus.cn/poster/game/";
|
|
window.location.href = url;
|
|
};
|
|
//设置排行信息
|
|
NewClass.prototype.getRankData = function (data) {
|
|
if (data) {
|
|
cc.fx.GameTool.getRankData(data, this, 4);
|
|
cc.fx.GameTool.setPic(this.selfNode.getChildByName("pic").getChildByName("icon"), this.selfData.pic);
|
|
var length = this.listData.length - 1;
|
|
if (length > 4)
|
|
length = 4;
|
|
for (var i = 0; i <= length; i++) {
|
|
this.setRank(i, this.listData[i]);
|
|
}
|
|
}
|
|
};
|
|
//根据内容填充排行榜
|
|
NewClass.prototype.setRank = function (num, data) {
|
|
var hitNode = null;
|
|
if (num == 0) {
|
|
hitNode = this.one;
|
|
}
|
|
else if (num == 1) {
|
|
hitNode = this.two;
|
|
}
|
|
else if (num == 2) {
|
|
hitNode = this.three;
|
|
}
|
|
else if (num == 3) {
|
|
hitNode = this.four;
|
|
}
|
|
else if (num == 4) {
|
|
hitNode = this.five;
|
|
}
|
|
if (hitNode) {
|
|
hitNode.active = true;
|
|
if (data.nickName.length >= 4)
|
|
cc.fx.GameTool.subName(data.nickName, 4);
|
|
hitNode.getChildByName("name").getComponent(cc.Label).string = data.nickName;
|
|
hitNode.getChildByName("total").getComponent(cc.Label).string = data.score;
|
|
cc.fx.GameTool.setPic(hitNode.getChildByName("pic").getChildByName("icon"), data.pic);
|
|
}
|
|
};
|
|
__decorate([
|
|
property(cc.Label)
|
|
], NewClass.prototype, "count", void 0);
|
|
__decorate([
|
|
property(cc.Label)
|
|
], NewClass.prototype, "time", void 0);
|
|
__decorate([
|
|
property(cc.Node)
|
|
], NewClass.prototype, "selfNode", void 0);
|
|
__decorate([
|
|
property(cc.Node)
|
|
], NewClass.prototype, "one", void 0);
|
|
__decorate([
|
|
property(cc.Node)
|
|
], NewClass.prototype, "two", void 0);
|
|
__decorate([
|
|
property(cc.Node)
|
|
], NewClass.prototype, "three", void 0);
|
|
__decorate([
|
|
property(cc.Node)
|
|
], NewClass.prototype, "four", void 0);
|
|
__decorate([
|
|
property(cc.Node)
|
|
], NewClass.prototype, "five", void 0);
|
|
NewClass = __decorate([
|
|
ccclass
|
|
], NewClass);
|
|
return NewClass;
|
|
}(cc.Component));
|
|
exports.default = NewClass;
|
|
|
|
cc._RF.pop(); |