Commit f09b2dae authored by zjz1994's avatar zjz1994

地图优化暂存

parent 41b020e6
......@@ -137,7 +137,7 @@
window['imgver'] = '11112';
//top 8 ,repeat 22 , bottom 3
window['total_level'] = 8 + 3 + 22 * 33;
window['last_level'] = 725;
window['last_level'] = 737;
var sharePic = document.getElementById('pic');
sharePic.onclick = function () {
......
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="StarSkin" width="76" height="31" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Image source="无星星_png" horizontalCenter="0" verticalCenter="0"/>
<e:Image source="无星星_png" horizontalCenter="0" verticalCenter="0" touchEnabled="false"/>
<e:Image id="star1" source="有星星_png" horizontalCenter="0" verticalCenter="0" visible="false"/>
<e:Image id="star2" source="有星星2_png" horizontalCenter="0" verticalCenter="0" visible="false"/>
<e:Image id="star3" source="有星星3_png" horizontalCenter="0" verticalCenter="0" visible="false"/>
......
......@@ -17,12 +17,13 @@ export default class MapBottomPart extends ComponentBase {
const star = new MapStarComp();
star.loadSkin(); star.start();
const icon = this.getIcon(i);
icon.addChild(star);
icon.show = ()=>{icon.visible = true;};
icon.hide = ()=>{icon.visible = false;};
icon['nums'] = icon.getChildAt(0);
icon['bmptxt']=icon.getChildAt(1);
icon.addChildAt(star,0);
icon['starsp'] = star;
icon.touchEnabled = true;
......
......@@ -22,12 +22,14 @@ export default class MapRpeatPart extends ComponentBase {
const star = new MapStarComp();
star.loadSkin(); star.start();
const icon = this.getIcon(i);
icon.addChild(star);
icon.show = ()=>{icon.visible = true;};
icon.hide = ()=>{icon.visible = false;};
icon['nums'] = icon.getChildAt(0);
icon['bmptxt']=icon.getChildAt(1);
icon.addChildAt(star,0);
icon['starsp'] = star;
// icon.hide();
......
......@@ -256,8 +256,9 @@ export default class MapScene extends Scene {
//进度条文本发光
setGlow(this['totalStarTxt'], 0x0083e8, 1);
//下一个挑战关卡,水花动效
this.creatPic();
//新地图创建
console.log("新添加地图");
var total_level = window['total_level'];
var maptop_level = MapTopPart.LEVEL_NUMS;
var maprep_level = MapRpeatPart.LEVEL_NUMS;
......@@ -268,7 +269,7 @@ export default class MapScene extends Scene {
var mapbot_height = this.mapbotpart.height||528;
var repeatnum = Math.abs((total_level-maptop_level-mapbot_level)/maprep_level)
console.log("中间maprepeat数量",repeatnum);
// console.log("中间maprepeat数量",repeatnum);
this.scrollMapy.push(0);
this.scrollMapy.push(maptop_height);
var smaph = maptop_height;
......@@ -279,26 +280,36 @@ export default class MapScene extends Scene {
this.scrollMapy.push(smaph+mapbot_height);
var scrollheight = maptop_height+repeatnum*maprep_height+mapbot_height;
console.log("scroll--------height",scrollheight,this.scrollMapy);
// console.log("scroll--------height",scrollheight,this.scrollMapy);
this.scrollGroup.height = scrollheight;
var nowlevel = getHomeData().levels.length;
console.log("玩家level",nowlevel);
// console.log("玩家level",nowlevel);
this.maptoppart.y = this.scrollMapy[0];
this.scrollGroup.addChild(this.maptoppart);
this.onemapreppart.y = 0;//this.scrollMapy[1];
this.onemapreppart.y = this.scrollMapy[1];
this.scrollGroup.addChild(this.onemapreppart);
this.twomapreppart.y = 0;//this.scrollMapy[2];
this.twomapreppart.y = this.scrollMapy[2];
this.scrollGroup.addChild(this.twomapreppart);
this.mapbotpart.y = this.scrollMapy[this.scrollMapy.length-2];
console.log('底部位置',this.mapbotpart.y);
// console.log('底部位置',this.mapbotpart.y);
this.scrollGroup.addChild(this.mapbotpart);
//设置顶部和底部关卡显示
this.changePartLevelShow(this.maptoppart,0,"top");
this.changePartLevelShow(this.onemapreppart,MapTopPart.LEVEL_NUMS,'mid');
this.changePartLevelShow(this.twomapreppart,MapTopPart.LEVEL_NUMS+MapRpeatPart.LEVEL_NUMS,'mid');
var botlevelstart = maptop_level+repeatnum*maprep_level;
this.changePartLevelShow(this.mapbotpart,botlevelstart,"bot");
const homeData = getHomeData();
//关于滚动,可以仅在第一次打开时自动滚到到最新位置,其余情况不动
let lastOrder = homeData.levels.length + 1;
if (homeData.levels.length >= window['total_level'])
lastOrder = window['total_level'];
this.scroll.viewport.scrollV = this.getScrollV(lastOrder, this.stage.stageHeight);
console.log("滚动设置",lastOrder,this.scroll.viewport.scrollV);
this.setScrollVShow();
// console.log('地图数据-----',this._data);
// this.topPart = this._data.top;
// this.repeatsPart = this._data.list;
......@@ -313,8 +324,7 @@ export default class MapScene extends Scene {
// this.scrollGroup.addChild(this._data.bottom);
// this._data.bottom.y = this._data.top.height + (this._data.list.length * this._data.list[0].height);
//下一个挑战关卡,水花动效
this.creatPic();
setTimeout(() => {
......@@ -544,32 +554,32 @@ export default class MapScene extends Scene {
// this.scrollGroup.addChild(data.bottom);
// data.bottom.y = data.top.height + (data.list.length * data.list[0].height);
let target;
// let target;
const homeData = getHomeData();
if (homeData.levels.length == 0) {
target = 1;
} 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) {
const levelOrder = parseInt(key);
const element = MapScene.iconHash[key];
if (!element.hasEventListener(egret.TouchEvent.TOUCH_TAP)) {
element.addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
if (
(levelOrder > (getHomeData().levels.length + 1) && levelOrder > 1)
|| (levelOrder > window['last_level'])
) {
// showToast('必须通关前面的关卡才能开启本关');
console.log('必须通关前面的关卡才能开启本关');
} else
PanelCtrl.instance.show('StartPanel', key);
NetManager.ins.clickLog(getlogItem(19));
}, this);
}
}
// if (homeData.levels.length == 0) {
// target = 1;
// } 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) {
// const levelOrder = parseInt(key);
// const element = MapScene.iconHash[key];
// if (!element.hasEventListener(egret.TouchEvent.TOUCH_TAP)) {
// element.addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
// if (
// (levelOrder > (getHomeData().levels.length + 1) && levelOrder > 1)
// || (levelOrder > window['last_level'])
// ) {
// // showToast('必须通关前面的关卡才能开启本关');
// console.log('必须通关前面的关卡才能开启本关');
// } else
// PanelCtrl.instance.show('StartPanel', key);
// NetManager.ins.clickLog(getlogItem(19));
// }, this);
// }
// }
// 当前关卡的水花动效
// console.log(homeData.levels,window['last_level'],target);
......@@ -617,12 +627,12 @@ export default class MapScene extends Scene {
}
}, this);
//关于滚动,可以仅在第一次打开时自动滚到到最新位置,其余情况不动
let lastOrder = homeData.levels.length + 1;
if (homeData.levels.length >= window['total_level'])
lastOrder = window['total_level'];
this.scroll.viewport.scrollV = this.getScrollV(lastOrder, this.stage.stageHeight);
this.setScrollVShow();
// //关于滚动,可以仅在第一次打开时自动滚到到最新位置,其余情况不动
// let lastOrder = homeData.levels.length + 1;
// if (homeData.levels.length >= window['total_level'])
// lastOrder = window['total_level'];
// this.scroll.viewport.scrollV = this.getScrollV(lastOrder, this.stage.stageHeight);
// this.setScrollVShow();
// console.warn(this.getScrollV(lastOrder, this.stage.stageHeight));
// setTimeout(() => {
......@@ -784,7 +794,7 @@ export default class MapScene extends Scene {
if(i3map.y!=i3mapy){
i3map.y = i3mapy;
var i3startlevel = MapTopPart.LEVEL_NUMS+(i3-1)*MapRpeatPart.LEVEL_NUMS;
console.log("局部显示",i3,i3mapy,i3startlevel,lidx,nidx);
// console.log("局部显示",i3,i3mapy,i3startlevel,lidx,nidx);
this.changePartLevelShow(i3map,i3startlevel,"mid");
}
......@@ -809,14 +819,14 @@ export default class MapScene extends Scene {
}else if(mappartype=="bot"){
mapnums = MapBottomPart.LEVEL_NUMS;
}
console.log("修改类型",mappartype,startlevel,mappart);
// console.log("修改类型",mappartype,startlevel,mappart);
var last_level = window['last_level'];
var homeData = getHomeData();
for(var i=0;i<mapnums;i++){
const levelOrder = startlevel + i + 1;
let icon = mappart.getIcon(i);
let havewater_light = icon.getChildByName('water_light');
icon.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.showToastQd);
icon.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.showToastQd,this);
mappart.getTxt(i).text = levelOrder + '';
if(levelOrder>last_level){
if(havewater_light){
......@@ -835,7 +845,7 @@ export default class MapScene extends Scene {
}
icon.filters = null;
var leveldata = homeData.levels[levelOrder-1];
console.log("关卡测试:"+levelOrder);
// console.log("关卡测试:"+levelOrder);
(icon['nums'] as eui.Image).source = 'icon_png';
(icon['bmptxt'] as eui.BitmapLabel).visible = true;
(icon['bmptxt'] as eui.BitmapLabel).font = 'nums_fnt';
......@@ -849,9 +859,10 @@ export default class MapScene extends Scene {
(icon['starsp'] as MapStarComp).setStar(0);
(icon['starsp'] as MapStarComp).visible = true;
if(!havewater_light){
console.log(icon,this.pic);
this.pic.x = 50;
this.pic.y = 37+7;
icon.addChild(this.pic);
icon.addChildAt(this.pic,1);
egret.Tween.removeTweens(this.pic);
egret.Tween.get(this.pic, { loop: true })
......@@ -878,12 +889,47 @@ export default class MapScene extends Scene {
}
}
}
//用户关卡数据更新,更行map
freshMapShow(){
console.log("刷新显示");
var topltxt = this.maptoppart.getIcon(0)['bmptxt'] as eui.BitmapLabel;
var onepltxt = this.onemapreppart.getIcon(0)['bmptxt'] as eui.BitmapLabel;
var twopltxt = this.twomapreppart.getIcon(0)['bmptxt'] as eui.BitmapLabel;
var botltxt = this.mapbotpart.getIcon(0)['bmptxt'] as eui.BitmapLabel;
if(topltxt){
var toplevel = Number(topltxt.text)-1;
this.changePartLevelShow(this.maptoppart,toplevel,"top");
}
if(onepltxt){
var oneplevel = Number(onepltxt.text)-1;
this.changePartLevelShow(this.onemapreppart,oneplevel,"mid");
}
if(twopltxt){
var twoplevel = Number(twopltxt.text)-1;
this.changePartLevelShow(this.twomapreppart,twoplevel,"mid");
}
if(botltxt){
var botlevel = Number(botltxt.text)-1;
this.changePartLevelShow(this.mapbotpart,botlevel,"bot");
}
}
//点击
clickIcon(e){
console.log(e);
let icon = e.target as eui.Group;
let txt = icon['bmptxt'] as eui.BitmapLabel;
console.log('关卡点击',txt.text);
if(e.target.name!='water_light'){
let icon = e.target as eui.Group;
let txt = icon['bmptxt'] as eui.BitmapLabel;
console.log('关卡点击',txt.text);
var homeData = getHomeData();
var clicklevel = Number(txt.text);
if(clicklevel<=homeData.levels.length+1){//可进行关卡
PanelCtrl.instance.show('StartPanel', clicklevel);
NetManager.ins.clickLog(getlogItem(19));
}else{
console.log('必须通关前面的关卡才能开启本关');
}
}
}
showToastQd(){
showToast('敬请期待更多关卡~');
......@@ -1012,12 +1058,12 @@ export default class MapScene extends Scene {
// 中间重复的
getScrollV3(lastOrder, stageHeight) {
const ylist = [4, 55, 160, 315, 431, 529, 594, 714, 820, 900, 970, 1098, 1164, 1245, 1380, 1493, 1548, 1611, 1734, 1882, 2023, 2180];
const y0 = this._data.top.height;//顶部的高度
const y0 = 1275;//顶部的高度
let a0 = (lastOrder - MapTopPart.LEVEL_NUMS) % MapRpeatPart.LEVEL_NUMS; //减去7后的order 8-7 = 1
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;
const y2 = y0 + y1 + a1 * 2297;
return y2 - stageHeight / 2;
}
......@@ -1031,59 +1077,76 @@ export default class MapScene extends Scene {
// 尾部
getScrollV2(lastOrder, stageHeight) {
const y0 = this._data.bottom.y;
lastOrder = lastOrder - this._data.list.length * MapRpeatPart.LEVEL_NUMS - 7;
var total_level = window['total_level'];
var maptop_level = MapTopPart.LEVEL_NUMS;
var maprep_level = MapRpeatPart.LEVEL_NUMS;
var mapbot_level = MapBottomPart.LEVEL_NUMS;
var repeatnum = Math.abs((total_level-maptop_level-mapbot_level)/maprep_level)
const y0 = this.mapbotpart.y;
console.log("底部scroll",y0)
lastOrder = lastOrder - repeatnum * MapRpeatPart.LEVEL_NUMS - 7;
if(lastOrder<1){
lastOrder = 1;
}else if(lastOrder>3){
lastOrder = 3;
}
const totalHeight = this._data.top.height +
(this._data.list.length * this._data.list[0].height)
+ this._data.bottom.height;
console.log("底部scroll",lastOrder);
var maptop_height = 1275;
var maprep_height = 2297;
var mapbot_height = 528;
const totalHeight = maptop_height +
(repeatnum * maprep_height)
+ mapbot_height;
const ylist = [62, 176, 314].map(i => i + 40);
const targetY = y0 + ylist[lastOrder - 1] - stageHeight / 2;
console.log("底部scroll",targetY,totalHeight,stageHeight,repeatnum);
if (targetY >= (totalHeight - stageHeight)) return totalHeight - stageHeight;
return targetY;
}
// 设置关卡图标为未开启
disableIcon(level) {
return;
this.setGray(level);
MapScene.starHash[level].visible = false;
}
// disableIcon(level) {
// return;
// this.setGray(level);
// MapScene.starHash[level].visible = false;
// }
// 设置关卡图标为已开启
enableIcon(level) {
return;
this.resetGray(level);
MapScene.starHash[level].visible = true;
}
// enableIcon(level) {
// return;
// this.resetGray(level);
// MapScene.starHash[level].visible = true;
// }
// 设置关卡图标为当前关卡
nowIcon(level) {
return;
const icon = MapScene.iconHash[level];
(icon['nums'] as eui.Image).source = 'iconnow_png';
(icon['bmptxt'] as eui.BitmapLabel).visible = true;
(icon['bmptxt'] as eui.BitmapLabel).font = 'nums3_fnt';
MapScene.starHash[level].visible = true;
}
setGray(order: number) {
return;
const icon = MapScene.iconHash[order];
(icon['nums'] as eui.Image).source = 'icongray_png';
(icon['bmptxt'] as eui.BitmapLabel).visible = false;
// (icon['bmptxt'] as eui.BitmapLabel).font = 'nums3_fnt';
}
resetGray(order: number) {
return;
const icon = MapScene.iconHash[order];
(icon['nums'] as eui.Image).source = 'icon_png';
(icon['bmptxt'] as eui.BitmapLabel).visible = true;
(icon['bmptxt'] as eui.BitmapLabel).font = 'nums_fnt';
}
// nowIcon(level) {
// return;
// const icon = MapScene.iconHash[level];
// (icon['nums'] as eui.Image).source = 'iconnow_png';
// (icon['bmptxt'] as eui.BitmapLabel).visible = true;
// (icon['bmptxt'] as eui.BitmapLabel).font = 'nums3_fnt';
// MapScene.starHash[level].visible = true;
// }
// setGray(order: number) {
// return;
// const icon = MapScene.iconHash[order];
// (icon['nums'] as eui.Image).source = 'icongray_png';
// (icon['bmptxt'] as eui.BitmapLabel).visible = false;
// // (icon['bmptxt'] as eui.BitmapLabel).font = 'nums3_fnt';
// }
// resetGray(order: number) {
// return;
// const icon = MapScene.iconHash[order];
// (icon['nums'] as eui.Image).source = 'icon_png';
// (icon['bmptxt'] as eui.BitmapLabel).visible = true;
// (icon['bmptxt'] as eui.BitmapLabel).font = 'nums_fnt';
// }
showLog() {
......@@ -1146,34 +1209,10 @@ export default class MapScene extends Scene {
}
updateHomeData() {
return;
const homeData = getHomeData();
this['goldTxt'].text = `${homeData.wealth}`;
for (let j = 1; j < window['total_level']; j++) {
this.disableIcon(j + 1);
}
for (let i = 0; i < homeData.levels.length; i++) {
const level = homeData.levels[i];
const star = MapScene.starHash[i + 1];
if (level) {
star.setStar(level.stars);
this.enableIcon(level.levelNum);
} else {
this.disableIcon(level.levelNum);
}
}
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 {
const star = MapScene.starHash[homeData.levels.length + 1];
this.nowIcon(homeData.levels.length + 1);
}
this.freshMapShow();
this.updateTimerView();
}
......
......@@ -23,6 +23,8 @@ export default class MapStarComp extends ComponentBase {
} else if(num == 3) {
this['star3'].visible = true;
}
this['star1'].touchEnabled = this['star2'].touchEnabled
= this['star3'].touchEnabled = false;
}
get skinKey(): string {
......
......@@ -12,12 +12,13 @@ export default class MapTopPart extends ComponentBase {
const star = new MapStarComp();
star.loadSkin(); star.start();
const icon = this.getIcon(i);
icon.addChild(star);
icon.show = ()=>{icon.visible = true;};
icon.hide = ()=>{icon.visible = false;};
icon['nums'] = icon.getChildAt(0);
icon['bmptxt']=icon.getChildAt(1);
icon.addChildAt(star,0);
icon['starsp'] = star;
icon.touchEnabled = true;
......
......@@ -3617,7 +3617,7 @@
{
"levelNum": 721,
"maxScore": 47440,
"stars": 1
"stars": 3
},
{
"levelNum": 722,
......@@ -3627,7 +3627,42 @@
{
"levelNum": 723,
"maxScore": 47440,
"stars": 3
},
{
"levelNum": 724,
"maxScore": 47440,
"stars": 2
},
{
"levelNum": 725,
"maxScore": 47440,
"stars": 1
},
{
"levelNum": 726,
"maxScore": 47440,
"stars": 1
},
{
"levelNum": 727,
"maxScore": 47440,
"stars": 3
},
{
"levelNum": 728,
"maxScore": 47440,
"stars": 1
},
{
"levelNum": 729,
"maxScore": 47440,
"stars": 3
},
{
"levelNum": 730,
"maxScore": 47440,
"stars": 2
}
],
"remainProp": [
......
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