Commit 7bd85035 authored by Edwise's avatar Edwise 🍷

1234

parent 6cc8e134
{
"success": true,
"message":"",
"data": {
"sence": 1,
"senceTips":["测试","测试"],
"senceGuide":{
"1":false,
"2":true,
"3":false,
"4":true
}
}
}
\ No newline at end of file
......@@ -2,14 +2,14 @@
"success": true,
"message":"",
"data": {
"catType": 3,
"catType": 4,
"userNick": "Edwise",
"energy": 1000,
"happyCoin":1000,
"experience": 80,
"level": "1",
"avatar": "http://wwc.alicdn.com/avatar/getAvatar.do?userIdStr=vFHbMm8SPFPHPFRHPG7HPmPhvmgyPGPIP07-OF*eMmQT&width=80&height=80&type=sns",
"sence": 2,
"sence": 1,
"catName": "哈哈哈",
"senceTips":["1说话说话说话说话说话说话说话说话说话说话说话","2说话说话说话说话说话说话说话说话说话说话说话说话","3说话说话说话说话说话说话说话说话说话说话说话说话"],
"energyMax":2000,
......
{
"success": true,
"data": null,
"code": "culpa eu Ut"
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -694,25 +694,25 @@ const resCanvasList = {
name: 'classRoomGuide1',
ext: '.png',
uuid: '5ae12c38-05d8-4105-9101-765e7f32525e',
url: '//yun.duiba.com.cn/spark/assets/02ca473f5f7828e4801c6de8d6c81cf459d4a366.png'
url: 'https://yun.duiba.com.cn/spark/assets/02ca473f5f7828e4801c6de8d6c81cf459d4a366.png'
},
'e8ad2e4e-925c-4db5-b229-882ee98881a7': {
name: 'classRoomGuide2',
ext: '.png',
uuid: 'e8ad2e4e-925c-4db5-b229-882ee98881a7',
url: '//yun.duiba.com.cn/spark/assets/c00974abebadf768413be923f88e4cec0836b275.png'
url: 'https://yun.duiba.com.cn/spark/assets/c00974abebadf768413be923f88e4cec0836b275.png'
},
'c549f0a7-085e-444d-b839-4f2172094b0b': {
name: 'classRoomGuide3',
ext: '.png',
uuid: 'c549f0a7-085e-444d-b839-4f2172094b0b',
url: '//yun.duiba.com.cn/spark/assets/d1696c00719725364450dd178fc7da4b6d9446de.png'
url: 'https://yun.duiba.com.cn/spark/assets/d1696c00719725364450dd178fc7da4b6d9446de.png'
},
'3f48a757-495b-4ed7-957c-9ec95f82ea5e': {
name: 'classRoomGuide4',
ext: '.png',
uuid: '3f48a757-495b-4ed7-957c-9ec95f82ea5e',
url: '//yun.duiba.com.cn/spark/assets/383ce57472efe68f0f16079f122b6cff5ec71995.png'
url: 'https://yun.duiba.com.cn/spark/assets/383ce57472efe68f0f16079f122b6cff5ec71995.png'
},
......@@ -720,56 +720,56 @@ const resCanvasList = {
'd37358ea-ba10-4c08-ab3c-7ff682629ada': {
name: 'playGroundGuide1',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/playGroundGuide1.9ca482960425bac644131a9ae90a45b700ea7642.png',
url: 'https://yun.duiba.com.cn/spark/assets/playGroundGuide1.9ca482960425bac644131a9ae90a45b700ea7642.png',
uuid: 'd37358ea-ba10-4c08-ab3c-7ff682629ada'
},
'f44dd5ee-2fa3-4a47-b398-527b0398544b': {
name: 'playgroundGuide2',
ext: '.png',
uuid: 'f44dd5ee-2fa3-4a47-b398-527b0398544b',
url: '//yun.duiba.com.cn/spark/assets/90b5cff8c620e9b2a81da22ab1cdc130a78da592.png'
url: 'https://yun.duiba.com.cn/spark/assets/90b5cff8c620e9b2a81da22ab1cdc130a78da592.png'
},
'6583475b-201e-4324-b15e-4632f33f57ec': {
name: 'playgroundGuide3',
ext: '.png',
uuid: '6583475b-201e-4324-b15e-4632f33f57ec',
url: '//yun.duiba.com.cn/spark/assets/bb6780d281325d2753204eded63f5c1f9824dc38.png'
url: 'https://yun.duiba.com.cn/spark/assets/bb6780d281325d2753204eded63f5c1f9824dc38.png'
},
'a90aa98b-2ff1-41a2-8a71-749bb76d6ba3': {
name: 'playgroundGuide4',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/playgroundGuide4.a20dd536f9ebe4a7884fd577434d129a49d790df.png',
url: 'https://yun.duiba.com.cn/spark/assets/playgroundGuide4.a20dd536f9ebe4a7884fd577434d129a49d790df.png',
uuid: 'a90aa98b-2ff1-41a2-8a71-749bb76d6ba3'
},
'5996c68c-2626-4a97-a36a-8d5af6b777c0': {
name: 'touchImg',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/touchImg.bababfd52ef6f99d5599d5dd09fd71a994e141d3.png',
url: 'https://yun.duiba.com.cn/spark/assets/touchImg.bababfd52ef6f99d5599d5dd09fd71a994e141d3.png',
uuid: '5996c68c-2626-4a97-a36a-8d5af6b777c0'
},
'90b114e6-83cb-46f1-b607-f88c50077b05': {
name: 'bluCat',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/bluCat.57cf00351ffde1985720a877d2e1384390970cd6.png',
url: 'https://yun.duiba.com.cn/spark/assets/bluCat.57cf00351ffde1985720a877d2e1384390970cd6.png',
uuid: '90b114e6-83cb-46f1-b607-f88c50077b05'
},
'4e471df6-01ab-421d-ba0b-084b2110dc6d': {
name: 'orengeCat',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/orengeCat.c664a89d9d7f63895c5460144098a5bac5fc31f5.png',
url: 'https://yun.duiba.com.cn/spark/assets/orengeCat.c664a89d9d7f63895c5460144098a5bac5fc31f5.png',
uuid: '4e471df6-01ab-421d-ba0b-084b2110dc6d'
},
'003e9904-aee4-4b8d-8d5d-fb4b1188bec1': {
name: 'sanhuaCat',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/sanhuaCat.b58ed1a3960ecd123ff0b0ff38b9cb8ad44c1b4d.png',
url: 'https://yun.duiba.com.cn/spark/assets/sanhuaCat.b58ed1a3960ecd123ff0b0ff38b9cb8ad44c1b4d.png',
uuid: '003e9904-aee4-4b8d-8d5d-fb4b1188bec1'
},
'90283bd3-4b18-4535-97a8-90318f068781': {
name: 'xianluoCat',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/xianluoCat.c28961a75753d2d6ffe788a3ae38e7f3c3937344.png',
url: 'https://yun.duiba.com.cn/spark/assets/xianluoCat.c28961a75753d2d6ffe788a3ae38e7f3c3937344.png',
uuid: '90283bd3-4b18-4535-97a8-90318f068781'
},
......@@ -778,43 +778,44 @@ const resCanvasList = {
name: 'bedRoomGuide1',
ext: '.png',
uuid: 'd4740497-ed95-4e35-b107-df545896cf05',
url: '//yun.duiba.com.cn/spark/assets/b81c5e7ec197bbcc310ec84dc425d1419238c470.png'
url: 'https://yun.duiba.com.cn/spark/assets/b81c5e7ec197bbcc310ec84dc425d1419238c470.png'
},
'ba92a69d-fc74-482a-8839-6b483d2290b8': {
name: 'bedRoomGuide2',
ext: '.png',
uuid: 'ba92a69d-fc74-482a-8839-6b483d2290b8',
url: '//yun.duiba.com.cn/spark/assets/fa384c300572a403ce99bf7cfe506fe5d95ff9e2.png'
url: 'https://yun.duiba.com.cn/spark/assets/fa384c300572a403ce99bf7cfe506fe5d95ff9e2.png'
},
'ff460e08-76fd-4888-8361-2b65b7ee95ea': {
name: 'bedRoomGuide3',
ext: '.png',
uuid: 'ff460e08-76fd-4888-8361-2b65b7ee95ea',
url: '//yun.duiba.com.cn/spark/assets/dfaa85ae186e20803592e30f535af8c5a527f745.png'
url: 'https://yun.duiba.com.cn/spark/assets/dfaa85ae186e20803592e30f535af8c5a527f745.png'
},
'f1154565-9a56-4d95-83de-44832d700b5f': {
name: 'bedRoomGuide4',
ext: '.png',
uuid: 'f1154565-9a56-4d95-83de-44832d700b5f',
url: '//yun.duiba.com.cn/spark/assets/fd6a0511d7feee32869253d7b380ca6870ef1492.png'
url: 'https://yun.duiba.com.cn/spark/assets/fd6a0511d7feee32869253d7b380ca6870ef1492.png'
},
'6ab7cbb8-6c9d-412f-9d57-8404465d9e35': {
name: 'bedRoomGuide5',
ext: '.png',
uuid: '6ab7cbb8-6c9d-412f-9d57-8404465d9e35',
url: '//yun.duiba.com.cn/spark/assets/19abee4b0b5e64dcfc219d69ded2bf89ed19847c.png'
url: 'https://yun.duiba.com.cn/spark/assets/19abee4b0b5e64dcfc219d69ded2bf89ed19847c.png'
},
'df6ccefe-756c-4383-aac3-7da9f74b3a0f': {
name: 'bedRoomGuide6',
ext: '.png',
uuid: 'df6ccefe-756c-4383-aac3-7da9f74b3a0f',
url: '//yun.duiba.com.cn/spark/assets/b6800bb9c52624fe34ae6065333733fe691db8a9.png'
url: 'https://yun.duiba.com.cn/spark/assets/b6800bb9c52624fe34ae6065333733fe691db8a9.png'
},
'1a4f7c9e-0857-425a-8abe-3dd5c79b2528': {
name: 'bedRoomGuide7',
ext: '.png',
uuid: '1a4f7c9e-0857-425a-8abe-3dd5c79b2528',
url: '//yun.duiba.com.cn/spark/assets/e2822fc4c01310e66f2276f9b03d56519b122e1e.png'
}
url: 'https://yun.duiba.com.cn/spark/assets/e2822fc4c01310e66f2276f9b03d56519b122e1e.png'
},
};
export default resCanvasList;
......@@ -6,8 +6,8 @@ var fs = require("fs");
// fs.readFileSync("./output.js")
// )
// 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 version = Math.round(new Date().getTime() / 1000);
// fs.writeFileSync(endPath + "output." + version + ".js", fs.readFileSync("./released/output.js"));
......
/**当前场景对应的类型 */
export enum SCENETYPE{
export enum SCENETYPE {
/**教室 */
CLASSROOM=1,
CLASSROOM = 1,
/**操场 */
PLAYGROUND,
/**寝室 */
......@@ -9,13 +9,13 @@ export enum SCENETYPE{
}
/**自定义事件 */
export enum MSG{
export enum MSG {
/**改变场景,参数为uiType */
CHANGE_SCENE="CHANGE_SCENE",
CHANGE_SCENE = "CHANGE_SCENE",
/**选择猫咪 */
SELECT_CAT="SELECT_CAT",
SELECT_CAT = "SELECT_CAT",
/**猫咪互动 */
CAT_ACT="CAT_ACT",
CAT_ACT = "CAT_ACT",
/**刷新用户领养信息 */
UPDATE_USERINFO = "UPDATE_USERINFO",
/**结束寝室引导 */
......@@ -23,11 +23,13 @@ export enum MSG{
/**结束教室引导 */
GUIDE_CLASSROOMEND = "GUIDE_CLASSROOMEND",
/**结束操场引导 */
GUIDE_PLAYGROUNDEND = "GUIDE_PLAYGROUNDEND"
GUIDE_PLAYGROUNDEND = "GUIDE_PLAYGROUNDEND",
/**找回猫咪 */
RECALL_CAT = "RECALL_CAT"
}
/**猫咪类型 */
export enum CATTYPE{
export enum CATTYPE {
/**蓝猫 */
BLUE,
/**橙猫 */
......@@ -39,7 +41,7 @@ export enum CATTYPE{
}
/**猫咪互动动作 */
export enum CAT_ACTTYPEP{
export enum CAT_ACTTYPEP {
/**睡觉 */
SLEEP,
/**说话 */
......
......@@ -36,6 +36,12 @@ export class Ins {
}
public static senceInfo: {
"sence":number,
"senceTips":string[],
"senceGuide":{}
}
public static showModule(name:string,data?){
sendTbNet(TbNetName.showModal, { name: name, data: data?data:{} }, (s, res) => {
console.log('showModal ruleModal, success,res', s, res)
......
......@@ -10,5 +10,5 @@ export const ResJson = {
"name": "startScene"
}
],
"path": "https://yun.duiba.com.cn/db_games/activity/babycare_xiaoxiao/1601014736/resource/"
"path": "https://yun.duiba.com.cn/db_games/activity/babycare_xiaoxiao/1601176297/resource/"
}
\ No newline at end of file
......@@ -27,6 +27,16 @@ export enum TbNetName {
*/
getUserEnergy = "tmallCat.getUserEnergy",
/**
* 获取场景
*/
getSence = "tmallCat.getSence",
/**
* 完成上报场景引导
*/
updateSenceGuide = "tmallCat.updateSenceGuide",
/**
* 埋点统计 到时改名字
* activityId params elemType
......
......@@ -51,12 +51,13 @@ export class Cat extends Module {
dialogPos:any[]=[{x:1,y:1}]; //猫咪对话框气泡位置
initUi() {
this.initEvents();
this.initCatLottieArr();
console.log(this.catLottieArr);
this.initCat();
this.initDialog();
this.catTalk();
this.initEvents();
}
/**初始化猫咪Lottie数据组 */
......@@ -146,7 +147,7 @@ export class Cat extends Module {
/**在每天进入场景或是在引导后,猫咪说话 */
catTalk(){
var tipsArr = Ins.userInfo.senceTips;
var tipsArr = Ins.senceInfo.senceTips;
var index = Math.floor(Math.random()*tipsArr.length)
this.showDialog(1,tipsArr[index]);
this.setCatAnimShow(1,()=>{this.stopCatAct()});
......@@ -201,6 +202,8 @@ export class Cat extends Module {
/**猫咪互动 */
catAct(e) {
console.log("eruighuerihgrueeigh")
console.log("当前猫咪是否在互动",this.actRunning);
if (this.actRunning) return;
var that = this;
let actType = e.data;
......@@ -242,10 +245,12 @@ export class Cat extends Module {
}
initEvents() {
console.log("猫咪添加互动事件")
FYGE.GDispatcher.addEventListener(MSG.CAT_ACT, this.catAct, this);
}
removeEvents() {
console.log("猫咪移除互动事件")
FYGE.GDispatcher.removeEventListener(MSG.CAT_ACT, this.catAct, this);
}
}
\ No newline at end of file
......@@ -39,7 +39,7 @@ export class Guide extends Module {
var that = this;
that.index = 0;
that.catPosArr = [80, 80, 80, 70];
that.catPosArr = [80, 40, 60, 70];
/**猫咪图片 */
......@@ -52,12 +52,15 @@ export class Guide extends Module {
that.guideUUIDArr_3 = ['d4740497-ed95-4e35-b107-df545896cf05', 'ba92a69d-fc74-482a-8839-6b483d2290b8', 'ff460e08-76fd-4888-8361-2b65b7ee95ea',
'f1154565-9a56-4d95-83de-44832d700b5f', '6ab7cbb8-6c9d-412f-9d57-8404465d9e35', 'df6ccefe-756c-4383-aac3-7da9f74b3a0f', '1a4f7c9e-0857-425a-8abe-3dd5c79b2528'];
that.guide = new FYGE.Sprite(Ins.getRes(that['guideUUIDArr_' + Ins.userInfo.sence][0]));
that.guide = new FYGE.Sprite(Ins.getRes(that['guideUUIDArr_' + that.guideType][0]));
that.addChild(that.guide);
that.catImg = new FYGE.Sprite(Ins.getRes(that.catImgUUIDArr[Ins.userInfo.catType - 1]))
that.addChild(that.catImg);
that.catImg.position.set(128, (Ins.stageH * 0.5 + that.catPosArr[Ins.userInfo.catType - 1]));
var x = (Ins.stageW - that.catImg.width) * 0.5;
var y = (Ins.stageH * 0.5)
that.catImg.position.set(x , y);
console.log("引导猫的位置",x,y)
that.guideTouch = new FYGE.Sprite(RES.getRes(resCanvasList["5996c68c-2626-4a97-a36a-8d5af6b777c0"].url));
that.addChild(that.guideTouch);
......@@ -68,13 +71,13 @@ export class Guide extends Module {
changeGuide() {
this.index++;
if (this.index >= this['guideUUIDArr_' + Ins.userInfo.sence].length) {
if (this.index >= this['guideUUIDArr_' + this.guideType].length) {
// GDispatcher.dispatchEvent(MSG.GUIDE_BEDROOMEND);
this.callBack && this.callBack();
return;
}
this.guide.texture = RES.getRes(resCanvasList[this['guideUUIDArr_' + Ins.userInfo.sence][this.index]].url)
if (Ins.userInfo.sence == 3 || Ins.userInfo.sence == 4) {
this.guide.texture = RES.getRes(resCanvasList[this['guideUUIDArr_' + this.guideType][this.index]].url)
if (this.guideType == 3 || this.guideType == 4) {
if (this.index == 4 || this.index == 5) {
this.catImg.visible = false;
} else {
......
......@@ -44,7 +44,7 @@ export class MainScene extends Scene {
private level: number = 0;
/**场景引导 */
private Guide:Guide;
private Guide: Guide;
initUi() {
var that = this;
......@@ -54,18 +54,20 @@ export class MainScene extends Scene {
/**初始化场景元素 */
initSceneEle() {
var that = this;
that.x = (Ins.stageW - 750) >> 1;
that.y = (Ins.stageH - 1624) >> 1;
console.log(that.y);
that.mouseChildren = true;
Ins.curScene = Ins.userInfo.sence;
Ins.curScene = Ins.senceInfo.sence;
//0:教室,1:操场,2:寝室
that.bgUUID = ["c6d699b0-b276-4985-b3ea-47bcef13f2ea", "efaf990e-5392-49ad-94d8-25c04f651ede", "b3c8c187-e5c9-4968-9a00-a118d18ab2fc"];
//生成默认场景,后面要改成根据接口值判断
that.sceneBg = Ins.initSprite(that.bgUUID[Ins.curScene == 4 ? 2 : Ins.curScene - 1]);
that.addChild(that.sceneBg);
that.x = (Ins.stageW - that.sceneBg.width) >> 1;
that.y = (Ins.stageH - that.sceneBg.height) >> 1;
that.mainUi = new MainSceneBtnUi({ uiType: Ins.curScene == 4 ? 3 : Ins.curScene, callF: () => { that.initGuide(Ins.curScene > 3 ? 3 : Ins.curScene) } });
that.addChild(that.mainUi);
that.tlBtn = Ins.initSprite("1f8b040d-2fbc-4ff8-92f9-159773364fae", 0, 640);
that.tlBtn.alpha = 0.1;
......@@ -87,13 +89,10 @@ export class MainScene extends Scene {
that.mxqBtn.visible = false;
}
that.mainUi = new MainSceneBtnUi({ uiType: Ins.curScene == 4 ? 3 : Ins.curScene });
that.addChild(that.mainUi);
that.initCat();
that.initEnergy();
that.energyUp();
that.initGuide();
// that.initGuide(Ins.curScene > 3 ? 3 : Ins.curScene);
}
/**初始化猫咪 */
......@@ -113,19 +112,42 @@ export class MainScene extends Scene {
}
/**初始化引导 */
initGuide(){
initGuide(sence) {
var that = this;
if(Ins.userInfo.senceGuide){
this.cat.visible = false;
this.Guide = new Guide({type:Ins.userInfo.sence,callBack:()=>{that.removeChild(that.Guide);that.senceGuideEnd()}});
this.addChild(this.Guide);
if (!Ins.senceInfo.senceGuide['' + sence]) {
that.cat.visible = false;
that.Guide = new Guide({ type: sence, callBack: () => { that.senceGuideEnd(sence); } });
that.addChildAt(this.Guide,999);
}
// setTimeout(()=>{
console.log("引导", sence)
that.mainUi.changeBtnByUiType(sence, true)
// },100)
}
/**场景引导结束 */
senceGuideEnd(){
this.cat.visible = true;
this.cat.catTalk();
senceGuideEnd(sence) {
var that = this;
that.updateUserInfo();
Ins.showLoading();
sendTbNet(TbNetName.updateSenceGuide, {sence:sence}, (s, r) => {
if (s) {
Ins.hideLoading();
var userSence = Ins.senceInfo.sence > 4 ? 3 : Ins.senceInfo.sence;
Ins.senceInfo.senceGuide[''+sence] = true
if (sence == userSence) {
that.cat.visible = true;
that.cat.catTalk();
}
that.mainUi.changeBtnByUiType(sence)
that.removeChild(that.Guide);
} else {
Ins.hideLoading();
Ins.showToast(r.message);
}
})
}
/**打开信封 */
......@@ -188,10 +210,10 @@ export class MainScene extends Scene {
energyUp() {
var that = this;
that.recoverEnergyHandler = setInterval(() => {
sendTbNet(TbNetName.recoverEnergy,{},(s,r)=>{
if(s){
sendTbNet(TbNetName.recoverEnergy, {}, (s, r) => {
if (s) {
that.getUserEnergy();
}else{
} else {
Ins.showToast(r.message);
}
});
......@@ -199,23 +221,23 @@ export class MainScene extends Scene {
}
/**时间到的时候拿取精力值 */
getUserEnergy(){
getUserEnergy() {
var that = this;
sendTbNet(TbNetName.getUserEnergy,{},(s,r)=>{
if(s){
if(r.data!=Ins.userInfo.energy){
sendTbNet(TbNetName.getUserEnergy, {}, (s, r) => {
if (s) {
if (r.data != Ins.userInfo.energy) {
Ins.userInfo.energy = r.data;
that.setEnergy();
return;
}else{
if(r.data!=Ins.userInfo.energyMax){
} else {
if (r.data != Ins.userInfo.energyMax) {
that.getUserEnergy();
}
else{
else {
return;
}
}
}else{
} else {
Ins.showToast(r.message);
}
})
......@@ -227,13 +249,15 @@ export class MainScene extends Scene {
var that = this;
Ins.curScene = type > 3 ? 3 : type;
that.sceneBg.texture = RES.getRes(resCanvasList[that.bgUUID[type - 1]].url)
that.initGuide(Ins.curScene);
//切换场景时判断猫在不在,后面要改成与接口值判断
if (Ins.catIsOut) {
that.cat.visible = false;
that.cat.stopCatAct();
} else {
if ((type) == Ins.userInfo.sence) {
if ((type) == Ins.senceInfo.sence) {
that.cat.visible = true;
that.cat.stopCatAct();
} else {
that.cat.visible = false;
that.cat.stopCatAct();
......@@ -259,9 +283,14 @@ export class MainScene extends Scene {
}
break;
}
if (!Ins.senceInfo.senceGuide['' + Ins.curScene]) {
that.mainUi.changeBtnByUiType(type, true);
} else {
that.mainUi.changeBtnByUiType(type);
}
}
/**更新用户信息时更新场景信息 */
updateSceneInfo() {
......@@ -274,22 +303,6 @@ export class MainScene extends Scene {
sendTbNet(TbNetName.getUserInfo, {}, (s, r) => {
if (s) {
Ins.userInfo = r.data;
// if (r.data.sence > 3) {
// Ins.catIsOut = true;
// that.cat.visible = false;
// that.cat.stopCatAct();
// that.mainUi.changeBtnByCatIsOuT(Ins.curScene)
// if (Ins.curScene == 3) {
// that.letter.visible = true;
// }
// } else {
// if (Ins.catIsOut) {
// that.cat.visible = true;
// that.letter.visible = false;
// }
// Ins.catIsOut = false;
// }
that.setEnergy();
that.mainUi.updateUserInfo();
......@@ -299,6 +312,39 @@ export class MainScene extends Scene {
})
}
/**召回猫咪 */
recallCat() {
console.log("找回猫咪,刷新用户信息,刷新出勤状态")
var that = this;
sendTbNet(TbNetName.getUserInfo, {}, (s, r) => {
if (s) {
Ins.userInfo = r.data;
that.setEnergy();
that.mainUi.updateUserInfo();
if (Ins.catIsOut) {
sendTbNet(TbNetName.getSence, {}, (s, r) => {
if (s) {
Ins.senceInfo = r.data;
if (r.data.sence < 4) {
Ins.catIsOut = false;
that.letter.visible = false;
if (r.data.sence == 3) {
that.cat.visible = true;
that.cat.stopCatAct();
}
that.mainUi.changeBtnByUiType(Ins.curScene > 3 ? 3 : Ins.curScene);
}
} else {
Ins.showToast(r.message);
}
})
}
} else {
Ins.showToast(r.message)
}
})
}
initEvents() {
var that = this;
......@@ -308,6 +354,7 @@ export class MainScene extends Scene {
that.letter && that.letter.addEventListener(FYGE.MouseEvent.CLICK, that.openLetter, that);
FYGE.GDispatcher.addEventListener(MSG.CHANGE_SCENE, () => { that.changeMainScene(SCENETYPE.BEADROOM) }, that);
GDispatcher.addEventListener(MSG.UPDATE_USERINFO, that.updateUserInfo, that);
GDispatcher.addEventListener(MSG.RECALL_CAT, that.recallCat, that);
}
removeEvents() {
......@@ -319,5 +366,6 @@ export class MainScene extends Scene {
that.letter && that.letter.removeEventListener(FYGE.MouseEvent.CLICK, that.openLetter, that);
FYGE.GDispatcher.removeEventListener(MSG.CHANGE_SCENE, () => { that.changeMainScene(SCENETYPE.BEADROOM) }, that);
GDispatcher.removeEventListener(MSG.UPDATE_USERINFO, that.updateUserInfo, that);
GDispatcher.removeEventListener(MSG.RECALL_CAT, that.recallCat, that);
}
}
\ No newline at end of file
......@@ -12,29 +12,26 @@ import { GDispatcher } from "../Main";
export class StartScene extends Scene {
initUi() {
super.initUi();
var that = this;
var sceneBg = Ins.initSprite("b3c8c187-e5c9-4968-9a00-a118d18ab2fc");
this.addChild(sceneBg);
that.addChild(sceneBg);
sceneBg.visible = false;
this.x = (Ins.stageW - 750) >> 1;
this.y = (Ins.stageH - 1624) >> 1;
that.x = (Ins.stageW - 750) >> 1;
that.y = (Ins.stageH - 1624) >> 1;
Ins.showLoading();
sendTbNet(TbNetName.getUserInfo, {}, (s, r) => {
if (s) {
if (r.data) {
Ins.userInfo = r.data;
/**判断猫咪是否出寝,只在用户进入游戏时判断,后面要根据接口改写,现在先做测试 */
if (r.data.sence == 4) {
Ins.catIsOut = true;
} else {
Ins.catIsOut = false;
}
changeScene(MainScene)
that.judgeCatIsOutAChangeMainScene();
} else {
sceneBg.visible = true;
Ins.showModule("selectcatModal")
}
} else {
sceneBg.visible = true;
Ins.hideLoading();
Ins.showToast(r.message)
}
})
......@@ -48,12 +45,26 @@ export class StartScene extends Scene {
console.log("选择完猫咪",r)
Ins.userInfo = r.data;
/**判断猫咪是否出寝,只在用户进入游戏时判断,后面要根据接口改写,现在先做测试 */
this.judgeCatIsOutAChangeMainScene();
}
/**判断猫咪是否出寝,并且改变到主场景 */
judgeCatIsOutAChangeMainScene(){
console.log("aaa")
sendTbNet(TbNetName.getSence,{},(s,r)=>{
if(s){
Ins.senceInfo = r.data;
if (r.data.sence == 4) {
Ins.catIsOut = true;
} else {
Ins.catIsOut = false;
}
Ins.hideLoading();
changeScene(MainScene)
}else{
Ins.showToast(r.message);
}
})
}
initEvents(){
......
......@@ -9,7 +9,7 @@ cloud.init({
App({
env,
requestType: 'cloud', // yapi,cloud: 云函数
requestType: 'local', // yapi,cloud: 云函数
// requestType: 'local', // yapi,cloud: 云函数
cloudName: 'tmallCat', // 主云函数项目名 tmallCat
// cloudName: 'bubbleSurviva', // 主云函数项目名 tmallCat
cloud,
......
......@@ -3,7 +3,7 @@
<image class="catbackbedbgaccident" a:if="{{backType==2}}" src={{resList['98a3f684-846b-479c-91ac-75b588e2b51b'].url}} />
<image class="catbackbedbgsurprise" a:if="{{backType==1}}" src={{resList['98a3f684-846b-479c-91ac-75b588e2b51b'].url}} />
<image class="catbackbedbgunluck" a:if="{{backType==3}}" src={{resList['3fa827d6-e333-4b56-a5d9-5f3ae2089127'].url}} />
<image class="catbackbedok" onTap="onModalClose" src={{resList['b701826c-63c5-4490-a380-52f273dad9af'].url}} />
<image class="catbackbedok" onTap="onModalClose" src="{{okBtnImg}}" />
<label class="catbackbedtip2"><text>{{getTypeText}}</text> <text style="color:{{getColor}}">{{getText}}</text> </label>
<label class="catbackbedtip">
{{desc}}
......
......@@ -17,6 +17,8 @@ Component({
"61869bae-f55f-46e3-be58-23ed6485b18e", "cfc54c6d-4233-478a-ae00-ef42d58718c1"
],
},
//收下按钮,0是倒霉的按钮,1是惊喜与意外的按钮
okBtnImgArr: ["c8c50400-1d65-4971-8be5-e4fb2eecfcd5","b701826c-63c5-4490-a380-52f273dad9af"],
//从召回猫接口中拿到的信息
recallCatInfo: null,
mydata: null, //mydata.catType 猫的类型
......@@ -31,23 +33,26 @@ Component({
getText: '+100欢乐币', //获取或减少收益文本
getColor: 'red', //获取或减少收益文本颜色
getTypeText: '获得', //获取或减少收益类型文本
okBtnImg: '' //收下按钮
},
methods: {
onModalClose() {
const {
onModalClose,onUpdateUserInfo
onModalClose
} = this.props;
onModalClose && onModalClose();
onUpdateUserInfo&&onUpdateUserInfo();
my.__updateUserInfo__();
// onUpdateUserInfo&&onUpdateUserInfo();
},
},
didMount() {
console.log(this.props.catImgArr,this.props.recallCatInfo)
const { value, type, backType, desc } = this.props.recallCatInfo;
const { value, type, backType, tips } = this.props.recallCatInfo;
let getText = '';
let getTextColor = '';
let getTypeText = '';
let okBtnImg = '';
if (type == 4) {
getText = '精力值';
} else if (type == 6) {
......@@ -57,17 +62,20 @@ Component({
case 1:
getText = '+' + value + getText;
getTextColor = 'red';
getTypeText = '获得'
getTypeText = '获得';
okBtnImg = this.props.okBtnImgArr[1];
break;
case 2:
getText = '+' + value + getText;
getTextColor = 'red';
getTypeText = '意外获得';
okBtnImg = this.props.okBtnImgArr[1];
break;
case 3:
getText = '-' + value + getText;
getTextColor = 'black';
getTypeText = '损失';
okBtnImg = this.props.okBtnImgArr[0];
break;
}
console.log("mm" + this.props.mydata.catType - 1)
......@@ -77,7 +85,9 @@ Component({
getText: getText,
getColor: getTextColor,
getTypeText:getTypeText,
backType:backType
backType:backType,
desc:tips[Math.floor(Math.random()*tips.length)],
okBtnImg:resList[okBtnImg].url
})
},
});
\ No newline at end of file
This diff is collapsed.
......@@ -490,5 +490,11 @@ const resList = {
url: '//yun.duiba.com.cn/spark/assets/a67137c922a0d539215aed739676aa7636e3c4d8.png'
},
'c8c50400-1d65-4971-8be5-e4fb2eecfcd5': {
name: 'unluckyBtn',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/unluckyBtn.e57fc34e49370d30a6942fb835395377a9cf4721.png',
uuid: 'c8c50400-1d65-4971-8be5-e4fb2eecfcd5'
}
};
export default resList;
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