Commit 996ca5a1 authored by wjf's avatar wjf

l

parent 071d9869
......@@ -62,6 +62,7 @@ import { HairballGreyDisAni } from '../something/anis/HairballGreyDisAni';
import { HairballBrownState } from '../something/states/HairballBrownState';
import { EleDownAni } from '../something/anis/EleDownAni';
import { GameGuide } from '../something/uis/GameGuide';
import { PropBtnCon } from '../something/uis/PropBtnCon';
const aniClass = {
"BoomAni": BoomAni,
......@@ -174,9 +175,7 @@ export default class MainScene extends Scene {
public starProgress: eui.Image;
public scoreTxt: eui.Label;
public chapterTxt: eui.Label;
public hammerBtn: eui.Button;
public stepBtn: eui.Button;
public boomBtn: eui.Button;
public settingGroup: eui.Group;
public settingbg: eui.Image;
public soundBtn: eui.Image;
......@@ -214,10 +213,8 @@ export default class MainScene extends Scene {
egret.Tween.get(this.scoreProgress, {}, null, true)
.to({ score: value }, 300)
}
//道具按钮上的数字
boomBtnNum: PropNumShow;
hammerBtnNum: PropNumShow;
stepBtnNum: PropNumShow;
//所有道具容器
propBtnCon: PropBtnCon;
//道具使用引导
propGuide: PropGuide;
//步数道具引导时的圆
......@@ -226,6 +223,8 @@ export default class MainScene extends Scene {
bonusTime: BonusTime;
//游戏操作引导
gameGuide: GameGuide;
//中间游戏区域高度
middleHeight: number
start(data) {
super.start();
//第几关
......@@ -233,7 +232,22 @@ export default class MainScene extends Scene {
// this.chapter = 24;
this.chapterTxt.text = "第" + this.chapter + "关";
//关卡数据
this.chapterData = getChapterData(this.chapter)
this.chapterData = getChapterData(this.chapter);
//初始化目标信息
this.initTarget();
//根据页面高度进行适配了
var height = document.body.clientHeight / document.body.clientWidth * 750;
var middleHeight = Tool.height * Tool.rowNum;
//有棒棒糖再加45,先不考虑
if (this.passElements && this.passElements[ElementType.LOLLIPOP]) middleHeight += 45
var smallestHeight = 230 + middleHeight + 180;
if (height < smallestHeight) {
Tool.offsetY = 230;
this.middleHeight = middleHeight;
} else {
Tool.offsetY = 230 + (height - smallestHeight) / 2;
this.middleHeight = height - 230 - 180;
}
//初始化索引信息,包括10*10的,
Tool.init(Tool.getColOddEven(this.chapterData.map.lattices));
this.initUi();
......@@ -245,8 +259,7 @@ export default class MainScene extends Scene {
NetManager.ins.showLog(getlogItem(10))
NetManager.ins.showLog(getlogItem(13))
//初始化目标信息
this.initTarget();
//初始化回收口,如果是棒棒糖关卡,那么在地图底部增加棒棒糖洞,用到map
this.initRecycle();
//初始化元素
......@@ -316,6 +329,8 @@ export default class MainScene extends Scene {
//分数进度条,托管
this.scoreProgress = new ScoreProgress(this.starProgress, this.scoreTxt, this.chapterData.starScores);
this.scoreTxt.y -= 2;
//分数置0
this.score = 0;
//地图生成
var path = generateMapBg(this.chapterData.map.lattices);
var bg = drawBg(path, this.chapterData.map.lattices)
......@@ -349,23 +364,23 @@ export default class MainScene extends Scene {
stopBg();
// setGameBgStatus(false);
}
//初始换道具容器
this.propBtnCon = new PropBtnCon();
this.propBtnCon.y = 230 + this.middleHeight + 55;
this.addChild(this.propBtnCon);
//按钮的事件
this.propBtnCon.boomBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_boomBtn, this)
this.propBtnCon.hammerBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_hammerBtn, this)
this.propBtnCon.stepBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_stepBtn, this)
//初始化道具信息
var arrObj = ["boomBtnNum", "hammerBtnNum", "stepBtnNum"];
var nums = [getPropNums(PropType.BOOM), getPropNums(PropType.HAMMER), getPropNums(PropType.CHANCE_NUM)]
for (var i = 0; i < 3; i++) {
this[arrObj[i]] = new PropNumShow();
this[arrObj[i]].x = 205 + i * 195;
this[arrObj[i]].y = 1125;
this[arrObj[i]].count = nums[i];
this.addChild(this[arrObj[i]])
}
this.updatePropNum();
//选择框 无需加入场景
var textureChoosed: egret.Texture = RES.getRes("chooseRect_png")
this.choosed = new eui.Image(textureChoosed);
this.choosed.x = -textureChoosed.textureWidth / 2;
this.choosed.y = -textureChoosed.textureHeight / 2;
//道具使用时蒙层 无需加入场景
this.propGuide = new PropGuide();
//道具使用时蒙层 无需加入场景,带入propBtnCo的位置数据
this.propGuide = new PropGuide(this.propBtnCon.y);
this.propGuide.touchEnabled = true;
// this.addChild(this.propGuide);
//bonusTime引导,备用的,无需加入场景
......@@ -374,8 +389,6 @@ export default class MainScene extends Scene {
this.bonusTime.y = 600;
}
initTarget() {
//分数置0
this.score = 0;
//通关目标,如果通关目标是元素时,赋值this.passElements,否则
if (this.chapterData.passTarget.type == PassType.ELEMENT_TARGET) {
this.hasEliminatedElements = [];
......@@ -676,12 +689,10 @@ export default class MainScene extends Scene {
/**
* 更新三个道具
*/
updateScene() {
var arrObj = ["boomBtnNum", "hammerBtnNum", "stepBtnNum"];
var nums = [getPropNums(PropType.BOOM), getPropNums(PropType.HAMMER), getPropNums(PropType.CHANCE_NUM)]
for (var i = 0; i < 3; i++) {
this[arrObj[i]].count = nums[i];
}
updatePropNum() {
this.propBtnCon.boomBtn.propNumShow.count = getPropNums(PropType.BOOM);
this.propBtnCon.hammerBtn.propNumShow.count = getPropNums(PropType.HAMMER);
this.propBtnCon.stepBtn.propNumShow.count = getPropNums(PropType.CHANCE_NUM);
}
//侦听事件
......@@ -693,9 +704,7 @@ export default class MainScene extends Scene {
this.musicBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_musicBtn, this)
this.quitBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_quitBtn, this)
// this.boomBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_boomBtn, this)
// this.hammerBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_hammerBtn, this)
// this.stepBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_stepBtn, this)
}
removeEvents() {
......@@ -706,9 +715,9 @@ export default class MainScene extends Scene {
this.musicBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_musicBtn, this)
this.quitBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_quitBtn, this)
// this.boomBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_boomBtn, this)
// this.hammerBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_hammerBtn, this)
// this.stepBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_stepBtn, this)
this.propBtnCon.boomBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_boomBtn, this)
this.propBtnCon.hammerBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_hammerBtn, this)
this.propBtnCon.stepBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_stepBtn, this)
this.elementContainer.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.mouseDownE, this);
this.elementContainer.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.mouseMoveE, this);
......@@ -795,7 +804,7 @@ export default class MainScene extends Scene {
}
onTap_boomBtn() {
NetManager.ins.clickLog(getlogItem(7));
if (this.boomBtnNum.count <= 0) {
if (this.propBtnCon.boomBtn.propNumShow.count <= 0) {
//购买弹框
PanelCtrl.instance.show("Buy2")
} else {
......@@ -804,7 +813,7 @@ export default class MainScene extends Scene {
}
onTap_hammerBtn() {
NetManager.ins.clickLog(getlogItem(10));
if (this.hammerBtnNum.count <= 0) {
if (this.propBtnCon.hammerBtn.propNumShow.count <= 0) {
//购买弹框
PanelCtrl.instance.show("Buy1", {})
} else {
......@@ -813,7 +822,7 @@ export default class MainScene extends Scene {
}
onTap_stepBtn() {
NetManager.ins.clickLog(getlogItem(13));
if (this.stepBtnNum.count <= 0) {
if (this.propBtnCon.stepBtn.propNumShow.count <= 0) {
//购买弹框
PanelCtrl.instance.show("Buy3", {})
} else {
......@@ -949,7 +958,7 @@ export default class MainScene extends Scene {
//如果有返回数据,没有说明是网络问题,不发home
//更新道具数量
NetManager.ins.hc_home(() => {
this.updateScene();
this.updatePropNum();
}, window['collectRuleId']);
}
}, prop)
......@@ -2695,7 +2704,7 @@ export default class MainScene extends Scene {
enableMouseEvt(b: boolean) {
// this.touchEnabled = b;
// this.touchChildren = b;
var arr = [this.elementContainer, /*this.boomBtn, this.hammerBtn, this.stepBtn*/]
var arr = [this.elementContainer, this.propBtnCon]
for (var i = 0; i < arr.length; i++) {
arr[i].touchEnabled = b;
arr[i].touchChildren = b;
......
import { PropNumber } from "./PropNumber";
import { PropNumShow } from "./PropNumShow";
export class PropBtnCon extends egret.DisplayObjectContainer {
export class PropBtnCon extends eui.Component {
boomBtn: CusButton;
hammerBtn: CusButton;
stepBtn: CusButton;
constructor() {
super();
this.boomBtn = new CusButton("boomBtn_png");
this.boomBtn.x = 375 - 110 - 50 //110图片宽度,50按钮间隔
this.addChild(this.boomBtn)
this.hammerBtn = new CusButton("hammerBtn_png");
this.hammerBtn.x = 375;
this.addChild(this.hammerBtn)
this.stepBtn = new CusButton("stepBtn_png");
this.stepBtn.x = 375 + 110 + 50
this.addChild(this.stepBtn)
}
}
/**
* 自定义按钮
*/
class CusButton extends eui.Component {
propNumShow: PropNumShow
constructor(source: string) {
super();
this.touchChildren = false;
var image = new eui.Image(source);
image.x = -55;
image.y = -55;
this.addChild(image);
this.propNumShow = new PropNumShow();
this.propNumShow.x = 15;
this.propNumShow.y = 15;
this.addChild(this.propNumShow);
this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, () => {
this.scaleX = this.scaleY = 0.9;
}, this)
this.addEventListener(egret.TouchEvent.TOUCH_END, () => {
this.scaleX = this.scaleY = 1;
}, this)
this.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, () => {
this.scaleX = this.scaleY = 1;
}, this)
}
}
\ No newline at end of file
......@@ -13,21 +13,21 @@ export class PropGuide extends egret.DisplayObjectContainer {
hammerBtn: egret.Bitmap;
stepBtn: egret.Bitmap;
msgTxt: egret.TextField;
constructor() {
constructor(offsetY: number) {
super()
this.bg = new egret.Shape();
this.addChild(this.bg);
this.boomBtn = new egret.Bitmap(RES.getRes("boomBtn_png"));
this.boomBtn.x = 185.58 - 67;
this.boomBtn.y = 1100 - 60;
this.boomBtn.x = 375 - 110 - 50 - 55; //110图片宽度,50按钮间隔,55一半的图片宽度
this.boomBtn.y = offsetY - 55;
this.addChild(this.boomBtn);
this.hammerBtn = new egret.Bitmap(RES.getRes("hammerBtn_png"));
this.hammerBtn.x = 375.5 - 67.5;
this.hammerBtn.y = 1100 - 60;
this.hammerBtn.x = 375 - 55;
this.hammerBtn.y = offsetY - 55;
this.addChild(this.hammerBtn);
this.stepBtn = new egret.Bitmap(RES.getRes("stepBtn_png"));
this.stepBtn.x = 568.46 - 67.5;
this.stepBtn.y = 1100 - 60;
this.stepBtn.x = 375 + 110 + 50 - 55;
this.stepBtn.y = offsetY - 55;
this.addChild(this.stepBtn);
//再调
var text: egret.TextField = new egret.TextField();
......@@ -35,7 +35,7 @@ export class PropGuide extends egret.DisplayObjectContainer {
text.textColor = 0xffffff;
text.size = 20;
text.x = (750 - 500) / 2;
text.y = 1008;
text.y = offsetY - 92;
text.textAlign = egret.HorizontalAlign.CENTER;
text.width = 500;
this.addChild(text);
......
......@@ -45,8 +45,8 @@ export class PropNumShow extends egret.DisplayObjectContainer {
this.addChild(bg)
//数字
this.countNum = new PropNumber();
this.countNum.x = 26;
this.countNum.y = 9;
this.countNum.x = 22.5;
this.countNum.y = 7;
this.addChild(this.countNum);
}
}
\ 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