Commit 199cae6d authored by Edwise's avatar Edwise 🍷

1234

parent c0d20f8b
{ {
"success": true, "success": true,
"message":"请稍后重试", "data": {
"data": "aaaa", "tips": "梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛",
"code": "000" "isUpgrade": true,
"channel": "aliqua",
"strategyCode": "dolore",
"code": "et nostrud adipisicing",
"image": "occaecat aliquip",
"name": "officia et deserunt ut",
"type": 65894870.29773912
},
"code": "culpa eu Ut"
} }
\ No newline at end of file
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
"level": "1", "level": "1",
"avatar": "https://yun.duiba.com.cn/spark/assets/a3ae99684afa9a1f8d94f4c95ee6f1ed81de9996.png", "avatar": "https://yun.duiba.com.cn/spark/assets/a3ae99684afa9a1f8d94f4c95ee6f1ed81de9996.png",
"sence": 3, "sence": 3,
"catName": "喵喵喵fuck." "catName": "喵喵喵",
"senceTips":["1说话说话说话说话说话说话说话说话说话说话说话","2说话说话说话说话说话说话说话说话说话说话说话说话","3说话说话说话说话说话说话说话说话说话说话说话说话"]
} }
} }
\ No newline at end of file
/**当前场景对应的类型 */ /**当前场景对应的类型 */
export enum SCENETYPE{ export enum SCENETYPE{
/**教室 */ /**教室 */
CLASSROOM, CLASSROOM=1,
/**操场 */ /**操场 */
PLAYGROUND, PLAYGROUND,
/**寝室 */ /**寝室 */
......
import { RES } from "../module/RES"; import { RES } from "../module/RES";
import resCanvasList from "../resCanvasList" import resCanvasList from "../resCanvasList"
import { SCENETYPE } from "./Enum";
/**记录全局信息与全局方法 */ /**记录全局信息与全局方法 */
export class Ins { export class Ins {
/**舞台宽高 */ /**舞台宽高 */
...@@ -10,6 +11,9 @@ export class Ins { ...@@ -10,6 +11,9 @@ export class Ins {
/**猫咪是否出寝了 */ /**猫咪是否出寝了 */
public static catIsOut:boolean; public static catIsOut:boolean;
/**当前用户所在场景 */
public static curScene:SCENETYPE;
public static userInfo: { public static userInfo: {
"catName": string, //猫咪姓名 "catName": string, //猫咪姓名
"catType": string, //猫咪类型 "catType": string, //猫咪类型
...@@ -20,7 +24,20 @@ export class Ins { ...@@ -20,7 +24,20 @@ export class Ins {
"level": string, //等级 "level": string, //等级
"avatar": string, //头像 "avatar": string, //头像
"sence": number, //场景 "sence": number, //场景
"senceTips":string[] //场景互动文案(猫咪说话)
}
public static showToast(msg?:any){
FYGE.GDispatcher.dispatchEvent("toast",msg);
}
public static showLoading(){
FYGE.GDispatcher.dispatchEvent("loading");
}
public static hideLoading(){
FYGE.GDispatcher.dispatchEvent("hideloading");
} }
/**删除一个lottie的所有tween,停止动效 */ /**删除一个lottie的所有tween,停止动效 */
......
import { showToast, wait, clearWait } from "../module/ctrls"; import { showToast, wait, clearWait } from "../module/ctrls";
import { Ins } from "./Ins";
import { GDispatcher } from "./Main"; import { GDispatcher } from "./Main";
//接口枚举,包括需要调用淘宝的api,用是否含有兑吧区分,或者单独区分 //接口枚举,包括需要调用淘宝的api,用是否含有兑吧区分,或者单独区分
...@@ -168,7 +169,7 @@ export function sendTbNet( ...@@ -168,7 +169,7 @@ export function sendTbNet(
netName: TbNetName, netName: TbNetName,
parameter?: any, parameter?: any,
callback?: (success: boolean, res?: dataOut) => void, callback?: (success: boolean, res?: dataOut) => void,
hideMsg: boolean = false hideMsg: boolean = true
): Promise<dataOut> { ): Promise<dataOut> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
//网络超时 //网络超时
...@@ -215,7 +216,7 @@ export function sendTbNet( ...@@ -215,7 +216,7 @@ export function sendTbNet(
//记录数据 //记录数据
dataRecord[netName] = d; dataRecord[netName] = d;
//统一错误信息提示,d.data为了区分网络超时 //统一错误信息提示,d.data为了区分网络超时
if (!hideMsg && !d.success) showToast(d.message || "网络超时") if (!hideMsg && !d.success) Ins.showToast(d.message || "网络超时")
//执行回调 //执行回调
callback && callback(d.success, d); callback && callback(d.success, d);
resolve(d) resolve(d)
......
...@@ -46,13 +46,17 @@ export class Cat extends Module { ...@@ -46,13 +46,17 @@ export class Cat extends Module {
actRunning: boolean = false; //动效是否进行中,如果动效进行中,无法进行其他动效 actRunning: boolean = false; //动效是否进行中,如果动效进行中,无法进行其他动效
dialog:FYGE.Sprite; //猫咪对话框气泡 dialog:FYGE.Sprite; //猫咪对话框气泡
dialogText:FYGE.TextField; //猫咪对话框气泡文字内容 dialogText:FYGE.TextField; //猫咪对话框气泡文字内容
dialogPos:any[]=[{x:1,y:1}]; //猫咪对话框气泡位置
initUi() { initUi() {
this.initCatLottieArr(); this.initCatLottieArr();
console.log(this.catLottieArr); console.log(this.catLottieArr);
this.initCat(); this.initCat();
this.initDialog(); this.initDialog();
this.setCatAnimShow(0); var tipsArr = Ins.userInfo.senceTips;
var index = Math.floor(Math.random()*tipsArr.length)
this.showDialog(1,tipsArr[index]);
this.setCatAnimShow(1,()=>{this.stopCatAct()});
this.initEvents(); this.initEvents();
} }
...@@ -125,26 +129,38 @@ export class Cat extends Module { ...@@ -125,26 +129,38 @@ export class Cat extends Module {
/**初始化对话框 */ /**初始化对话框 */
initDialog(){ initDialog(){
var that = this; var that = this;
that.dialogPos = [{},{x:280,y:516},{x:320,y:400},{x:280,y:556},{x:280,y:536},{x:370,y:536}]
that.dialog = Ins.initSprite("624e8c63-963f-4b20-9802-b0fb006fbf93"); that.dialog = Ins.initSprite("624e8c63-963f-4b20-9802-b0fb006fbf93");
that.dialog.position.set(280,526) that.dialog.position.set(280,526)
that.addChild(that.dialog); that.addChild(that.dialog);
that.dialogText = Ins.initLabel({size:24,x:30,y:20}); that.dialogText = Ins.initLabel({size:24,x:30,y:20});
that.dialogText.textWidth = 280; that.dialogText.textWidth = 280;
that.dialog.addChild(that.dialogText); that.dialog.addChild(that.dialogText);
that.dialogText.text = "哈哈哈哈哈哈哈哈哈哈哈\n哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈"; that.dialogText.textHeight = 138;
that.dialogText.verticalAlign = FYGE.VERTICAL_ALIGN.MIDDLE
// that.dialogText.text = "哈哈哈哈哈哈哈,哈哈哈\n哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈";
console.log("最大长度为"+that.dialogText.text.length) console.log("最大长度为"+that.dialogText.text.length)
that.dialog.visible = false; console.log("当前文本高度为"+that.dialogText.textHeight);
// that.dialog.visible = false;
that.dialog.alpha = 0;
} }
/**显示对话框 */ /**显示对话框 */
showDialog(msg:string){ showDialog(type,msg:string){
this.dialogText.text = msg; var that = this;
this.dialog.visible = true; msg = msg.length>=11?msg.substring(0,11)+'\n'+msg.substring(11):msg
that.dialog.position.set(that.dialogPos[type].x,that.dialogPos[type].y)
that.dialogText.text = msg;
FYGE.Tween.removeTweens(that.dialog);
that.dialog.alpha = 0;
FYGE.Tween.get(that.dialog).to({alpha:1},400);
// this.dialog.visible = true;
} }
/**隐藏对话框 */ /**隐藏对话框 */
hideDialog(){ hideDialog(){
this.dialog.visible = false; this.dialog.alpha = 0;
FYGE.Tween.removeTweens(this.dialog);
} }
/**根据index显示猫咪动画 /**根据index显示猫咪动画
...@@ -169,13 +185,31 @@ export class Cat extends Module { ...@@ -169,13 +185,31 @@ export class Cat extends Module {
} }
} }
/**猫咪停止互动 */
stopCatAct(){
var that = this;
that.hideDialog();
that.setCatAnimShow(0,null);
}
/**猫咪互动 */ /**猫咪互动 */
catAct(e) { catAct(e) {
if (this.actRunning) return; if (this.actRunning) return;
var that = this; var that = this;
let actType = e.data; let actType = e.data;
var type;
switch(actType){
case 2: type=2;
break;
case 3: type=1;
break;
case 4: type=4;
break;
case 5: type=3;
break;
}
console.log(actType); console.log(actType);
sendTbNet(TbNetName.interaction, {}, (s, r) => { sendTbNet(TbNetName.interaction, {type:type,scene:Ins.curScene}, (s, r) => {
if (s) { if (s) {
FYGE.GDispatcher.dispatchEvent(MSG.UPDATE_USERINFO); FYGE.GDispatcher.dispatchEvent(MSG.UPDATE_USERINFO);
that.actRunning = true; that.actRunning = true;
...@@ -183,15 +217,15 @@ export class Cat extends Module { ...@@ -183,15 +217,15 @@ export class Cat extends Module {
case CAT_ACTTYPEP.SLEEP: case CAT_ACTTYPEP.SLEEP:
break; break;
default: default:
that.showDialog(actType,r.data.tips);
that.setCatAnimShow(actType, () => { that.setCatAnimShow(actType, () => {
that.hideDialog(); that.stopCatAct();
that.setCatAnimShow(0, null)
}); });
break; break;
} }
}else }else
{ {
showToast(r.message) Ins.showToast(r.message)
} }
}) })
} }
......
...@@ -53,10 +53,11 @@ export class MainScene extends Scene { ...@@ -53,10 +53,11 @@ export class MainScene extends Scene {
that.y = (Ins.stageH - 1624) >> 1; that.y = (Ins.stageH - 1624) >> 1;
console.log(that.y); console.log(that.y);
that.mouseChildren = true; that.mouseChildren = true;
Ins.curScene = Ins.userInfo.sence;
//0:教室,1:操场,2:寝室 //0:教室,1:操场,2:寝室
that.bgUUID = ["c6d699b0-b276-4985-b3ea-47bcef13f2ea", "efaf990e-5392-49ad-94d8-25c04f651ede", "b3c8c187-e5c9-4968-9a00-a118d18ab2fc"]; that.bgUUID = ["c6d699b0-b276-4985-b3ea-47bcef13f2ea", "efaf990e-5392-49ad-94d8-25c04f651ede", "b3c8c187-e5c9-4968-9a00-a118d18ab2fc"];
//生成默认场景,后面要改成根据接口值判断 //生成默认场景,后面要改成根据接口值判断
that.sceneBg = Ins.initSprite("b3c8c187-e5c9-4968-9a00-a118d18ab2fc"); that.sceneBg = Ins.initSprite(that.bgUUID[Ins.curScene-1]);
that.addChild(that.sceneBg); that.addChild(that.sceneBg);
that.tlBtn = Ins.initSprite("1f8b040d-2fbc-4ff8-92f9-159773364fae", 0, 640); that.tlBtn = Ins.initSprite("1f8b040d-2fbc-4ff8-92f9-159773364fae", 0, 640);
...@@ -71,7 +72,15 @@ export class MainScene extends Scene { ...@@ -71,7 +72,15 @@ export class MainScene extends Scene {
that.mxqBtn.mouseEnable = true; that.mxqBtn.mouseEnable = true;
that.addChild(that.mxqBtn); that.addChild(that.mxqBtn);
that.mainUi = new MainSceneBtnUi({ uiType: SCENETYPE.BEADROOM }); if(Ins.curScene==SCENETYPE.BEADROOM){
that.tlBtn.visible = true;
that.mxqBtn.visible = true;
}else{
that.tlBtn.visible = false;
that.mxqBtn.visible = false;
}
that.mainUi = new MainSceneBtnUi({ uiType: Ins.curScene });
that.addChild(that.mainUi); that.addChild(that.mainUi);
that.initCat(); that.initCat();
...@@ -158,16 +167,17 @@ export class MainScene extends Scene { ...@@ -158,16 +167,17 @@ export class MainScene extends Scene {
changeMainScene(type: SCENETYPE) { changeMainScene(type: SCENETYPE) {
console.log("切换到" + type) console.log("切换到" + type)
var that = this; var that = this;
that.sceneBg.texture = RES.getRes(resCanvasList[that.bgUUID[type]].url) Ins.curScene = type;
that.sceneBg.texture = RES.getRes(resCanvasList[that.bgUUID[type-1]].url)
//切换场景时判断猫在不在,后面要改成与接口值判断 //切换场景时判断猫在不在,后面要改成与接口值判断
if (Ins.catIsOut) { if (Ins.catIsOut) {
that.cat.visible = false; that.cat.visible = false;
} else { } else {
if ((type + 1) == Ins.userInfo.sence) { if ((type) == Ins.userInfo.sence) {
that.cat.visible = true; that.cat.visible = true;
} else { } else {
that.cat.visible = false; that.cat.visible = false;
that.cat.setCatAnimShow(0); that.cat.stopCatAct();
} }
} }
switch (type) { switch (type) {
......
...@@ -21,7 +21,7 @@ export class StartScene extends Scene { ...@@ -21,7 +21,7 @@ export class StartScene extends Scene {
if(r.data){ if(r.data){
Ins.userInfo = r.data; Ins.userInfo = r.data;
/**判断猫咪是否出寝,只在用户进入游戏时判断,后面要根据接口改写,现在先做测试 */ /**判断猫咪是否出寝,只在用户进入游戏时判断,后面要根据接口改写,现在先做测试 */
if(r.data.happyCoin>2000){ if(r.data.sence==4){
Ins.catIsOut = true; Ins.catIsOut = true;
}else{ }else{
Ins.catIsOut = false; Ins.catIsOut = false;
...@@ -33,7 +33,7 @@ export class StartScene extends Scene { ...@@ -33,7 +33,7 @@ export class StartScene extends Scene {
} }
}else }else
{ {
showToast(r.message) Ins.showToast(r.message)
} }
}) })
......
...@@ -177,21 +177,20 @@ export class MainSceneBtnUi extends Module { ...@@ -177,21 +177,20 @@ export class MainSceneBtnUi extends Module {
case SCENETYPE.BEADROOM: case SCENETYPE.BEADROOM:
if (Ins.catIsOut) { if (Ins.catIsOut) {
that.catRecall.visible = true; that.catRecall.visible = true;
} else { } else if(Ins.userInfo.sence==type){
that.combingBtn.visible = true; that.combingBtn.visible = true;
that.catBtn.visible = true; that.catBtn.visible = true;
} }
break; break;
case SCENETYPE.CLASSROOM: case SCENETYPE.CLASSROOM:
that.returnBtn.visible = true; that.returnBtn.visible = true;
if (!Ins.catIsOut) { if (!Ins.catIsOut&&Ins.userInfo.sence==type) {
that.touchHeadBtn.visible = true; that.touchHeadBtn.visible = true;
} }
break; break;
case SCENETYPE.PLAYGROUND: case SCENETYPE.PLAYGROUND:
that.returnBtn.visible = true; that.returnBtn.visible = true;
if (!Ins.catIsOut) { if (!Ins.catIsOut&&Ins.userInfo.sence==type) {
that.playBtn.visible = true; that.playBtn.visible = true;
} }
break; break;
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
import resList from '../../resconfig/resList'; import resList from '../../resconfig/resList';
Component({ Component({
props: {}, props: {
},
data: { data: {
resList: resList, resList: resList,
curSelect:1 //1:蓝猫,2:三花,3:暹罗,4:橘猫 curSelect:1 //1:蓝猫,2:三花,3:暹罗,4:橘猫
...@@ -24,10 +26,11 @@ Component({ ...@@ -24,10 +26,11 @@ Component({
}, },
selectSure(){ selectSure(){
const {getCatTypeAndOpenNameModal,onModalClose} = this.props; console.log(this.props);
const {closeModal,onModalClose} = this.props;
onModalClose && onModalClose(); onModalClose && onModalClose();
console.log(getCatTypeAndOpenNameModal) console.log(closeModal)
// getCatTypeAndOpenNameModal&&getCatTypeAndOpenNameModal(this.data.curSelect); closeModal&&closeModal();
} }
}, },
......
...@@ -7,5 +7,6 @@ ...@@ -7,5 +7,6 @@
<rule-modal a:if="{{ruleModalVisible}}" onModalClose="closeRuleModal"><text>{{rule}}</text></rule-modal> <rule-modal a:if="{{ruleModalVisible}}" onModalClose="closeRuleModal"><text>{{rule}}</text></rule-modal>
<levelup-modal a:if="{{levelupModalVisible}}" onModalClose="closeLevelupModal"></levelup-modal> <levelup-modal a:if="{{levelupModalVisible}}" onModalClose="closeLevelupModal"></levelup-modal>
<message-modal a:if="{{messageModalVisible}}" mydata="{{messageModalData}}" onModalClose="closeMessageModal"></message-modal> <message-modal a:if="{{messageModalVisible}}" mydata="{{messageModalData}}" onModalClose="closeMessageModal"></message-modal>
<view class="popcontainer" a:if="{{selectcatModalVisible}}"><selectcat-modal getCatTypeAndOpenNameModal="getCatTypeAndOpenNameModal" onModalClose="closeSelectcatModal"></selectcat-modal></view> <view class="popcontainer" a:if="{{selectcatModalVisible}}"><selectcat-modal onModalClose="closeSelectcatModal" closeModal=closeModal></selectcat-modal></view>
<view class="popcontainer" a:if="{{catnameModalVisible}}" ><catname-modal onModalClose="closeCatnameModal"/></view> <view class="popcontainer" a:if="{{catnameModalVisible}}" ><catname-modal onModalClose="closeCatnameModal"/></view>
\ No newline at end of file
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