Commit d672b3bd authored by Edwise's avatar Edwise 🍷

1234

parent 68ca898c
...@@ -46905,6 +46905,7 @@ var MainScene = (function (_super) { ...@@ -46905,6 +46905,7 @@ var MainScene = (function (_super) {
_this.bgUUID = []; _this.bgUUID = [];
_this.maxEnergy = 1500; _this.maxEnergy = 1500;
_this.level = 0; _this.level = 0;
_this.isShow = false;
return _this; return _this;
} }
MainScene.prototype.initUi = function () { MainScene.prototype.initUi = function () {
...@@ -46943,7 +46944,7 @@ var MainScene = (function (_super) { ...@@ -46943,7 +46944,7 @@ var MainScene = (function (_super) {
} }
that.initCat(); that.initCat();
that.initEnergy(); that.initEnergy();
that.energyUp(); that.energyUp1();
}; };
MainScene.prototype.initCat = function () { MainScene.prototype.initCat = function () {
var that = this; var that = this;
...@@ -47059,11 +47060,39 @@ var MainScene = (function (_super) { ...@@ -47059,11 +47060,39 @@ var MainScene = (function (_super) {
that.energyLabel.text = "精力" + that.energy + "/" + that.maxEnergy; that.energyLabel.text = "精力" + that.energy + "/" + that.maxEnergy;
that.energyLabel.x = (that.energyGroup.width - that.energyLabel.textWidth) / 2; that.energyLabel.x = (that.energyGroup.width - that.energyLabel.textWidth) / 2;
}; };
MainScene.prototype.energyUp = function () { MainScene.prototype.energyUp1 = function () {
var that = this; var that = this;
if (that.recoverEnergyHandler)
clearInterval(that.recoverEnergyHandler);
console.log("上一次恢复精力的时间", new Date(Ins_1.Ins.userInfo.lastEnergyTime).getMinutes());
var time = new Date().getTime() - Ins_1.Ins.userInfo.lastEnergyTime;
console.log("相差的时间", Math.floor(time % 3600 / 60));
if (time <= Ins_1.Ins.recoverEnergy) {
that.recoverEnergyTime = Ins_1.Ins.recoverEnergy - time;
}
that.recoverEnergyHandler = setInterval(function () {
TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.recoverEnergy, {}, function (s, r) {
if (s) {
console.log("恢复精力时间:", new Date().getMinutes());
clearInterval(that.recoverEnergyHandler);
that.energyUp2();
that.getUserEnergy();
}
else {
Ins_1.Ins.showToast(r.message);
}
});
}, that.recoverEnergyTime);
};
MainScene.prototype.energyUp2 = function () {
var that = this;
if (that.recoverEnergyHandler)
clearInterval(that.recoverEnergyHandler);
that.recoverEnergyTime = Ins_1.Ins.recoverEnergy;
that.recoverEnergyHandler = setInterval(function () { that.recoverEnergyHandler = setInterval(function () {
TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.recoverEnergy, {}, function (s, r) { TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.recoverEnergy, {}, function (s, r) {
if (s) { if (s) {
console.log("恢复精力时间2:", new Date().getMinutes());
that.getUserEnergy(); that.getUserEnergy();
} }
else { else {
...@@ -47072,10 +47101,14 @@ var MainScene = (function (_super) { ...@@ -47072,10 +47101,14 @@ var MainScene = (function (_super) {
}); });
}, Ins_1.Ins.recoverEnergy); }, Ins_1.Ins.recoverEnergy);
}; };
MainScene.prototype.showPageEnergyUp = function () {
};
MainScene.prototype.getUserEnergy = function () { MainScene.prototype.getUserEnergy = function () {
var that = this; var that = this;
TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.getUserEnergy, {}, function (s, r) { TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.getUserEnergy, {}, function (s, r) {
if (s) { if (s) {
that.recoverEnergyTime = Ins_1.Ins.recoverEnergy;
console.log("设置恢复时间", that.recoverEnergyTime);
if (r.data != Ins_1.Ins.userInfo.energy) { if (r.data != Ins_1.Ins.userInfo.energy) {
Ins_1.Ins.userInfo.energy = r.data; Ins_1.Ins.userInfo.energy = r.data;
that.setEnergy(); that.setEnergy();
...@@ -47083,7 +47116,9 @@ var MainScene = (function (_super) { ...@@ -47083,7 +47116,9 @@ var MainScene = (function (_super) {
} }
else { else {
if (r.data != Ins_1.Ins.userInfo.energyMax) { if (r.data != Ins_1.Ins.userInfo.energyMax) {
that.getUserEnergy(); setTimeout(function () {
that.getUserEnergy();
}, 500);
} }
else { else {
return; return;
...@@ -47150,6 +47185,10 @@ var MainScene = (function (_super) { ...@@ -47150,6 +47185,10 @@ var MainScene = (function (_super) {
TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.getUserInfo, {}, function (s, r) { TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.getUserInfo, {}, function (s, r) {
if (s) { if (s) {
Ins_1.Ins.userInfo = r.data; Ins_1.Ins.userInfo = r.data;
if (that.isShow) {
that.isShow = false;
that.energyUp1();
}
that.setEnergy(); that.setEnergy();
that.mainUi.updateUserInfo(); that.mainUi.updateUserInfo();
} }
...@@ -47193,6 +47232,14 @@ var MainScene = (function (_super) { ...@@ -47193,6 +47232,14 @@ var MainScene = (function (_super) {
} }
}); });
}; };
MainScene.prototype.onShow = function () {
console.log("canvas页面显示,isShow设置为true");
this.isShow = true;
};
MainScene.prototype.onHide = function () {
console.log("canvas页面显示, isShow设置为false");
this.isShow = false;
};
MainScene.prototype.initEvents = function () { MainScene.prototype.initEvents = function () {
var that = this; var that = this;
console.log("主场景添加事件"); console.log("主场景添加事件");
...@@ -47202,6 +47249,8 @@ var MainScene = (function (_super) { ...@@ -47202,6 +47249,8 @@ var MainScene = (function (_super) {
FYGE.GDispatcher.addEventListener(Enum_1.MSG.CHANGE_SCENE, function () { that.changeMainScene(Enum_1.SCENETYPE.BEADROOM); }, that); FYGE.GDispatcher.addEventListener(Enum_1.MSG.CHANGE_SCENE, function () { that.changeMainScene(Enum_1.SCENETYPE.BEADROOM); }, that);
Main_1.GDispatcher.addEventListener(Enum_1.MSG.UPDATE_USERINFO, that.updateUserInfo, that); Main_1.GDispatcher.addEventListener(Enum_1.MSG.UPDATE_USERINFO, that.updateUserInfo, that);
Main_1.GDispatcher.addEventListener(Enum_1.MSG.RECALL_CAT, that.recallCat, that); Main_1.GDispatcher.addEventListener(Enum_1.MSG.RECALL_CAT, that.recallCat, that);
Main_1.GDispatcher.addEventListener("onShow", that.onShow, that);
Main_1.GDispatcher.addEventListener("onHide", that.onHide, that);
}; };
MainScene.prototype.removeEvents = function () { MainScene.prototype.removeEvents = function () {
var that = this; var that = this;
...@@ -47213,6 +47262,8 @@ var MainScene = (function (_super) { ...@@ -47213,6 +47262,8 @@ var MainScene = (function (_super) {
FYGE.GDispatcher.removeEventListener(Enum_1.MSG.CHANGE_SCENE, function () { that.changeMainScene(Enum_1.SCENETYPE.BEADROOM); }, that); FYGE.GDispatcher.removeEventListener(Enum_1.MSG.CHANGE_SCENE, function () { that.changeMainScene(Enum_1.SCENETYPE.BEADROOM); }, that);
Main_1.GDispatcher.removeEventListener(Enum_1.MSG.UPDATE_USERINFO, that.updateUserInfo, that); Main_1.GDispatcher.removeEventListener(Enum_1.MSG.UPDATE_USERINFO, that.updateUserInfo, that);
Main_1.GDispatcher.removeEventListener(Enum_1.MSG.RECALL_CAT, that.recallCat, that); Main_1.GDispatcher.removeEventListener(Enum_1.MSG.RECALL_CAT, that.recallCat, that);
Main_1.GDispatcher.addEventListener("onShow", that.onShow, that);
Main_1.GDispatcher.addEventListener("onHide", that.onHide, that);
}; };
return MainScene; return MainScene;
}(Scene_1.Scene)); }(Scene_1.Scene));
...@@ -47286,6 +47337,7 @@ var StartScene = (function (_super) { ...@@ -47286,6 +47337,7 @@ var StartScene = (function (_super) {
}; };
StartScene.prototype.getCat = function (r) { StartScene.prototype.getCat = function (r) {
console.log("选择完猫咪", r); console.log("选择完猫咪", r);
Ins_1.Ins.showLoading();
Ins_1.Ins.userInfo = r.data.data; Ins_1.Ins.userInfo = r.data.data;
this.judgeCatIsOutAChangeMainScene(); this.judgeCatIsOutAChangeMainScene();
}; };
...@@ -47304,6 +47356,7 @@ var StartScene = (function (_super) { ...@@ -47304,6 +47356,7 @@ var StartScene = (function (_super) {
ctrls_1.changeScene(MainScene_1.MainScene); ctrls_1.changeScene(MainScene_1.MainScene);
} }
else { else {
Ins_1.Ins.hideLoading();
Ins_1.Ins.showToast(r.message); Ins_1.Ins.showToast(r.message);
} }
}); });
This diff is collapsed.
...@@ -46907,6 +46907,7 @@ var MainScene = (function (_super) { ...@@ -46907,6 +46907,7 @@ var MainScene = (function (_super) {
_this.bgUUID = []; _this.bgUUID = [];
_this.maxEnergy = 1500; _this.maxEnergy = 1500;
_this.level = 0; _this.level = 0;
_this.isShow = false;
return _this; return _this;
} }
MainScene.prototype.initUi = function () { MainScene.prototype.initUi = function () {
...@@ -46945,7 +46946,7 @@ var MainScene = (function (_super) { ...@@ -46945,7 +46946,7 @@ var MainScene = (function (_super) {
} }
that.initCat(); that.initCat();
that.initEnergy(); that.initEnergy();
that.energyUp(); that.energyUp1();
}; };
MainScene.prototype.initCat = function () { MainScene.prototype.initCat = function () {
var that = this; var that = this;
...@@ -47061,11 +47062,39 @@ var MainScene = (function (_super) { ...@@ -47061,11 +47062,39 @@ var MainScene = (function (_super) {
that.energyLabel.text = "精力" + that.energy + "/" + that.maxEnergy; that.energyLabel.text = "精力" + that.energy + "/" + that.maxEnergy;
that.energyLabel.x = (that.energyGroup.width - that.energyLabel.textWidth) / 2; that.energyLabel.x = (that.energyGroup.width - that.energyLabel.textWidth) / 2;
}; };
MainScene.prototype.energyUp = function () { MainScene.prototype.energyUp1 = function () {
var that = this; var that = this;
if (that.recoverEnergyHandler)
clearInterval(that.recoverEnergyHandler);
console.log("上一次恢复精力的时间", new Date(Ins_1.Ins.userInfo.lastEnergyTime).getMinutes());
var time = new Date().getTime() - Ins_1.Ins.userInfo.lastEnergyTime;
console.log("相差的时间", Math.floor(time % 3600 / 60));
if (time <= Ins_1.Ins.recoverEnergy) {
that.recoverEnergyTime = Ins_1.Ins.recoverEnergy - time;
}
that.recoverEnergyHandler = setInterval(function () {
TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.recoverEnergy, {}, function (s, r) {
if (s) {
console.log("恢复精力时间:", new Date().getMinutes());
clearInterval(that.recoverEnergyHandler);
that.energyUp2();
that.getUserEnergy();
}
else {
Ins_1.Ins.showToast(r.message);
}
});
}, that.recoverEnergyTime);
};
MainScene.prototype.energyUp2 = function () {
var that = this;
if (that.recoverEnergyHandler)
clearInterval(that.recoverEnergyHandler);
that.recoverEnergyTime = Ins_1.Ins.recoverEnergy;
that.recoverEnergyHandler = setInterval(function () { that.recoverEnergyHandler = setInterval(function () {
TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.recoverEnergy, {}, function (s, r) { TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.recoverEnergy, {}, function (s, r) {
if (s) { if (s) {
console.log("恢复精力时间2:", new Date().getMinutes());
that.getUserEnergy(); that.getUserEnergy();
} }
else { else {
...@@ -47074,10 +47103,14 @@ var MainScene = (function (_super) { ...@@ -47074,10 +47103,14 @@ var MainScene = (function (_super) {
}); });
}, Ins_1.Ins.recoverEnergy); }, Ins_1.Ins.recoverEnergy);
}; };
MainScene.prototype.showPageEnergyUp = function () {
};
MainScene.prototype.getUserEnergy = function () { MainScene.prototype.getUserEnergy = function () {
var that = this; var that = this;
TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.getUserEnergy, {}, function (s, r) { TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.getUserEnergy, {}, function (s, r) {
if (s) { if (s) {
that.recoverEnergyTime = Ins_1.Ins.recoverEnergy;
console.log("设置恢复时间", that.recoverEnergyTime);
if (r.data != Ins_1.Ins.userInfo.energy) { if (r.data != Ins_1.Ins.userInfo.energy) {
Ins_1.Ins.userInfo.energy = r.data; Ins_1.Ins.userInfo.energy = r.data;
that.setEnergy(); that.setEnergy();
...@@ -47085,7 +47118,9 @@ var MainScene = (function (_super) { ...@@ -47085,7 +47118,9 @@ var MainScene = (function (_super) {
} }
else { else {
if (r.data != Ins_1.Ins.userInfo.energyMax) { if (r.data != Ins_1.Ins.userInfo.energyMax) {
that.getUserEnergy(); setTimeout(function () {
that.getUserEnergy();
}, 500);
} }
else { else {
return; return;
...@@ -47152,6 +47187,10 @@ var MainScene = (function (_super) { ...@@ -47152,6 +47187,10 @@ var MainScene = (function (_super) {
TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.getUserInfo, {}, function (s, r) { TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.getUserInfo, {}, function (s, r) {
if (s) { if (s) {
Ins_1.Ins.userInfo = r.data; Ins_1.Ins.userInfo = r.data;
if (that.isShow) {
that.isShow = false;
that.energyUp1();
}
that.setEnergy(); that.setEnergy();
that.mainUi.updateUserInfo(); that.mainUi.updateUserInfo();
} }
...@@ -47195,6 +47234,14 @@ var MainScene = (function (_super) { ...@@ -47195,6 +47234,14 @@ var MainScene = (function (_super) {
} }
}); });
}; };
MainScene.prototype.onShow = function () {
console.log("canvas页面显示,isShow设置为true");
this.isShow = true;
};
MainScene.prototype.onHide = function () {
console.log("canvas页面显示, isShow设置为false");
this.isShow = false;
};
MainScene.prototype.initEvents = function () { MainScene.prototype.initEvents = function () {
var that = this; var that = this;
console.log("主场景添加事件"); console.log("主场景添加事件");
...@@ -47204,6 +47251,8 @@ var MainScene = (function (_super) { ...@@ -47204,6 +47251,8 @@ var MainScene = (function (_super) {
FYGE.GDispatcher.addEventListener(Enum_1.MSG.CHANGE_SCENE, function () { that.changeMainScene(Enum_1.SCENETYPE.BEADROOM); }, that); FYGE.GDispatcher.addEventListener(Enum_1.MSG.CHANGE_SCENE, function () { that.changeMainScene(Enum_1.SCENETYPE.BEADROOM); }, that);
Main_1.GDispatcher.addEventListener(Enum_1.MSG.UPDATE_USERINFO, that.updateUserInfo, that); Main_1.GDispatcher.addEventListener(Enum_1.MSG.UPDATE_USERINFO, that.updateUserInfo, that);
Main_1.GDispatcher.addEventListener(Enum_1.MSG.RECALL_CAT, that.recallCat, that); Main_1.GDispatcher.addEventListener(Enum_1.MSG.RECALL_CAT, that.recallCat, that);
Main_1.GDispatcher.addEventListener("onShow", that.onShow, that);
Main_1.GDispatcher.addEventListener("onHide", that.onHide, that);
}; };
MainScene.prototype.removeEvents = function () { MainScene.prototype.removeEvents = function () {
var that = this; var that = this;
...@@ -47215,6 +47264,8 @@ var MainScene = (function (_super) { ...@@ -47215,6 +47264,8 @@ var MainScene = (function (_super) {
FYGE.GDispatcher.removeEventListener(Enum_1.MSG.CHANGE_SCENE, function () { that.changeMainScene(Enum_1.SCENETYPE.BEADROOM); }, that); FYGE.GDispatcher.removeEventListener(Enum_1.MSG.CHANGE_SCENE, function () { that.changeMainScene(Enum_1.SCENETYPE.BEADROOM); }, that);
Main_1.GDispatcher.removeEventListener(Enum_1.MSG.UPDATE_USERINFO, that.updateUserInfo, that); Main_1.GDispatcher.removeEventListener(Enum_1.MSG.UPDATE_USERINFO, that.updateUserInfo, that);
Main_1.GDispatcher.removeEventListener(Enum_1.MSG.RECALL_CAT, that.recallCat, that); Main_1.GDispatcher.removeEventListener(Enum_1.MSG.RECALL_CAT, that.recallCat, that);
Main_1.GDispatcher.addEventListener("onShow", that.onShow, that);
Main_1.GDispatcher.addEventListener("onHide", that.onHide, that);
}; };
return MainScene; return MainScene;
}(Scene_1.Scene)); }(Scene_1.Scene));
...@@ -47288,6 +47339,7 @@ var StartScene = (function (_super) { ...@@ -47288,6 +47339,7 @@ var StartScene = (function (_super) {
}; };
StartScene.prototype.getCat = function (r) { StartScene.prototype.getCat = function (r) {
console.log("选择完猫咪", r); console.log("选择完猫咪", r);
Ins_1.Ins.showLoading();
Ins_1.Ins.userInfo = r.data.data; Ins_1.Ins.userInfo = r.data.data;
this.judgeCatIsOutAChangeMainScene(); this.judgeCatIsOutAChangeMainScene();
}; };
...@@ -47306,6 +47358,7 @@ var StartScene = (function (_super) { ...@@ -47306,6 +47358,7 @@ var StartScene = (function (_super) {
ctrls_1.changeScene(MainScene_1.MainScene); ctrls_1.changeScene(MainScene_1.MainScene);
} }
else { else {
Ins_1.Ins.hideLoading();
Ins_1.Ins.showToast(r.message); Ins_1.Ins.showToast(r.message);
} }
}); });
...@@ -7,7 +7,7 @@ var fs = require("fs"); ...@@ -7,7 +7,7 @@ var fs = require("fs");
// ) // )
// var endPath = 'D:/duibaGame/测试项目0527/taobaominiTest/client/pages/index1/'; // var endPath = 'D:/duibaGame/测试项目0527/taobaominiTest/client/pages/index1/';
// var endPath = '/Users/wanghongyuan/new_taobao/taobao_mini/client/pages/pagecanvas/'; // var endPath = '/Users/wanghongyuan/new_taobao/taobao_mini/client/pages/pagecanvas/';
var endPath = 'D:/taobaoProject/tmyangcheng/new_taobao/taobao_mini/client/pages/pagecanvas'; var endPath = 'D:/taobaoProject/tmyangcheng/new_taobao/taobao_mini/client/pages/pagecanvas/';
var version = Math.round(new Date().getTime() / 1000); var version = Math.round(new Date().getTime() / 1000);
// fs.writeFileSync(endPath + "output." + version + ".js", fs.readFileSync("./released/output.js")); // fs.writeFileSync(endPath + "output." + version + ".js", fs.readFileSync("./released/output.js"));
......
...@@ -20,6 +20,8 @@ export class Ins { ...@@ -20,6 +20,8 @@ export class Ins {
/**多长时间恢复精力(ms) */ /**多长时间恢复精力(ms) */
public static recoverEnergy:number = 5*60*1000; public static recoverEnergy:number = 5*60*1000;
// /**最长时间恢复精力 */
public static userInfo: { public static userInfo: {
"catName": string, //猫咪姓名 "catName": string, //猫咪姓名
"catType": number, //猫咪类型 "catType": number, //猫咪类型
......
...@@ -49,7 +49,11 @@ export class MainScene extends Scene { ...@@ -49,7 +49,11 @@ export class MainScene extends Scene {
/**场景引导 */ /**场景引导 */
private Guide: Guide; private Guide: Guide;
/**是否是重新进入游戏场景 */ /**恢复精力的时间 */
private recoverEnergyTime:number;
/**页面是否显示 */
private isShow:boolean = false;
initUi() { initUi() {
var that = this; var that = this;
...@@ -96,7 +100,7 @@ export class MainScene extends Scene { ...@@ -96,7 +100,7 @@ export class MainScene extends Scene {
that.initCat(); that.initCat();
that.initEnergy(); that.initEnergy();
that.energyUp(); that.energyUp1();
// that.initGuide(Ins.curScene > 3 ? 3 : Ins.curScene); // that.initGuide(Ins.curScene > 3 ? 3 : Ins.curScene);
} }
...@@ -235,12 +239,39 @@ export class MainScene extends Scene { ...@@ -235,12 +239,39 @@ export class MainScene extends Scene {
that.energyLabel.x = (that.energyGroup.width - that.energyLabel.textWidth) / 2 that.energyLabel.x = (that.energyGroup.width - that.energyLabel.textWidth) / 2
} }
/**按照时间恢复精力 */ /**按照首次登录时间恢复精力 */
energyUp() { energyUp1() {
var that = this; var that = this;
if(that.recoverEnergyHandler) clearInterval(that.recoverEnergyHandler);
console.log("上一次恢复精力的时间",new Date(Ins.userInfo.lastEnergyTime).getMinutes())
let time = new Date().getTime()-Ins.userInfo.lastEnergyTime;
console.log("相差的时间",Math.floor(time % 3600 / 60))
if(time<=Ins.recoverEnergy){
that.recoverEnergyTime = Ins.recoverEnergy - time;
}
that.recoverEnergyHandler = setInterval(() => { that.recoverEnergyHandler = setInterval(() => {
sendTbNet(TbNetName.recoverEnergy, {}, (s, r) => { sendTbNet(TbNetName.recoverEnergy, {}, (s, r) => {
if (s) { if (s) {
console.log("恢复精力时间:",new Date().getMinutes())
clearInterval(that.recoverEnergyHandler);
that.energyUp2();
that.getUserEnergy();
} else {
Ins.showToast(r.message);
}
});
}, that.recoverEnergyTime)
}
/**按照固定时间恢复精力 */
energyUp2(){
var that = this;
if(that.recoverEnergyHandler) clearInterval(that.recoverEnergyHandler);
that.recoverEnergyTime = Ins.recoverEnergy;
that.recoverEnergyHandler = setInterval(() => {
sendTbNet(TbNetName.recoverEnergy, {}, (s, r) => {
if (s) {
console.log("恢复精力时间2:",new Date().getMinutes())
that.getUserEnergy(); that.getUserEnergy();
} else { } else {
Ins.showToast(r.message); Ins.showToast(r.message);
...@@ -249,18 +280,29 @@ export class MainScene extends Scene { ...@@ -249,18 +280,29 @@ export class MainScene extends Scene {
}, Ins.recoverEnergy) }, Ins.recoverEnergy)
} }
/**显示页面时重新计算时间恢复精力 */
showPageEnergyUp(){
}
/**时间到的时候拿取精力值 */ /**时间到的时候拿取精力值 */
getUserEnergy() { getUserEnergy() {
var that = this; var that = this;
sendTbNet(TbNetName.getUserEnergy, {}, (s, r) => { sendTbNet(TbNetName.getUserEnergy, {}, (s, r) => {
if (s) { if (s) {
that.recoverEnergyTime = Ins.recoverEnergy;
console.log("设置恢复时间",that.recoverEnergyTime)
if (r.data != Ins.userInfo.energy) { if (r.data != Ins.userInfo.energy) {
Ins.userInfo.energy = r.data; Ins.userInfo.energy = r.data;
// that.recoverEnergyTime = Ins.recoverEnergy;
// console.log("设置恢复时间",that.recoverEnergyTime)
that.setEnergy(); that.setEnergy();
return; return;
} else { } else {
if (r.data != Ins.userInfo.energyMax) { if (r.data != Ins.userInfo.energyMax) {
that.getUserEnergy(); setTimeout(()=>{
that.getUserEnergy();
},500)
} }
else { else {
return; return;
...@@ -332,9 +374,12 @@ export class MainScene extends Scene { ...@@ -332,9 +374,12 @@ export class MainScene extends Scene {
sendTbNet(TbNetName.getUserInfo, {}, (s, r) => { sendTbNet(TbNetName.getUserInfo, {}, (s, r) => {
if (s) { if (s) {
Ins.userInfo = r.data; Ins.userInfo = r.data;
if(that.isShow){
that.isShow = false;
that.energyUp1();
}
that.setEnergy(); that.setEnergy();
that.mainUi.updateUserInfo(); that.mainUi.updateUserInfo();
} else { } else {
Ins.showToast(r.message) Ins.showToast(r.message)
} }
...@@ -376,6 +421,17 @@ export class MainScene extends Scene { ...@@ -376,6 +421,17 @@ export class MainScene extends Scene {
}) })
} }
/**页面显示 */
onShow(){
console.log("canvas页面显示,isShow设置为true")
this.isShow = true;
}
/**页面隐藏 */
onHide(){
console.log("canvas页面显示, isShow设置为false")
this.isShow = false;
}
initEvents() { initEvents() {
var that = this; var that = this;
...@@ -386,6 +442,8 @@ export class MainScene extends Scene { ...@@ -386,6 +442,8 @@ export class MainScene extends Scene {
FYGE.GDispatcher.addEventListener(MSG.CHANGE_SCENE, () => { that.changeMainScene(SCENETYPE.BEADROOM) }, that); FYGE.GDispatcher.addEventListener(MSG.CHANGE_SCENE, () => { that.changeMainScene(SCENETYPE.BEADROOM) }, that);
GDispatcher.addEventListener(MSG.UPDATE_USERINFO, that.updateUserInfo, that); GDispatcher.addEventListener(MSG.UPDATE_USERINFO, that.updateUserInfo, that);
GDispatcher.addEventListener(MSG.RECALL_CAT, that.recallCat, that); GDispatcher.addEventListener(MSG.RECALL_CAT, that.recallCat, that);
GDispatcher.addEventListener("onShow",that.onShow,that);
GDispatcher.addEventListener("onHide",that.onHide,that);
} }
removeEvents() { removeEvents() {
...@@ -398,5 +456,7 @@ export class MainScene extends Scene { ...@@ -398,5 +456,7 @@ export class MainScene extends Scene {
FYGE.GDispatcher.removeEventListener(MSG.CHANGE_SCENE, () => { that.changeMainScene(SCENETYPE.BEADROOM) }, that); FYGE.GDispatcher.removeEventListener(MSG.CHANGE_SCENE, () => { that.changeMainScene(SCENETYPE.BEADROOM) }, that);
GDispatcher.removeEventListener(MSG.UPDATE_USERINFO, that.updateUserInfo, that); GDispatcher.removeEventListener(MSG.UPDATE_USERINFO, that.updateUserInfo, that);
GDispatcher.removeEventListener(MSG.RECALL_CAT, that.recallCat, that); GDispatcher.removeEventListener(MSG.RECALL_CAT, that.recallCat, that);
GDispatcher.addEventListener("onShow",that.onShow,that);
GDispatcher.addEventListener("onHide",that.onHide,that);
} }
} }
\ No newline at end of file
...@@ -44,6 +44,7 @@ export class StartScene extends Scene { ...@@ -44,6 +44,7 @@ export class StartScene extends Scene {
/**领养完毕猫咪 */ /**领养完毕猫咪 */
getCat(r) { getCat(r) {
console.log("选择完猫咪",r) console.log("选择完猫咪",r)
Ins.showLoading();
Ins.userInfo = r.data.data; Ins.userInfo = r.data.data;
/**判断猫咪是否出寝,只在用户进入游戏时判断,后面要根据接口改写,现在先做测试 */ /**判断猫咪是否出寝,只在用户进入游戏时判断,后面要根据接口改写,现在先做测试 */
this.judgeCatIsOutAChangeMainScene(); this.judgeCatIsOutAChangeMainScene();
...@@ -63,6 +64,7 @@ export class StartScene extends Scene { ...@@ -63,6 +64,7 @@ export class StartScene extends Scene {
Ins.hideLoading(); Ins.hideLoading();
changeScene(MainScene) changeScene(MainScene)
}else{ }else{
Ins.hideLoading();
Ins.showToast(r.message); Ins.showToast(r.message);
} }
}) })
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
height: 559rpx; height: 559rpx;
opacity: 1; opacity: 1;
left: 18rpx; left: 18rpx;
top: 392rpx; top: 442rpx;
position: absolute; position: absolute;
transform-origin: 50% 50% 0rpx; transform-origin: 50% 50% 0rpx;
display: block; display: block;
......
...@@ -96,14 +96,27 @@ ...@@ -96,14 +96,27 @@
transform-origin: 0rpx 0rpx 0rpx; transform-origin: 0rpx 0rpx 0rpx;
} }
.levelup .levelup_prizeView {
width: 353rpx;
height: 293rpx;
opacity: 1;
left: 201rpx;
top: 380rpx;
position: absolute;
transform-origin: 0rpx 0rpx 0rpx;
overflow: hidden;
/* border: 3rpx solid black; */
border-radius: 10rpx;
}
.levelup .levelup_prizeImg { .levelup .levelup_prizeImg {
width: 349rpx; width: 360rpx;
height: 288rpx; height: 299rpx;
opacity: 1; opacity: 1;
left: 203rpx;
top: 382rpx;
position: absolute; position: absolute;
transform-origin: 0rpx 0rpx 0rpx; transform-origin: 0rpx 0rpx 0rpx;
left: -3rpx;
top: -3rpx;
} }
.levelup .levelup_btn { .levelup .levelup_btn {
......
...@@ -7,7 +7,9 @@ ...@@ -7,7 +7,9 @@
<label class="levelup_txt ">{{levelupTxt}}</label> <label class="levelup_txt ">{{levelupTxt}}</label>
<image class="levelup_title " src={{resList['69bff61a-b5a6-4979-ba8d-9e008aed737a'].url}} /> <image class="levelup_title " src={{resList['69bff61a-b5a6-4979-ba8d-9e008aed737a'].url}} />
<image class="levelup_imgbg " src={{resList['f56872e2-5e79-4906-99a2-576231f153af'].url}} /> <image class="levelup_imgbg " src={{resList['f56872e2-5e79-4906-99a2-576231f153af'].url}} />
<image class="levelup_prizeImg" src="{{prizeImg}}"/>> <view class="levelup_prizeView">
<image class="levelup_prizeImg" src="{{prizeImg}}"/>>
</view>
<image class="levelup_btn btn" onTap="onBtnClick" src={{resList['95520b55-9655-4988-a833-3907978dbffb'].url}} /> <image class="levelup_btn btn" onTap="onBtnClick" src={{resList['95520b55-9655-4988-a833-3907978dbffb'].url}} />
<image class="levelup_closebtn " onTap="onModalClose" src={{resList['d33bbf87-ed39-4959-8673-02a4c31dca77'].url}} /> <image class="levelup_closebtn " onTap="onModalClose" src={{resList['d33bbf87-ed39-4959-8673-02a4c31dca77'].url}} />
</view> </view>
......
...@@ -46907,6 +46907,7 @@ var MainScene = (function (_super) { ...@@ -46907,6 +46907,7 @@ var MainScene = (function (_super) {
_this.bgUUID = []; _this.bgUUID = [];
_this.maxEnergy = 1500; _this.maxEnergy = 1500;
_this.level = 0; _this.level = 0;
_this.isShow = false;
return _this; return _this;
} }
MainScene.prototype.initUi = function () { MainScene.prototype.initUi = function () {
...@@ -46945,7 +46946,7 @@ var MainScene = (function (_super) { ...@@ -46945,7 +46946,7 @@ var MainScene = (function (_super) {
} }
that.initCat(); that.initCat();
that.initEnergy(); that.initEnergy();
that.energyUp(); that.energyUp1();
}; };
MainScene.prototype.initCat = function () { MainScene.prototype.initCat = function () {
var that = this; var that = this;
...@@ -47061,11 +47062,39 @@ var MainScene = (function (_super) { ...@@ -47061,11 +47062,39 @@ var MainScene = (function (_super) {
that.energyLabel.text = "精力" + that.energy + "/" + that.maxEnergy; that.energyLabel.text = "精力" + that.energy + "/" + that.maxEnergy;
that.energyLabel.x = (that.energyGroup.width - that.energyLabel.textWidth) / 2; that.energyLabel.x = (that.energyGroup.width - that.energyLabel.textWidth) / 2;
}; };
MainScene.prototype.energyUp = function () { MainScene.prototype.energyUp1 = function () {
var that = this; var that = this;
if (that.recoverEnergyHandler)
clearInterval(that.recoverEnergyHandler);
console.log("上一次恢复精力的时间", new Date(Ins_1.Ins.userInfo.lastEnergyTime).getMinutes());
var time = new Date().getTime() - Ins_1.Ins.userInfo.lastEnergyTime;
console.log("相差的时间", Math.floor(time % 3600 / 60));
if (time <= Ins_1.Ins.recoverEnergy) {
that.recoverEnergyTime = Ins_1.Ins.recoverEnergy - time;
}
that.recoverEnergyHandler = setInterval(function () {
TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.recoverEnergy, {}, function (s, r) {
if (s) {
console.log("恢复精力时间:", new Date().getMinutes());
clearInterval(that.recoverEnergyHandler);
that.energyUp2();
that.getUserEnergy();
}
else {
Ins_1.Ins.showToast(r.message);
}
});
}, that.recoverEnergyTime);
};
MainScene.prototype.energyUp2 = function () {
var that = this;
if (that.recoverEnergyHandler)
clearInterval(that.recoverEnergyHandler);
that.recoverEnergyTime = Ins_1.Ins.recoverEnergy;
that.recoverEnergyHandler = setInterval(function () { that.recoverEnergyHandler = setInterval(function () {
TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.recoverEnergy, {}, function (s, r) { TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.recoverEnergy, {}, function (s, r) {
if (s) { if (s) {
console.log("恢复精力时间2:", new Date().getMinutes());
that.getUserEnergy(); that.getUserEnergy();
} }
else { else {
...@@ -47074,10 +47103,14 @@ var MainScene = (function (_super) { ...@@ -47074,10 +47103,14 @@ var MainScene = (function (_super) {
}); });
}, Ins_1.Ins.recoverEnergy); }, Ins_1.Ins.recoverEnergy);
}; };
MainScene.prototype.showPageEnergyUp = function () {
};
MainScene.prototype.getUserEnergy = function () { MainScene.prototype.getUserEnergy = function () {
var that = this; var that = this;
TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.getUserEnergy, {}, function (s, r) { TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.getUserEnergy, {}, function (s, r) {
if (s) { if (s) {
that.recoverEnergyTime = Ins_1.Ins.recoverEnergy;
console.log("设置恢复时间", that.recoverEnergyTime);
if (r.data != Ins_1.Ins.userInfo.energy) { if (r.data != Ins_1.Ins.userInfo.energy) {
Ins_1.Ins.userInfo.energy = r.data; Ins_1.Ins.userInfo.energy = r.data;
that.setEnergy(); that.setEnergy();
...@@ -47085,7 +47118,9 @@ var MainScene = (function (_super) { ...@@ -47085,7 +47118,9 @@ var MainScene = (function (_super) {
} }
else { else {
if (r.data != Ins_1.Ins.userInfo.energyMax) { if (r.data != Ins_1.Ins.userInfo.energyMax) {
that.getUserEnergy(); setTimeout(function () {
that.getUserEnergy();
}, 500);
} }
else { else {
return; return;
...@@ -47152,6 +47187,10 @@ var MainScene = (function (_super) { ...@@ -47152,6 +47187,10 @@ var MainScene = (function (_super) {
TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.getUserInfo, {}, function (s, r) { TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.getUserInfo, {}, function (s, r) {
if (s) { if (s) {
Ins_1.Ins.userInfo = r.data; Ins_1.Ins.userInfo = r.data;
if (that.isShow) {
that.isShow = false;
that.energyUp1();
}
that.setEnergy(); that.setEnergy();
that.mainUi.updateUserInfo(); that.mainUi.updateUserInfo();
} }
...@@ -47195,6 +47234,14 @@ var MainScene = (function (_super) { ...@@ -47195,6 +47234,14 @@ var MainScene = (function (_super) {
} }
}); });
}; };
MainScene.prototype.onShow = function () {
console.log("canvas页面显示,isShow设置为true");
this.isShow = true;
};
MainScene.prototype.onHide = function () {
console.log("canvas页面显示, isShow设置为false");
this.isShow = false;
};
MainScene.prototype.initEvents = function () { MainScene.prototype.initEvents = function () {
var that = this; var that = this;
console.log("主场景添加事件"); console.log("主场景添加事件");
...@@ -47204,6 +47251,8 @@ var MainScene = (function (_super) { ...@@ -47204,6 +47251,8 @@ var MainScene = (function (_super) {
FYGE.GDispatcher.addEventListener(Enum_1.MSG.CHANGE_SCENE, function () { that.changeMainScene(Enum_1.SCENETYPE.BEADROOM); }, that); FYGE.GDispatcher.addEventListener(Enum_1.MSG.CHANGE_SCENE, function () { that.changeMainScene(Enum_1.SCENETYPE.BEADROOM); }, that);
Main_1.GDispatcher.addEventListener(Enum_1.MSG.UPDATE_USERINFO, that.updateUserInfo, that); Main_1.GDispatcher.addEventListener(Enum_1.MSG.UPDATE_USERINFO, that.updateUserInfo, that);
Main_1.GDispatcher.addEventListener(Enum_1.MSG.RECALL_CAT, that.recallCat, that); Main_1.GDispatcher.addEventListener(Enum_1.MSG.RECALL_CAT, that.recallCat, that);
Main_1.GDispatcher.addEventListener("onShow", that.onShow, that);
Main_1.GDispatcher.addEventListener("onHide", that.onHide, that);
}; };
MainScene.prototype.removeEvents = function () { MainScene.prototype.removeEvents = function () {
var that = this; var that = this;
...@@ -47215,6 +47264,8 @@ var MainScene = (function (_super) { ...@@ -47215,6 +47264,8 @@ var MainScene = (function (_super) {
FYGE.GDispatcher.removeEventListener(Enum_1.MSG.CHANGE_SCENE, function () { that.changeMainScene(Enum_1.SCENETYPE.BEADROOM); }, that); FYGE.GDispatcher.removeEventListener(Enum_1.MSG.CHANGE_SCENE, function () { that.changeMainScene(Enum_1.SCENETYPE.BEADROOM); }, that);
Main_1.GDispatcher.removeEventListener(Enum_1.MSG.UPDATE_USERINFO, that.updateUserInfo, that); Main_1.GDispatcher.removeEventListener(Enum_1.MSG.UPDATE_USERINFO, that.updateUserInfo, that);
Main_1.GDispatcher.removeEventListener(Enum_1.MSG.RECALL_CAT, that.recallCat, that); Main_1.GDispatcher.removeEventListener(Enum_1.MSG.RECALL_CAT, that.recallCat, that);
Main_1.GDispatcher.addEventListener("onShow", that.onShow, that);
Main_1.GDispatcher.addEventListener("onHide", that.onHide, that);
}; };
return MainScene; return MainScene;
}(Scene_1.Scene)); }(Scene_1.Scene));
...@@ -47288,6 +47339,7 @@ var StartScene = (function (_super) { ...@@ -47288,6 +47339,7 @@ var StartScene = (function (_super) {
}; };
StartScene.prototype.getCat = function (r) { StartScene.prototype.getCat = function (r) {
console.log("选择完猫咪", r); console.log("选择完猫咪", r);
Ins_1.Ins.showLoading();
Ins_1.Ins.userInfo = r.data.data; Ins_1.Ins.userInfo = r.data.data;
this.judgeCatIsOutAChangeMainScene(); this.judgeCatIsOutAChangeMainScene();
}; };
...@@ -47306,6 +47358,7 @@ var StartScene = (function (_super) { ...@@ -47306,6 +47358,7 @@ var StartScene = (function (_super) {
ctrls_1.changeScene(MainScene_1.MainScene); ctrls_1.changeScene(MainScene_1.MainScene);
} }
else { else {
Ins_1.Ins.hideLoading();
Ins_1.Ins.showToast(r.message); Ins_1.Ins.showToast(r.message);
} }
}); });
...@@ -95,7 +95,7 @@ Page({ ...@@ -95,7 +95,7 @@ Page({
console.log('on ready') console.log('on ready')
//授权和登录先搞 //授权和登录先搞
// await this.getAuth(); await this.getAuth();
// this.initCanvas(); // this.initCanvas();
my.__onMessage__ = (e) => { my.__onMessage__ = (e) => {
this.onMessage(e) this.onMessage(e)
...@@ -188,6 +188,9 @@ Page({ ...@@ -188,6 +188,9 @@ Page({
onCanvasReady(query) { onCanvasReady(query) {
console.log('onCanvasReady', query) console.log('onCanvasReady', query)
setInterval(()=>{
console.log("测试测试测试")
},2000)
//授权和登录先搞 //授权和登录先搞
checkSystem().then(r => { checkSystem().then(r => {
if (r) { if (r) {
...@@ -298,9 +301,10 @@ Page({ ...@@ -298,9 +301,10 @@ Page({
onShow() { onShow() {
// 页面显示 // 页面显示
if (this.main) { if (this.main) {
console.log("界面显示")
this.main.run(); this.main.run();
this.main.dispatchGlobalEvent("onShow"); this.main.dispatchGlobalEvent("onShow");
my.__updateUserInfo__(); this.showPageLogin();
} }
}, },
...@@ -309,6 +313,7 @@ Page({ ...@@ -309,6 +313,7 @@ Page({
if (this.main) { if (this.main) {
this.main.pause(); this.main.pause();
this.main.dispatchGlobalEvent("onHide"); this.main.dispatchGlobalEvent("onHide");
console.log("主页面隐藏")
} }
}, },
...@@ -376,6 +381,27 @@ Page({ ...@@ -376,6 +381,27 @@ Page({
this.initCanvas(); this.initCanvas();
} }
}, },
/**页面显示登录 */
async showPageLogin() {
const {
nickName,
avatar
} = app;
const {
success,
data,
} = await API.login({
userNick: nickName,
avatar
}).catch(res => {
commonToast(res && res.message);
}) || {};
if (success) {
app.openId = data.openId;
my.__updateUserInfo__();
}
},
/**刷新用户信息 */ /**刷新用户信息 */
updateUserInfo() { updateUserInfo() {
console.log("通知canvas刷新用户信息") console.log("通知canvas刷新用户信息")
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment