Commit 3f7b3e32 authored by wjf's avatar wjf

Merge branch 'dev' of gitlab2.dui88.com:wanghongyuan/xiaoxiaole into dev

parents d3d91ccf f14b20bc
......@@ -28,6 +28,8 @@ import MapTopPart from "./MapTopPart";
import createRegTriangle from "../playScene/factory/createRegTriangle";
import RedBagAni, { createRedBagIcon } from "./RedBagAni";
import { createEffect2MovieClip } from "../effect/createEffect2";
import IconBase from "./icon/IconBase";
import ActIcon from "./icon/ActIcon";
let doHelpFlag = false;
// let doScratchHelpFlag = false;
......@@ -44,25 +46,35 @@ export default class MapScene extends Scene {
_data;
private icons = {};
private actIcon:ActIcon = null;
sendInvite() {
const code = Utils.getRequestByKey('shareCode');
if (!code) return;
if (doHelpFlag) {
if(!code) return;
if(doHelpFlag) {
return;
}
if (code.indexOf("12345678") == -1) { // 邀请有礼
if(code.indexOf("12345678") == -1) { // 邀请有礼
const dojoin = DataManager.ins.getData('hc_doJoin');
if (!dojoin) return;
if(!dojoin) return;
NetManager.ins.doHelp((success, res) => {
doHelpFlag = true;
switch (true) {
case (res.code == "400017"): showToast("您不是新用户呢~"); break;
case (res.code == "0000022"): showToast("不可以给自己助力哦~"); break;
case (res.code == "0200202"): showToast("已经给好友助力过了哦~"); break;
default: break;
switch(true) {
case (res.code == "400017"):
showToast("您不是新用户呢~");
break;
case (res.code == "0000022"):
showToast("不可以给自己助力哦~");
break;
case (res.code == "0200202"):
showToast("已经给好友助力过了哦~");
break;
default:
break;
}
if(!success) {
return;
}
if (!success) { return; }
showToast("助力成功");
NetManager.ins.showLog(getlogItem(36));
}, code, dojoin.data);
......@@ -70,13 +82,22 @@ export default class MapScene extends Scene {
const _code = code.slice(8);
NetManager.ins.scratchDoHelp((success, res) => {
doHelpFlag = true;
switch (true) {
case (res.code == "0000024"): showToast("今日刮卡次数已达到上线限哦~"); break;
case (res.code == "0000022"): showToast("不可以给自己刮哦~"); break;
case (res.code == "0000023"): showToast("已经给好友刮过了哦~"); break;
default: break;
switch(true) {
case (res.code == "0000024"):
showToast("今日刮卡次数已达到上线限哦~");
break;
case (res.code == "0000022"):
showToast("不可以给自己刮哦~");
break;
case (res.code == "0000023"):
showToast("已经给好友刮过了哦~");
break;
default:
break;
}
if(!success) {
return;
}
if (!success) { return; }
showToast("帮刮成功!");
NetManager.ins.showLog(getlogItem(52));
NetManager.ins.showLog(getlogItem(36));
......@@ -95,7 +116,6 @@ export default class MapScene extends Scene {
// const submitData = DataManager.ins.getData('hc_submit').data;
// PanelCtrl.instance.show(ModuleTypes.PRIZE_PANEL,{ level:1, option: submitData.option })
// },1,1,'','')
this['actIconsGroup'].x = -999;
this.addIcon(); // 添加Icon
this.sendInvite();
......@@ -105,7 +125,7 @@ export default class MapScene extends Scene {
GDispatcher.dispatchEvent("getInviteInfo"); // 查询邀请信息,控制邀请有礼角标
this['avatar'].mask = this['avatarMask'];
if (getBgOn() && MapScene['firstPlayBgTag'] == true) {
if(getBgOn() && MapScene['firstPlayBgTag'] == true) {
playBg();
}
......@@ -122,12 +142,12 @@ export default class MapScene extends Scene {
const oldTimerStr2 = localStorage.getItem('nowTimer2Str' + window['CFG'].consumerId);
const hc_advert = DataManager.ins.getData('hc_advert').data || {};
let { noticeAdvert } = hc_advert;
if (noticeAdvert == null) {
noticeAdvert = { enable: false }
let {noticeAdvert} = hc_advert;
if(noticeAdvert == null) {
noticeAdvert = {enable: false}
}
if (noticeAdvert && noticeAdvert.enable && nowTimerStr2 != oldTimerStr2) {
if(noticeAdvert && noticeAdvert.enable && nowTimerStr2 != oldTimerStr2) {
// if (!adTag) {
panels.push('ad');
// adTag = true;
......@@ -140,16 +160,16 @@ export default class MapScene extends Scene {
// panels.push('back');
// }
const { signInfoVO } = DataManager.ins.getData('getSignInfo');
if (signInfoVO.continueDay < 7) { //表示明天还可以签到
if (signInfoVO.todaySigned == 0 && oldTimerStr != nowTimerStr) {
const {signInfoVO} = DataManager.ins.getData('getSignInfo');
if(signInfoVO.continueDay < 7) { //表示明天还可以签到
if(signInfoVO.todaySigned == 0 && oldTimerStr != nowTimerStr) {
panels.push('sign');
localStorage.setItem('nowTimerStr' + window['CFG'].consumerId, nowTimerStr);
}
}
this.updateSign();
if (!readCache() && getHomeData().levels.length <= 0) { //引导
if(!readCache() && getHomeData().levels.length <= 0) { //引导
const guide = new GuideCon(() => {
PanelCtrl.instance.showPanels(panels, [], this.onAllPanelHide);
});
......@@ -189,19 +209,19 @@ export default class MapScene extends Scene {
let target;
const homeData = getHomeData();
if (homeData.levels.length == 0) {
if(homeData.levels.length == 0) {
target = 1;
} else if (homeData.levels.length == window['total_level']) {
} else if(homeData.levels.length == window['total_level']) {
target = window['total_level'] + 1;
} else {
target = homeData.levels.length + 1;
}
for (const key in MapScene.iconHash) {
for(const key in MapScene.iconHash) {
const levelOrder = parseInt(key);
const element = MapScene.iconHash[key];
if (!element.hasEventListener(egret.TouchEvent.TOUCH_TAP)) {
if(!element.hasEventListener(egret.TouchEvent.TOUCH_TAP)) {
element.addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
if (
if(
(levelOrder > (getHomeData().levels.length + 1) && levelOrder > 1)
|| (levelOrder > window['last_level'])
) {
......@@ -214,7 +234,7 @@ export default class MapScene extends Scene {
}
}
if (homeData.levels.length < window['total_level']) {
if(homeData.levels.length < window['total_level']) {
const targetIcon = MapScene.iconHash[target];
const light = RES.getRes('lightani_png');
......@@ -227,7 +247,7 @@ export default class MapScene extends Scene {
pic.anchorOffsetY = 61;
// pic.x = 50 - 2;
// pic.y = 37 + 10;
egret.Tween.get(pic, { loop: true }).to({ scaleX: 2, scaleY: 2, alpha: 0 }, 1000).wait(1000);
egret.Tween.get(pic, {loop: true}).to({scaleX: 2, scaleY: 2, alpha: 0}, 1000).wait(1000);
this['pic'] = pic;
}
......@@ -237,8 +257,8 @@ export default class MapScene extends Scene {
this.showLog();
this.updateBox();
if (data.level) {
if (homeData.remainEnargy == 0)
if(data.level) {
if(homeData.remainEnargy == 0)
PanelCtrl.instance.show('bloodPanel')
else
......@@ -246,8 +266,8 @@ export default class MapScene extends Scene {
}
this.stage.once(egret.TouchEvent.TOUCH_TAP, () => {
if (!MapScene['firstPlayBgTag']) {
if (getBgOn()) {
if(!MapScene['firstPlayBgTag']) {
if(getBgOn()) {
playBg();
}
MapScene['firstPlayBgTag'] = true;
......@@ -255,7 +275,7 @@ export default class MapScene extends Scene {
}, this);
let lastOrder = homeData.levels.length + 1;
if (homeData.levels.length >= window['total_level'])
if(homeData.levels.length >= window['total_level'])
lastOrder = window['total_level'];
this.scroll.viewport.scrollV = this.getScrollV(lastOrder, this.stage.stageHeight);
// console.warn(this.getScrollV(lastOrder, this.stage.stageHeight))
......@@ -265,7 +285,7 @@ export default class MapScene extends Scene {
Promise.all([
RES.getResAsync(`${key}_json`),
RES.getResAsync(`${key}_png`)]);
} catch (error) {
} catch(error) {
}
......@@ -273,7 +293,7 @@ export default class MapScene extends Scene {
}
onAllPanelHide = () => {
if (!localStorage.getItem('activityguide')) {
if(!localStorage.getItem('activityguide')) {
this['guide'].visible = true;
}
}
......@@ -284,15 +304,15 @@ export default class MapScene extends Scene {
const y1 = this.stage.stageHeight + this.scroll.viewport.scrollV - offset;
// console.log(y0, y1);
let count = 0;
for (const key in MapScene.iconHash) {
for(const key in MapScene.iconHash) {
const icon = MapScene.iconHash[key];
if (icon['visibleY'] >= y0 && icon['visibleY'] <= y1) {
if(icon['visibleY'] >= y0 && icon['visibleY'] <= y1) {
icon.show();
} else if (icon.parent) {
} else if(icon.parent) {
icon.hide();
}
if (icon.parent)
if(icon.parent)
count++;
}
}
......@@ -302,8 +322,17 @@ export default class MapScene extends Scene {
this.icons = {
"scratchIcon": new ScratchIcon("scratchIcon", this["scratchGroup"], this["scratchBtn"], this["scratchTipsBg"], this["scratchTips"]),
"turntableIcon": new TurntableIcon("turntableIcon", this["turnTableGroup"], this["turnTableBtn"], this["turnTableTipsBg"], this["turnTableTips"]),
"hbRainIcon": new HbRainIcon("hbRainIcon", this["hbRainGroup"], this["hbRainBtn"]),
};
this.actIcon = new ActIcon(this['actsShowBtn'], this['actIconsGroup']);
this.actIcon.addActIcon("hbRainIcon", new HbRainIcon("hbRainIcon", this["hbRainGroup"], this["hbRainBtn"]));
}
private removeIcon() {
for(let k in this.icons) {
this.icons[k].destory();
}
this.icons = {};
}
updateMyInfo() {
......@@ -311,20 +340,20 @@ export default class MapScene extends Scene {
this['nameTxt'].text = '';
// NetManager.ins.hc_userInfo(() => {
this['avatar'].visible = true;
const { data } = DataManager.ins.getData('hc_userInfo');
if (data)
const {data} = DataManager.ins.getData('hc_userInfo');
if(data)
this['avatar'].source = data.avatar || "http://yun.duiba.com.cn/db_games/default_avatar.png";
else
this['avatar'].source = "http://yun.duiba.com.cn/db_games/default_avatar.png";
if (data && data.nickname)
if(data && data.nickname)
this['nameTxt'].text = getNick(data.nickname);
// });
}
updateSign() {
const { signInfoVO } = DataManager.ins.getData('getSignInfo');
if (signInfoVO.continueDay < 7) { //表示明天还可以签到
const {signInfoVO} = DataManager.ins.getData('getSignInfo');
if(signInfoVO.continueDay < 7) { //表示明天还可以签到
this['sign_s1'].visible = signInfoVO.todaySigned == 0;
this['sign_s2'].visible = !this['sign_s1'].visible;
} else {
......@@ -334,17 +363,17 @@ export default class MapScene extends Scene {
updateAdData() {
const hc_advert = DataManager.ins.getData('hc_advert').data || {};
let { mapAdvert } = hc_advert;
if (mapAdvert == null)
mapAdvert = { enable: false, advertList: [] }
let {mapAdvert} = hc_advert;
if(mapAdvert == null)
mapAdvert = {enable: false, advertList: []}
this['adBtn'].visible = mapAdvert.enable;
if (this['adBtn'].visible) {
if(this['adBtn'].visible) {
NetManager.ins.showLog(getlogItem(32));
}
if (mapAdvert.enable) {
if(mapAdvert.enable) {
let result;
result = mapAdvert.advertList;
if (Array.isArray(mapAdvert.advertList)) {
if(Array.isArray(mapAdvert.advertList)) {
const index = Math.floor(mapAdvert.advertList.length * Math.random());
result = mapAdvert.advertList[index];
}
......@@ -358,10 +387,14 @@ export default class MapScene extends Scene {
destroy() {
super.destroy();
if (this['pic'])
this.removeIcon();
this.actIcon.destory();
if(this['pic'])
egret.Tween.removeTweens(this['pic']);
if (this.inviteTimer) {
if(this.inviteTimer) {
this.inviteTimer.stop();
this.inviteTimer.removeEventListener(egret.TimerEvent.TIMER, this.inviteCutTimer, this);
}
......@@ -369,18 +402,18 @@ export default class MapScene extends Scene {
this.scroll.removeEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this);
this._avatarsCache.forEach((item) => {
if (item.parent) item.parent.removeChild(item);
if(item.parent) item.parent.removeChild(item);
});
this._avatarsCache = null;
}
getScrollV(lastOrder, stageHeight) {
// lastOrder = 69;
if (lastOrder <= 7) {//顶部的1-7关
if(lastOrder <= 7) {//顶部的1-7关
return this.getScrollV1(lastOrder, stageHeight);
}
if (lastOrder >= window['total_level'] - 10) {//底部的60-70关 70-10
if(lastOrder >= window['total_level'] - 10) {//底部的60-70关 70-10
return this.getScrollV2(lastOrder, stageHeight);
}
//中部的4个循环*13 8~59
......@@ -391,7 +424,7 @@ export default class MapScene extends Scene {
const ylist = [26, 158, 302, 435, 547, 674, 821, 897, 969, 1072, 1137, 1254, 1367];
const y0 = this._data.top.height;//顶部的高度
let a0 = (lastOrder - MapTopPart.LEVEL_NUMS) % MapRpeatPart.LEVEL_NUMS; //减去7后的order 8-7 = 1
if (a0 == 0) a0 = MapRpeatPart.LEVEL_NUMS
if(a0 == 0) a0 = MapRpeatPart.LEVEL_NUMS
const a1 = Math.ceil((lastOrder - MapTopPart.LEVEL_NUMS) / MapRpeatPart.LEVEL_NUMS) - 1;//当前地图repeat的顺序
const y1 = ylist[a0 - 1];
const y2 = y0 + y1 + a1 * this._data.list[0].height;
......@@ -401,7 +434,7 @@ export default class MapScene extends Scene {
getScrollV1(lastOrder, stageHeight) {
const ylist = [492, 550.35, 744, 803, 810, 975, 1089.69].map(i => i + 40);
const targetY = ylist[lastOrder - 1] - stageHeight / 2;
if (targetY <= 0) return 0
if(targetY <= 0) return 0
return targetY;
}
......@@ -413,7 +446,7 @@ export default class MapScene extends Scene {
+ this._data.bottom.height;
const ylist = [44, 148.44, 331, 403, 513, 660, 829.69, 949.69, 1052.69, 1148.69, 1209.69].map(i => i + 40);
const targetY = y0 + ylist[lastOrder - 1] - stageHeight / 2;
if (targetY >= (totalHeight - stageHeight)) return totalHeight - stageHeight
if(targetY >= (totalHeight - stageHeight)) return totalHeight - stageHeight
return targetY;
}
......@@ -435,7 +468,7 @@ export default class MapScene extends Scene {
updateBox() {
const homeData = getHomeData();
if (homeData.canReceiveTreasureBoxNum <= 0)
if(homeData.canReceiveTreasureBoxNum <= 0)
setGray(this['box']);
this['boxiconWrapper'].visible = homeData.canReceiveTreasureBoxNum > 0;
this['totalStarTxt'].text = `${homeData.totalStars}/${homeData.nextRangeStarsNum}`;
......@@ -449,6 +482,7 @@ export default class MapScene extends Scene {
}
private _avatarsCache = [];
addAvatar(level, ele?) {
const item = MapScene.iconHash[level];
const parent = item['mappart'];
......@@ -458,7 +492,7 @@ export default class MapScene extends Scene {
parent.addChild(avatar);
avatar.x = item.x + 10;
avatar.y = item.y - avatar.height - 30;
if (!MapScene.starHash[level].visible) {
if(!MapScene.starHash[level].visible) {
avatar.y = item.y - avatar.height;
}
this._avatarsCache.push(avatar);
......@@ -467,11 +501,11 @@ export default class MapScene extends Scene {
updateFriends() {
NetManager.ins.hc_mapRank(() => {
const hc_mapRank = DataManager.ins.getData('hc_mapRank').data;
if (!hc_mapRank) return;
const { data } = DataManager.ins.getData('hc_userInfo');
if(!hc_mapRank) return;
const {data} = DataManager.ins.getData('hc_userInfo');
hc_mapRank.forEach((ele) => {
if (ele.levelNum == getHomeData().levels.length + 1) {
if (data == null)
if(ele.levelNum == getHomeData().levels.length + 1) {
if(data == null)
ele.rank[0].avatar = "http://yun.duiba.com.cn/db_games/default_avatar.png";
else
ele.rank[0].avatar = data.avatar || "http://yun.duiba.com.cn/db_games/default_avatar.png";
......@@ -486,24 +520,24 @@ export default class MapScene extends Scene {
this['goldTxt'].text = `${homeData.wealth}`;
for (let j = 1; j < window['total_level']; j++) {
for(let j = 1; j < window['total_level']; j++) {
this.disableIcon(j + 1);
}
for (let i = 0; i < homeData.levels.length; i++) {
for(let i = 0; i < homeData.levels.length; i++) {
const level = homeData.levels[i];
const star = MapScene.starHash[i + 1];
if (level) {
if(level) {
star.setStar(level.stars);
this.enableIcon(level.levelNum);
} else {
this.disableIcon(level.levelNum);
}
}
if (homeData.levels.length == 0) {
if(homeData.levels.length == 0) {
const star = MapScene.starHash[1];
star.setStar(0);
this.enableIcon(1);
} else if (homeData.levels.length == window['last_level']) {
} else if(homeData.levels.length == window['last_level']) {
} else {
const star = MapScene.starHash[homeData.levels.length + 1];
......@@ -517,11 +551,11 @@ export default class MapScene extends Scene {
updateTimerView() {
//更新倒计时
if (this._countDown == null) {
if(this._countDown == null) {
this._countDown = new CountDown(this['countdown']);
}
const data = getHomeData();
if (data.remainEnargy >= BLOOD_NUMS_MAX) { //满了
if(data.remainEnargy >= BLOOD_NUMS_MAX) { //满了
this._countDown.stop();
this['fullTxt'].visible = true;
......@@ -539,48 +573,41 @@ export default class MapScene extends Scene {
PanelCtrl.instance.show('task');
}
onTap_actsShowBtn() {
this['actIconsGroup'].visible = !this['actIconsGroup'].visible;
this['actIconsGroup'].x = 12.12;
if (this['actIconsGroup'].visible == false) {
this['actIconsGroup'].x = -999;
}
}
onTap_guide() {
this['guide'].visible = false;
localStorage.setItem('activityguide', '1');
}
onTap_act2btn() {
PanelCtrl.instance.show("BombTipsPanel");
this.onTap_actsShowBtn();
GDispatcher.dispatchEvent('closeActBtn');
}
onTap_inviteBtn() {
NetManager.ins.clickLog(getlogItem(33));
NetManager.ins.getInviteInfo((success, res) => {
if (!success || !res.data) {
if(!success || !res.data) {
return;
}
const flag = res.data.completeFlag;
switch (true) {
switch(true) {
case (flag == 0): // 未完成
this.loadsvga(res);
break;
case (flag == 1): // 完成未开奖 待领奖 请求领奖接口
try {
if (window['getRST']) window['getRST']();
} catch (error) {
if(window['getRST']) window['getRST']();
} catch(error) {
console.warn(error)
}
NetManager.ins.acceptInvitationPrize((success, res) => {
if (!success) {
if(!success) {
showToast("哎呀,萌狮开小差啦!\n过会再来看吧!");
GDispatcher.dispatchEvent("getInviteInfo");
return;
}
// console.log(res.data);
if (res.data.completeFlag == 3) {
if(res.data.completeFlag == 3) {
showToast("哎呀,萌狮开小差啦!\n过会再来看吧!");
GDispatcher.dispatchEvent("getInviteInfo");
} else {
......@@ -595,7 +622,7 @@ export default class MapScene extends Scene {
case (flag == 4): // 可以开启下一次发任务
NetManager.ins.acceptInvitationInfo((success, res) => {
if (!success) {
if(!success) {
return;
}
this.loadsvga(res);
......@@ -611,7 +638,7 @@ export default class MapScene extends Scene {
}
loadsvga(res) {
if (MapScene['svga']) {
if(MapScene['svga']) {
const mv = MapScene['svga']
mv.gotoAndStop(1);
res.data.svga = mv;
......@@ -636,20 +663,20 @@ export default class MapScene extends Scene {
*/
getInviteInfo() {
const hc_advert = DataManager.ins.getData('hc_advert').data || {};
const { mapAdvert } = hc_advert;
const {mapAdvert} = hc_advert;
// tslint:disable-next-line: cyclomatic-complexity
NetManager.ins.getInviteInfo((success, res) => {
if (!success || !res.data) {
if(!success || !res.data) {
return;
}
const flag = res.data.completeFlag;
if (this.inviteTimer) {
if(this.inviteTimer) {
this.inviteTimer.stop();
}
switch (true) {
switch(true) {
case (flag == 0): // 未完成 显示倒计时
this["inviteGroup"].visible = true;
if (!mapAdvert || mapAdvert.enable == false) {
if(!mapAdvert || mapAdvert.enable == false) {
this['activitys'].y = 458;
this['guideInner'].y = 185;
}
......@@ -665,7 +692,7 @@ export default class MapScene extends Scene {
case (flag == 1): // 完成未开奖 待领奖 显示待领奖
NetManager.ins.showLog(getlogItem(33));
this["inviteGroup"].visible = true;
if (!mapAdvert || mapAdvert.enable == false) {
if(!mapAdvert || mapAdvert.enable == false) {
this['activitys'].y = 458;
this['guideInner'].y = 185;
}
......@@ -676,7 +703,7 @@ export default class MapScene extends Scene {
case (flag == 2): // 领奖成功 无角标
case (flag == 3): // 领奖失败 无角标
this["inviteGroup"].visible = true;
if (!mapAdvert || mapAdvert.enable == false) {
if(!mapAdvert || mapAdvert.enable == false) {
this['activitys'].y = 458;
this['guideInner'].y = 185;
}
......@@ -686,7 +713,7 @@ export default class MapScene extends Scene {
break;
case (flag == 4): // 可以开启下一次发任务 显示立即到账
this["inviteGroup"].visible = true;
if (!mapAdvert || mapAdvert.enable == false) {
if(!mapAdvert || mapAdvert.enable == false) {
this['activitys'].y = 458;
this['guideInner'].y = 185;
}
......@@ -697,7 +724,7 @@ export default class MapScene extends Scene {
break;
case (flag == 5): // 等待开启下一次发任务 无角标
this["inviteGroup"].visible = true;
if (!mapAdvert || mapAdvert.enable == false) {
if(!mapAdvert || mapAdvert.enable == false) {
this['activitys'].y = 458;
this['guideInner'].y = 185;
}
......@@ -708,7 +735,7 @@ export default class MapScene extends Scene {
case (flag == 6): // 无入口
this["inviteGroup"].visible = false;
this['adBtn'].y = 323.76;
if (mapAdvert && mapAdvert.enable) {
if(mapAdvert && mapAdvert.enable) {
this['guideInner'].y = 185;
this['activitys'].y = 458;
} else {
......@@ -726,7 +753,7 @@ export default class MapScene extends Scene {
// 倒计时
private inviteCutTimer() {
const timer = this.convertTime(this.cutTime -= 1000);
if (timer.hour === "00"
if(timer.hour === "00"
&& timer.min === "00"
&& timer.sec === "00") {
this.inviteTimer.stop();
......@@ -768,7 +795,6 @@ export default class MapScene extends Scene {
// this['goldBtn'].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_goldBtn, this)
this['guide'].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_guide, this);
this['act2Btn'].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_act2btn, this);
this['actsShowBtn'].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_actsShowBtn, this);
this['inviteBtn'].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_inviteBtn, this);
this['friendBtn'].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_friendBtn, this)
this['adBtn'].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_adBtn, this)
......@@ -790,8 +816,6 @@ export default class MapScene extends Scene {
// 消消乐查询信息
GDispatcher.addEvent('getInviteInfo', this.getInviteInfo, this);
GDispatcher.addEvent('closeActBtn', this.onTap_actsShowBtn, this);
}
initSound() {
......@@ -818,9 +842,9 @@ export default class MapScene extends Scene {
async onTap_boxLayer() {
NetManager.ins.clickLog(getlogItem(1));
const data = getHomeData();
if (data.canReceiveTreasureBoxNum > 0) {
if(data.canReceiveTreasureBoxNum > 0) {
this['boxLayer'].visible = true;
if (!this._mc)
if(!this._mc)
this._mc = await loadSvga(getResPath() + 'resource/assets/svgas/box.svga', this['boxani']);
this._mc.stop();
this._mc.gotoAndStop(1);
......@@ -832,18 +856,18 @@ export default class MapScene extends Scene {
await wait(50);
this._mc.visible = true;
const a = 100, b = 10;
egret.Tween.get(this._mc, { loop: true }).set({ rotation: b })
.to({ rotation: -b }, a).to({ rotation: b }, a)
.to({ rotation: -b }, a).to({ rotation: b }, a)
.to({ rotation: -b }, a).to({ rotation: b }, a)
.to({ rotation: 0 }, a / 2)
egret.Tween.get(this._mc, {loop: true}).set({rotation: b})
.to({rotation: -b}, a).to({rotation: b}, a)
.to({rotation: -b}, a).to({rotation: b}, a)
.to({rotation: -b}, a).to({rotation: b}, a)
.to({rotation: 0}, a / 2)
.wait(1000);
}
}
async playAni() {
if (this._mc) {
if(this._mc) {
egret.Tween.removeTweens(this._mc);
this._mc.gotoAndPlay(1, true);
await this.onPlaySTOP();
......@@ -854,7 +878,7 @@ export default class MapScene extends Scene {
async onPlaySTOP() {
return new Promise((r) => {
const func = () => {
if (this._mc.currentFrame >= 100) {
if(this._mc.currentFrame >= 100) {
this._mc.removeEventListener(egret.Event.ENTER_FRAME, func, this);
this._mc.stop();
r();
......@@ -873,14 +897,14 @@ export default class MapScene extends Scene {
this['boxani'].touchChildren = false;
await this.playAni();
try {
if (window['getRST']) window['getRST']();
} catch (error) {
if(window['getRST']) window['getRST']();
} catch(error) {
console.warn(error)
}
NetManager.ins.hc_openTreasureBox((success) => {
this['boxani'].touchEnabled = true;
this['boxani'].touchChildren = true;
if (success) {
if(success) {
const hc_openTreasureBox = DataManager.ins.getData('hc_openTreasureBox');
const boxdata = hc_openTreasureBox.data;
const homeData = DataManager.ins.getData('hc_home').data;
......@@ -890,7 +914,7 @@ export default class MapScene extends Scene {
homeData.isGetAllTreasureBox = boxdata.isGetAllTreasureBox;
this.updateBox();
if (hc_openTreasureBox.success && boxdata && boxdata.option) {
if(hc_openTreasureBox.success && boxdata && boxdata.option) {
PanelCtrl.instance.show('box');
} else {
......@@ -924,7 +948,7 @@ export default class MapScene extends Scene {
onTap_bloodBtn() {
NetManager.ins.clickLog(getlogItem(2));
if (getHomeData().remainEnargy > 0)
if(getHomeData().remainEnargy > 0)
PanelCtrl.instance.show('bloodPanel')
else
PanelCtrl.instance.show('blood2Panel')
......@@ -949,14 +973,14 @@ export default class MapScene extends Scene {
showRedBagAni() {
const hash = MapScene.iconHash;
const keys = [];
for (const key in hash) {
for(const key in hash) {
const ele = hash[key];
if (ele.parent)
if(ele.parent)
keys.push(key);
}
const p0 = new egret.Point(750 / 2, 750 / 1.5);
const pics = [];
for (const key of keys) {
for(const key of keys) {
const icon = MapScene.iconHash[key] as egret.DisplayObject;
const p = (icon.localToGlobal(0, 0));
const pic = createRedBagIcon(this);
......@@ -973,7 +997,7 @@ export default class MapScene extends Scene {
pic.visible = true;
const p2 = pic['__p2__'] as egret.Point;
let dir = 100;
if (p2.y < p0.y)
if(p2.y < p0.y)
dir *= -1;
const p1x = (p0.x + p2.x) / 2 + dir;
const p1y = (p0.y + p2.y) / 2;
......@@ -981,13 +1005,16 @@ export default class MapScene extends Scene {
new RedBagAni(p0, p1, p2, pic, () => {
const mc = createEffect2MovieClip(p2.x, p2.y);
this.addChild(mc);
const x0=pic['__icon__'].x;const y0=pic['__icon__'].y;
egret.Tween.get(pic['__icon__']).to({y:y0+10},100).to({y:y0},100);
const light =new egret.Bitmap( RES.getRes('maplight2_png'));
light.anchorOffsetX=75;light.anchorOffsetY=49;
light.x=50;light.y=40+5;
pic['__icon__'].addChildAt(light,0);
egret.Tween.get(light).to({scaleX:1.5,scaleY:1.5,},200).call(()=>{
const x0 = pic['__icon__'].x;
const y0 = pic['__icon__'].y;
egret.Tween.get(pic['__icon__']).to({y: y0 + 10}, 100).to({y: y0}, 100);
const light = new egret.Bitmap(RES.getRes('maplight2_png'));
light.anchorOffsetX = 75;
light.anchorOffsetY = 49;
light.x = 50;
light.y = 40 + 5;
pic['__icon__'].addChildAt(light, 0);
egret.Tween.get(light).to({scaleX: 1.5, scaleY: 1.5,}, 200).call(() => {
pic['__icon__'].removeChild(light);
});
......@@ -997,9 +1024,9 @@ export default class MapScene extends Scene {
}
}
export const getNick = (nickname, max = 4) => {
if (!nickname) return nickname;
if(!nickname) return nickname;
if (nickname.length > max)
if(nickname.length > max)
return nickname.slice(0, max) + '...';
return nickname;
}
\ No newline at end of file
import { GDispatcher } from "../../../libs/tc/util/GDispatcher";
import IconBase from "./IconBase";
export default class ActIcon {
private actIconsGroup;
private actsShowBtn;
private icons = {};
constructor(actsShowBtn, actIconGroup) {
this.actsShowBtn = actsShowBtn;
this.actIconsGroup = actIconGroup;
this.initUI();
this.initEvents();
}
public addActIcon(name: string, actIcon: IconBase) {
this.icons[name] = actIcon;
}
public removeActIcon(name:string){
if(this.icons[name]){
this.icons[name].destory();
delete this.icons[name];
}
}
public destory() {
for(let k in this.icons){
this.removeActIcon(this.icons[k]);
}
this.removeEvents();
}
private initUI() {
this.actIconsGroup.x = -999;
}
private updateActIcon(){
for(let k in this.icons){
if(this.icons[k].visible){
this.visible = true;
return;
}
}
this.visible = false;
}
public set visible(visible:boolean){
this.actsShowBtn.visible = visible;
this.actIconsGroup.visible = visible;
}
private onTap_actsShowBtn() {
this.actIconsGroup.visible = !this.actIconsGroup.visible;
this.actIconsGroup.x = 12.12;
if(this.actIconsGroup.visible == false) {
this.actIconsGroup.x = -999;
}
}
private initEvents() {
this.actsShowBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_actsShowBtn, this);
GDispatcher.addEvent('closeActBtn', this.onTap_actsShowBtn, this);
GDispatcher.addEvent('updateActIcon', this.updateActIcon, this);
}
private removeEvents() {
this.actsShowBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_actsShowBtn, this);
GDispatcher.removeEvent('closeActBtn', this.onTap_actsShowBtn, this);
GDispatcher.removeEvent('updateActIcon', this.updateActIcon, this);
}
}
\ No newline at end of file
......@@ -2,7 +2,6 @@ import IconBase from "./IconBase";
import PanelCtrl from "../../../libs/new_wx/ctrls/panelCtrl";
import { GDispatcher } from "../../../libs/tc/util/GDispatcher";
import { NetManager } from "../../../libs/tw/manager/NetManager";
import CutTimer from "../../CutTimer";
export default class HbRainIcon extends IconBase {
......@@ -56,7 +55,7 @@ export default class HbRainIcon extends IconBase {
GDispatcher.removeEvent('updateHbRainIcon', this.updateIcon, this);
}
protected destory() {
public destory() {
super.destory();
}
......
import { GDispatcher } from "../../../libs/tc/util/GDispatcher";
/**
* 地图页图标基类
* Created on 2019/10/25
......@@ -48,6 +50,11 @@ export default class IconBase {
this.iconBtn.visible = visible;
// this.iconTipsBg.visible = visible;
// this.iconTips.visible = visible;
GDispatcher.dispatchEvent('updateActIcon');
}
public get visible():boolean{
return this.iconGroup.visible;
}
public get position(): { x, y } {
......@@ -95,7 +102,7 @@ export default class IconBase {
this.iconBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchBtn, this);
}
protected destory() {
public destory() {
this.removeEvents();
}
......
......@@ -118,7 +118,7 @@ export default class ScratchIcon extends IconBase {
super.removeEvents();
}
protected destory() {
public destory() {
super.destory();
}
......
......@@ -61,7 +61,7 @@ export default class TurntableIcon extends IconBase {
GDispatcher.removeEvent('updateTurntableIcon', this.updateIcon, this);
}
protected destory() {
public destory() {
super.destory();
}
......
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