Commit 199cae6d authored by Edwise's avatar Edwise 🍷

1234

parent c0d20f8b
{
"success": true,
"message":"请稍后重试",
"data": "aaaa",
"code": "000"
"data": {
"tips": "梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛",
"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 @@
"level": "1",
"avatar": "https://yun.duiba.com.cn/spark/assets/a3ae99684afa9a1f8d94f4c95ee6f1ed81de9996.png",
"sence": 3,
"catName": "喵喵喵fuck."
"catName": "喵喵喵",
"senceTips":["1说话说话说话说话说话说话说话说话说话说话说话","2说话说话说话说话说话说话说话说话说话说话说话说话","3说话说话说话说话说话说话说话说话说话说话说话说话"]
}
}
\ No newline at end of file
/**当前场景对应的类型 */
export enum SCENETYPE{
/**教室 */
CLASSROOM,
CLASSROOM=1,
/**操场 */
PLAYGROUND,
/**寝室 */
......
import { RES } from "../module/RES";
import resCanvasList from "../resCanvasList"
import { SCENETYPE } from "./Enum";
/**记录全局信息与全局方法 */
export class Ins {
/**舞台宽高 */
......@@ -10,6 +11,9 @@ export class Ins {
/**猫咪是否出寝了 */
public static catIsOut:boolean;
/**当前用户所在场景 */
public static curScene:SCENETYPE;
public static userInfo: {
"catName": string, //猫咪姓名
"catType": string, //猫咪类型
......@@ -20,7 +24,20 @@ export class Ins {
"level": string, //等级
"avatar": string, //头像
"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,停止动效 */
......
import { showToast, wait, clearWait } from "../module/ctrls";
import { Ins } from "./Ins";
import { GDispatcher } from "./Main";
//接口枚举,包括需要调用淘宝的api,用是否含有兑吧区分,或者单独区分
......@@ -168,7 +169,7 @@ export function sendTbNet(
netName: TbNetName,
parameter?: any,
callback?: (success: boolean, res?: dataOut) => void,
hideMsg: boolean = false
hideMsg: boolean = true
): Promise<dataOut> {
return new Promise((resolve, reject) => {
//网络超时
......@@ -215,7 +216,7 @@ export function sendTbNet(
//记录数据
dataRecord[netName] = d;
//统一错误信息提示,d.data为了区分网络超时
if (!hideMsg && !d.success) showToast(d.message || "网络超时")
if (!hideMsg && !d.success) Ins.showToast(d.message || "网络超时")
//执行回调
callback && callback(d.success, d);
resolve(d)
......
......@@ -46,13 +46,17 @@ export class Cat extends Module {
actRunning: boolean = false; //动效是否进行中,如果动效进行中,无法进行其他动效
dialog:FYGE.Sprite; //猫咪对话框气泡
dialogText:FYGE.TextField; //猫咪对话框气泡文字内容
dialogPos:any[]=[{x:1,y:1}]; //猫咪对话框气泡位置
initUi() {
this.initCatLottieArr();
console.log(this.catLottieArr);
this.initCat();
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();
}
......@@ -125,26 +129,38 @@ export class Cat extends Module {
/**初始化对话框 */
initDialog(){
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.position.set(280,526)
that.addChild(that.dialog);
that.dialogText = Ins.initLabel({size:24,x:30,y:20});
that.dialogText.textWidth = 280;
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)
that.dialog.visible = false;
console.log("当前文本高度为"+that.dialogText.textHeight);
// that.dialog.visible = false;
that.dialog.alpha = 0;
}
/**显示对话框 */
showDialog(msg:string){
this.dialogText.text = msg;
this.dialog.visible = true;
showDialog(type,msg:string){
var that = this;
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(){
this.dialog.visible = false;
this.dialog.alpha = 0;
FYGE.Tween.removeTweens(this.dialog);
}
/**根据index显示猫咪动画
......@@ -169,13 +185,31 @@ export class Cat extends Module {
}
}
/**猫咪停止互动 */
stopCatAct(){
var that = this;
that.hideDialog();
that.setCatAnimShow(0,null);
}
/**猫咪互动 */
catAct(e) {
if (this.actRunning) return;
var that = this;
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);
sendTbNet(TbNetName.interaction, {}, (s, r) => {
sendTbNet(TbNetName.interaction, {type:type,scene:Ins.curScene}, (s, r) => {
if (s) {
FYGE.GDispatcher.dispatchEvent(MSG.UPDATE_USERINFO);
that.actRunning = true;
......@@ -183,15 +217,15 @@ export class Cat extends Module {
case CAT_ACTTYPEP.SLEEP:
break;
default:
that.showDialog(actType,r.data.tips);
that.setCatAnimShow(actType, () => {
that.hideDialog();
that.setCatAnimShow(0, null)
that.stopCatAct();
});
break;
}
}else
{
showToast(r.message)
Ins.showToast(r.message)
}
})
}
......
......@@ -53,10 +53,11 @@ export class MainScene extends Scene {
that.y = (Ins.stageH - 1624) >> 1;
console.log(that.y);
that.mouseChildren = true;
Ins.curScene = Ins.userInfo.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("b3c8c187-e5c9-4968-9a00-a118d18ab2fc");
that.sceneBg = Ins.initSprite(that.bgUUID[Ins.curScene-1]);
that.addChild(that.sceneBg);
that.tlBtn = Ins.initSprite("1f8b040d-2fbc-4ff8-92f9-159773364fae", 0, 640);
......@@ -71,7 +72,15 @@ export class MainScene extends Scene {
that.mxqBtn.mouseEnable = true;
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.initCat();
......@@ -158,16 +167,17 @@ export class MainScene extends Scene {
changeMainScene(type: SCENETYPE) {
console.log("切换到" + type)
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) {
that.cat.visible = false;
} else {
if ((type + 1) == Ins.userInfo.sence) {
if ((type) == Ins.userInfo.sence) {
that.cat.visible = true;
} else {
that.cat.visible = false;
that.cat.setCatAnimShow(0);
that.cat.stopCatAct();
}
}
switch (type) {
......
......@@ -21,7 +21,7 @@ export class StartScene extends Scene {
if(r.data){
Ins.userInfo = r.data;
/**判断猫咪是否出寝,只在用户进入游戏时判断,后面要根据接口改写,现在先做测试 */
if(r.data.happyCoin>2000){
if(r.data.sence==4){
Ins.catIsOut = true;
}else{
Ins.catIsOut = false;
......@@ -33,7 +33,7 @@ export class StartScene extends Scene {
}
}else
{
showToast(r.message)
Ins.showToast(r.message)
}
})
......
......@@ -177,21 +177,20 @@ export class MainSceneBtnUi extends Module {
case SCENETYPE.BEADROOM:
if (Ins.catIsOut) {
that.catRecall.visible = true;
} else {
} else if(Ins.userInfo.sence==type){
that.combingBtn.visible = true;
that.catBtn.visible = true;
}
break;
case SCENETYPE.CLASSROOM:
that.returnBtn.visible = true;
if (!Ins.catIsOut) {
if (!Ins.catIsOut&&Ins.userInfo.sence==type) {
that.touchHeadBtn.visible = true;
}
break;
case SCENETYPE.PLAYGROUND:
that.returnBtn.visible = true;
if (!Ins.catIsOut) {
if (!Ins.catIsOut&&Ins.userInfo.sence==type) {
that.playBtn.visible = true;
}
break;
......
......@@ -2,7 +2,9 @@
import resList from '../../resconfig/resList';
Component({
props: {},
props: {
},
data: {
resList: resList,
curSelect:1 //1:蓝猫,2:三花,3:暹罗,4:橘猫
......@@ -24,10 +26,11 @@ Component({
},
selectSure(){
const {getCatTypeAndOpenNameModal,onModalClose} = this.props;
console.log(this.props);
const {closeModal,onModalClose} = this.props;
onModalClose && onModalClose();
console.log(getCatTypeAndOpenNameModal)
// getCatTypeAndOpenNameModal&&getCatTypeAndOpenNameModal(this.data.curSelect);
console.log(closeModal)
closeModal&&closeModal();
}
},
......
......@@ -7,5 +7,6 @@
<rule-modal a:if="{{ruleModalVisible}}" onModalClose="closeRuleModal"><text>{{rule}}</text></rule-modal>
<levelup-modal a:if="{{levelupModalVisible}}" onModalClose="closeLevelupModal"></levelup-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>
\ No newline at end of file
......@@ -26,8 +26,8 @@ const checkSystem = async () => {
Page({
data: {
catType:1,
catName:'',
catType: 1,
catName: '',
messageModalVisible: false,
messageModalData: {},
ruleModalVisible: false,
......@@ -53,11 +53,18 @@ Page({
onReady() {
console.log('on ready')
var that = this;
setTimeout(()=>{
var parameter = {name:"selectcatModal"}
var data = {netName:"mine.showModal",parameter}
that.onMessage({data:data})
},2000)
setTimeout(() => {
var parameter = {
name: "selectcatModal"
}
var data = {
netName: "mine.showModal",
parameter
}
that.onMessage({
data: data
})
}, 2000)
//授权和登录先搞
// this.getAuth();
my.__onMessage__ = (e) => {
......@@ -89,7 +96,9 @@ Page({
app.canvasMain = this.main;
this.main.addGlobalEvent("onMessage", self.onMessage, self);
this.main.addGlobalEvent("showToast", self.showToast, self);
this.main.addGlobalEvent("toast", self.showToast, self);
this.main.addGlobalEvent("loading", self.showLoadingHandler,self);
this.main.addGlobalEvent("hideloading",self.hideLoadingHandler,self);
}
}
});
......@@ -105,12 +114,18 @@ Page({
});
},
showToast(e) {
showToastHandler(e) {
my.showToast({
content: e.data || "网络异常,请稍后重试~",
duration: 2000
});
},
showLoadingHandler(){
my.showLoading();
},
hideLoadingHandler(){
my.hideLoading();
},
postMessage(netName, data) {
this.main && this.main.dispatchGlobalEvent({
......@@ -252,9 +267,9 @@ Page({
}
},
/**选择猫咪,打开取名弹窗 */
getCatTypeAndOpenNameModal(type){
this.catType = type;
console.log("选择了",type)
closeModal() {
// this.catType = type;
// console.log("选择了", type)
},
closeLevelupModal() {
this.setData({
......
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