176 lines
6.7 KiB
JavaScript
176 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.finishiTime = null;
|
|
return _this;
|
|
}
|
|
// onLoad () {}
|
|
NewClass.prototype.start = function () {
|
|
this.count.string = 0 + "";
|
|
this.init();
|
|
// success_${today}_${code}_${matchedReferrer.gameId}
|
|
// const today = new Date().toLocaleDateString();
|
|
// const data = "success_${today}_${code}_${matchedReferrer.gameId}"
|
|
};
|
|
//初始化数据
|
|
NewClass.prototype.init = function () {
|
|
//展示准确率
|
|
this.showAccuracy();
|
|
//展示完成时间
|
|
this.showFinishiTime();
|
|
//上传排行榜
|
|
this.setRank();
|
|
//删除本关卡
|
|
setTimeout(function () {
|
|
cc.fx.GameTool.getCustom(true);
|
|
}, 100);
|
|
var urlNow = window.location.href;
|
|
if (this.containsTrain(urlNow)) {
|
|
this.node.getChildByName("btn").getChildByName("again").active = false;
|
|
this.node.getChildByName("btn").getChildByName("rank").active = false;
|
|
this.node.getChildByName("btn").getChildByName("finishi").active = true;
|
|
this.setLocalStorage();
|
|
}
|
|
else {
|
|
this.node.getChildByName("btn").getChildByName("again").active = true;
|
|
this.node.getChildByName("btn").getChildByName("rank").active = true;
|
|
this.node.getChildByName("btn").getChildByName("finishi").active = false;
|
|
}
|
|
};
|
|
NewClass.prototype.setLocalStorage = function () {
|
|
var today = new Date().toLocaleDateString();
|
|
var name = "success_" + today + "_" + cc.fx.GameConfig.GM_INFO.scode + "_" + cc.fx.GameConfig.GM_INFO.gameId;
|
|
localStorage.setItem(name, JSON.stringify({ success: true }));
|
|
};
|
|
NewClass.prototype.setRank = function () {
|
|
var data = {
|
|
"totleTimes": cc.fx.GameConfig.GM_INFO.stepTimeList,
|
|
"accuracy": this.accuracy,
|
|
};
|
|
cc.fx.GameTool.setRank(data);
|
|
};
|
|
NewClass.prototype.showFinishiTime = function () {
|
|
var _this = this;
|
|
cc.tween(this.finishiTime)
|
|
.delay(1.5)
|
|
.to(0.5, { fillRange: 1 })
|
|
.start();
|
|
cc.tween(this.time.node)
|
|
.delay(1.7)
|
|
.to(0.3, { opacity: 255 })
|
|
.call(function () {
|
|
_this.conversionTime();
|
|
})
|
|
.start();
|
|
};
|
|
NewClass.prototype.conversionTime = function () {
|
|
var _this = this;
|
|
var minute = 0;
|
|
var second = 0;
|
|
var obj = { a: 100 };
|
|
var time = parseInt(cc.fx.GameConfig.GM_INFO.stepTimeList / 1000 + "");
|
|
cc.tween(obj)
|
|
// .delay(0.1)
|
|
.to(1, { a: time }, {
|
|
progress: function (start, end, current, ratio) {
|
|
current = end * ratio;
|
|
second = current.toFixed(0);
|
|
if (second >= 60) {
|
|
minute = parseInt(second / 60 + "");
|
|
second -= 60 * minute;
|
|
}
|
|
_this.time.string = minute + "分" + second + "秒";
|
|
}
|
|
})
|
|
.call(function () {
|
|
_this.node.getChildByName("btn").active = true;
|
|
cc.tween(_this.node.getChildByName("btn"))
|
|
.to(0.3, { opacity: 255 })
|
|
.start();
|
|
})
|
|
.start();
|
|
};
|
|
NewClass.prototype.showAccuracy = function () {
|
|
var _this = this;
|
|
this.accuracy = parseInt(cc.fx.GameConfig.GM_INFO.successList.length /
|
|
cc.fx.GameConfig.GM_INFO.level * 100 + "");
|
|
console.log("答对的个数:", cc.fx.GameConfig.GM_INFO.successList.length);
|
|
console.log("总数:", cc.fx.GameConfig.GM_INFO.level);
|
|
console.log("准确率:", this.accuracy);
|
|
var obj = { a: 100 };
|
|
cc.tween(obj)
|
|
.delay(0.5)
|
|
.to(1, { a: this.accuracy }, {
|
|
progress: function (start, end, current, ratio) {
|
|
current = end * ratio;
|
|
current = current.toFixed(0);
|
|
_this.count.string = current + "";
|
|
}
|
|
})
|
|
.start();
|
|
};
|
|
NewClass.prototype.jumpFinishi = function () {
|
|
var url = "https://train.sparkus.cn/poster/game/" + cc.fx.GameConfig.GM_INFO.scode + "?suc=1";
|
|
window.location.href = url;
|
|
};
|
|
//判断来源
|
|
NewClass.prototype.containsTrain = function (str) {
|
|
return /from=train/i.test(str);
|
|
};
|
|
//打开排行榜
|
|
NewClass.prototype.openRank = function () {
|
|
cc.director.loadScene("RankScene");
|
|
};
|
|
//重新开始玩
|
|
NewClass.prototype.again = function () {
|
|
cc.director.loadScene("GameScene");
|
|
};
|
|
NewClass.prototype.update = function (dt) {
|
|
// this.count.string = this.accuracy + "";
|
|
};
|
|
__decorate([
|
|
property(cc.Label)
|
|
], NewClass.prototype, "count", void 0);
|
|
__decorate([
|
|
property(cc.Label)
|
|
], NewClass.prototype, "time", void 0);
|
|
__decorate([
|
|
property(cc.Sprite)
|
|
], NewClass.prototype, "finishiTime", void 0);
|
|
NewClass = __decorate([
|
|
ccclass
|
|
], NewClass);
|
|
return NewClass;
|
|
}(cc.Component));
|
|
exports.default = NewClass;
|
|
|
|
cc._RF.pop(); |