Commit c64c4091 authored by wjf's avatar wjf

l

parent 86276783
......@@ -135,6 +135,9 @@ export default class MainBase extends eui.UILayer {
RES.getResAsync("ele" + i + j + "_png")
}
}
for (var i = 1; i <= 27; i++) {
RES.getResAsync("bonusFra" + i + "_png")
}
for (var i = 1; i <= 12; i++) {
RES.getResAsync("eleDis" + i + "_png")
}
......
......@@ -57,7 +57,7 @@
"name": "startpanel"
},
{
"keys": "yezi1_png,unlightedStar_png,targetBoard_png,stepsBoard_png,stepNumber9_png,stepNumber8_png,stepNumber7_png,stepNumber6_png,stepNumber5_png,stepNumber4_png,stepNumber3_png,stepNumber2_png,stepNumber1_png,stepNumber0_png,stepBtn_png,starProgress_png,setting_png,scoreNumber9_png,scoreNumber8_png,scoreNumber7_png,scoreNumber6_png,scoreNumber5_png,scoreNumber4_png,scoreNumber3_png,scoreNumber2_png,scoreNumber1_png,scoreNumber0_png,rock6_png,rock5_png,rock4_png,rock3_png,rock2_png,rock1_png,rightMark_png,rightArrow_png,rectLat_png,progressDown_png,playSceneBg_png,magicLionBg_png,magicLion_png,lockUp_png,lockDown_png,lineLight_png,lightedStar_png,leftArrow_png,ice6_png,ice5_png,ice4_png,ice3_png,ice2_png,ice1_png,hammerBtn_png,eleDis9_png,eleDis8_png,eleDis7_png,eleDis6_png,eleDis5_png,eleDis4_png,eleDis3_png,eleDis2_png,eleDis12_png,eleDis11_png,eleDis10_png,eleDis1_png,ele5_png,ele42_png,ele41_png,ele40_png,ele4_png,ele32_png,ele31_png,ele30_png,ele3_png,ele22_png,ele21_png,ele20_png,ele2_png,ele12_png,ele11_png,ele10_png,ele1_png,ele02_png,ele01_png,ele00_png,ele0_png,dangqianfenshu_png,chooseRect_png,boomBtn_png,boom9_png,boom8_png,boom7_png,boom6_png,boom5_png,boom4_png,boom3_png,boom2_png,boom18_png,boom17_png,boom16_png,boom15_png,boom14_png,boom13_png,boom12_png,boom11_png,boom10_png,boom1_png,mainSoundBtnOn_png,mainSettingBg_png,mainQuestionBtn_png,mainMusicBtnOn_png,mainQuitBtn_png,mainSoundBtnOff_png,mainMusicBtnOff_png,targetNumber9_png,targetNumber8_png,targetNumber7_png,targetNumber6_png,targetNumber5_png,targetNumber4_png,targetNumber3_png,targetNumber2_png,targetNumber1_png,targetNumber0_png,ele7_png,ele6_png",
"keys": "yezi1_png,unlightedStar_png,targetBoard_png,stepsBoard_png,stepNumber9_png,stepNumber8_png,stepNumber7_png,stepNumber6_png,stepNumber5_png,stepNumber4_png,stepNumber3_png,stepNumber2_png,stepNumber1_png,stepNumber0_png,stepBtn_png,starProgress_png,setting_png,scoreNumber9_png,scoreNumber8_png,scoreNumber7_png,scoreNumber6_png,scoreNumber5_png,scoreNumber4_png,scoreNumber3_png,scoreNumber2_png,scoreNumber1_png,scoreNumber0_png,rock6_png,rock5_png,rock4_png,rock3_png,rock2_png,rock1_png,rightMark_png,rightArrow_png,rectLat_png,progressDown_png,playSceneBg_png,magicLionBg_png,magicLion_png,lockUp_png,lockDown_png,lineLight_png,lightedStar_png,leftArrow_png,ice6_png,ice5_png,ice4_png,ice3_png,ice2_png,ice1_png,hammerBtn_png,eleDis9_png,eleDis8_png,eleDis7_png,eleDis6_png,eleDis5_png,eleDis4_png,eleDis3_png,eleDis2_png,eleDis12_png,eleDis11_png,eleDis10_png,eleDis1_png,ele5_png,ele42_png,ele41_png,ele40_png,ele4_png,ele32_png,ele31_png,ele30_png,ele3_png,ele22_png,ele21_png,ele20_png,ele2_png,ele12_png,ele11_png,ele10_png,ele1_png,ele02_png,ele01_png,ele00_png,ele0_png,dangqianfenshu_png,chooseRect_png,boomBtn_png,boom9_png,boom8_png,boom7_png,boom6_png,boom5_png,boom4_png,boom3_png,boom2_png,boom18_png,boom17_png,boom16_png,boom15_png,boom14_png,boom13_png,boom12_png,boom11_png,boom10_png,boom1_png,mainSoundBtnOn_png,mainSettingBg_png,mainQuestionBtn_png,mainMusicBtnOn_png,mainQuitBtn_png,mainSoundBtnOff_png,mainMusicBtnOff_png,targetNumber9_png,targetNumber8_png,targetNumber7_png,targetNumber6_png,targetNumber5_png,targetNumber4_png,targetNumber3_png,targetNumber2_png,targetNumber1_png,targetNumber0_png,ele7_png,ele6_png,bonusFra9_png,bonusFra8_png,bonusFra7_png,bonusFra6_png,bonusFra5_png,bonusFra4_png,bonusFra3_png,bonusFra27_png,bonusFra26_png,bonusFra25_png,bonusFra24_png,bonusFra23_png,bonusFra22_png,bonusFra21_png,bonusFra20_png,bonusFra2_png,bonusFra19_png,bonusFra18_png,bonusFra17_png,bonusFra16_png,bonusFra15_png,bonusFra14_png,bonusFra13_png,bonusFra12_png,bonusFra11_png,bonusFra10_png,bonusFra1_png,bonusShoot_png",
"name": "mainScene"
}
],
......@@ -1166,6 +1166,146 @@
"url": "assets/mainScene/ele6.png",
"type": "image",
"name": "ele6_png"
},
{
"url": "assets/mainScene/bonusFra27.png",
"type": "image",
"name": "bonusFra27_png"
},
{
"url": "assets/mainScene/bonusFra1.png",
"type": "image",
"name": "bonusFra1_png"
},
{
"url": "assets/mainScene/bonusFra2.png",
"type": "image",
"name": "bonusFra2_png"
},
{
"url": "assets/mainScene/bonusFra3.png",
"type": "image",
"name": "bonusFra3_png"
},
{
"url": "assets/mainScene/bonusFra4.png",
"type": "image",
"name": "bonusFra4_png"
},
{
"url": "assets/mainScene/bonusFra5.png",
"type": "image",
"name": "bonusFra5_png"
},
{
"url": "assets/mainScene/bonusFra6.png",
"type": "image",
"name": "bonusFra6_png"
},
{
"url": "assets/mainScene/bonusFra7.png",
"type": "image",
"name": "bonusFra7_png"
},
{
"url": "assets/mainScene/bonusFra8.png",
"type": "image",
"name": "bonusFra8_png"
},
{
"url": "assets/mainScene/bonusFra9.png",
"type": "image",
"name": "bonusFra9_png"
},
{
"url": "assets/mainScene/bonusFra10.png",
"type": "image",
"name": "bonusFra10_png"
},
{
"url": "assets/mainScene/bonusFra11.png",
"type": "image",
"name": "bonusFra11_png"
},
{
"url": "assets/mainScene/bonusFra12.png",
"type": "image",
"name": "bonusFra12_png"
},
{
"url": "assets/mainScene/bonusFra13.png",
"type": "image",
"name": "bonusFra13_png"
},
{
"url": "assets/mainScene/bonusFra14.png",
"type": "image",
"name": "bonusFra14_png"
},
{
"url": "assets/mainScene/bonusFra15.png",
"type": "image",
"name": "bonusFra15_png"
},
{
"url": "assets/mainScene/bonusFra16.png",
"type": "image",
"name": "bonusFra16_png"
},
{
"url": "assets/mainScene/bonusFra17.png",
"type": "image",
"name": "bonusFra17_png"
},
{
"url": "assets/mainScene/bonusFra18.png",
"type": "image",
"name": "bonusFra18_png"
},
{
"url": "assets/mainScene/bonusFra19.png",
"type": "image",
"name": "bonusFra19_png"
},
{
"url": "assets/mainScene/bonusFra20.png",
"type": "image",
"name": "bonusFra20_png"
},
{
"url": "assets/mainScene/bonusFra21.png",
"type": "image",
"name": "bonusFra21_png"
},
{
"url": "assets/mainScene/bonusFra22.png",
"type": "image",
"name": "bonusFra22_png"
},
{
"url": "assets/mainScene/bonusFra23.png",
"type": "image",
"name": "bonusFra23_png"
},
{
"url": "assets/mainScene/bonusFra24.png",
"type": "image",
"name": "bonusFra24_png"
},
{
"url": "assets/mainScene/bonusFra25.png",
"type": "image",
"name": "bonusFra25_png"
},
{
"url": "assets/mainScene/bonusFra26.png",
"type": "image",
"name": "bonusFra26_png"
},
{
"url": "assets/mainScene/bonusShoot.png",
"type": "image",
"name": "bonusShoot_png"
}
]
}
\ No newline at end of file
......@@ -19,7 +19,7 @@
<e:Button id="hammerBtn" label="" anchorOffsetX="67.5" anchorOffsetY="60" icon="hammerBtn_png" skinName="ui.IconButtonSkin" y="1100" x="375.5"/>
<e:Button id="stepBtn" label="" anchorOffsetX="67.5" anchorOffsetY="60" icon="stepBtn_png" skinName="ui.IconButtonSkin" y="1100" x="568.46"/>
<e:Button id="boomBtn" label="" anchorOffsetX="67" anchorOffsetY="60" icon="boomBtn_png" skinName="ui.IconButtonSkin" y="1100" x="185.58"/>
<e:Group id="settingAll" width="89" height="320" x="641" y="53">
<e:Group id="settingAll" width="89" height="203" x="641" y="53" anchorOffsetY="0">
<e:Group id="settingGroup" width="72" height="282" x="8" y="29" anchorOffsetX="0" visible="false">
<e:Image x="0" y="0" source="mainSettingBg_png"/>
<e:Image id="musicBtn" x="14" y="174" source="mainMusicBtnOn_png"/>
......
......@@ -28,7 +28,7 @@ import { PassType } from '../something/enum/PassType';
import { ElementTargetData } from '../something/interface/ElementTargetData';
import { ScoreAni } from '../something/anis/ScoreAni';
import { ScoreProgress } from '../something/uis/ScoreProgress';
import { playSound, SoundType } from '../something/soundCtrl';
import { playSound, SoundType } from '../soundCtrl';
import Scene from '../../libs/new_wx/components/Scene';
import { showToast } from '../../libs/new_wx/ctrls/toastCtrl';
import getResPath from '../../libs/new_tc/getResPath';
......@@ -38,6 +38,7 @@ import { ModuleTypes } from '../../libs/new_wx/types/sceneTypes';
import { ElementTarget } from '../something/uis/ElementTarget';
import { ElementTargets } from '../something/uis/ElementTargets';
import { Chapters } from '../something/Chapters';
import { FlyTargetAni } from '../something/anis/FlyTargetAni';
// import BridgeFactory from "../../libs/JSBridge/bridge/BridgeFactory";
const aniClass = {
......@@ -89,8 +90,8 @@ export default class MainScene extends Scene {
effectElements: number[] = [];
//消除队列的索引
eliminatedElements: number[] = [];
//冰淇淋生成标志
iceCreamMark;
//棒棒糖生成标志
lollipopMark: boolean;
//地图背景容器
map: egret.DisplayObjectContainer;
//是否手动触发特效,用于两个组合后的特效
......@@ -110,11 +111,13 @@ export default class MainScene extends Scene {
commonContinuityTimes: number = 0;
//特效连消次数
effectContinuityTimes: number = 0;
//棒棒糖数量
lollipopCount: number = 0;
//是否已通关
hasPassed: boolean = false;
//通关的目标元素的计数,下标和元素类型索引一致
passElements: number[];
elementTargets:ElementTargets;
elementTargets: ElementTargets;
//所有元素的消耗数量,需要传给后端
hasEliminatedElements: number[];
//得分的动画,首先特效组合的单独算分,然后把所有符合的放入,在波及的特效触发时不算分
......@@ -199,11 +202,10 @@ export default class MainScene extends Scene {
this.passElements[element.type] = element.count;
this.hasEliminatedElements[element.type] = 0;
}
this.elementTargets=new ElementTargets(this.passElements);
this.elementTargets.x=375;
this.elementTargets.y=200;
console.log(this.elementTargets)
this.addChild(this.elementTargets)
this.elementTargets = new ElementTargets(this.passElements);
this.elementTargets.x = 375;
this.elementTargets.y = 155;
this.addChild(this.elementTargets);
this.targetScoreTxt.visible = false;
} else {
this.passElements = null;
......@@ -215,8 +217,6 @@ export default class MainScene extends Scene {
var bg = drawBg(generateMapBg(this.chapterData.map.lattices), this.chapterData.map.lattices)
this.addChild(bg);
this.map = bg;
//初始化格子
this.initLattices();
//选择框
var textureChoosed: egret.Texture = RES.getRes("chooseRect_png")
this.choosed = new eui.Image(textureChoosed);
......@@ -228,18 +228,16 @@ export default class MainScene extends Scene {
//加遮罩
var mask = new egret.Shape();
mask.graphics.beginFill(0xffffff, 1);
mask.graphics.drawRect(Tool.offsetX, Tool.offsetY, Tool.width * Tool.colNum, Tool.height * Tool.rowNum);
mask.graphics.drawRect(Tool.offsetX, Tool.offsetY, Tool.width * Tool.colNum, Tool.height * Tool.rowNum + 100);
mask.graphics.endFill();
this.elementContainer.mask = mask;
this.addChild(mask)
//容器事件
this.elementContainer.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.mouseDownE, this);
this.elementContainer.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.mouseMoveE, this);
//初始化石头
this.initRock();
//初始化元素
this.initElements();
//初始化格子
this.initLattices();
//设置栏置顶
this.addChild(this["settingAll"])
//开启事件,具体不应该放在这里,到时看
......@@ -287,36 +285,87 @@ export default class MainScene extends Scene {
var generateLats = this.chapterData.map.generateLats;
this.lattices = [];
for (var i = 0; i < latticesD.length; i++) {
if (latticesD[i]) {
this.lattices[i] = Pool.takeOut(RecoverName.LATTICE);
if (!this.lattices[i]) {
this.lattices[i] = new Lattice(i);
} else {
this.lattices[i].reset(i);
}
//如果是生成口
if (generateLats.indexOf(i) >= 0) {
this.lattices[i].isGenerate = true;
}
if (!latticesD[i]) continue;
this.lattices[i] = Pool.takeOut(RecoverName.LATTICE);
if (!this.lattices[i]) {
this.lattices[i] = new Lattice(i);
} else {
this.lattices[i].reset(i);
}
}
//冰块
var iceIndexs = this.chapterData.iceIndexs;
if (iceIndexs) {
for (var i = 0; i < iceIndexs.length; i++) {
var p = Tool.getPositionByIndex(iceIndexs[i]);
let ice = Pool.takeOut(RecoverName.ICE);
if (!ice) {
ice = new Ice();
} else {
ice.reset();
}
this.map.addChild(ice);
this.lattices[iceIndexs[i]].ice = ice;
setTimeout(() => {
ice.x = p[0] - ice.width / 2;
ice.y = p[1] - ice.height / 2;
})
//如果是生成口
if (generateLats.indexOf(i) >= 0) {
this.lattices[i].isGenerate = true;
}
var p = Tool.getPositionByIndex(i);
switch (latticesD[i]) {
//基础元素,浅冰块,深冰块,枷锁
case 1:
case 2:
case 3:
case 6:
var type = this.returnType(i);
let ele: Element = Pool.takeOut(RecoverName.ELEMENT);
if (!ele) {
ele = new Element(type)
} else {
ele.reset(type)
}
ele.x = p[0];
ele.y = p[1];
this.elementContainer.addChild(ele);
this.lattices[i].element = ele;
//加特效
if (Math.random() < this.chapterData.effectInitProbability) {
ele.effectType = Tool.randomT([0, 1, 2, 3])
if (ele.effectType == EffectType.MAGICLION) {
this.elementContainer.addChildAt(ele, 0);
}
}
//冰块
if (latticesD[i] == 2 || latticesD[i] == 3) {
let ice = Pool.takeOut(RecoverName.ICE);
if (!ice) {
ice = new Ice(latticesD[i] - 1);
} else {
ice.reset(latticesD[i] - 1);
}
this.map.addChild(ice);
this.lattices[i].ice = ice;
ice.x = p[0] - 80 / 2;
ice.y = p[1] - 81 / 2;
}
//枷锁
else if (latticesD[i] == 6) {
ele.isLock = true;
}
break;
//棒棒糖
case 4:
this.lollipopCount++;
let lol: Element = Pool.takeOut(RecoverName.ELEMENT);
if (!lol) {
lol = new Element(ElementType.LOLLIPOP)
} else {
lol.reset(ElementType.LOLLIPOP)
}
lol.x = p[0];
lol.y = p[1];
this.elementContainer.addChild(lol);
this.lattices[i].element = lol;
break;
//石头
case 5:
let rock: Element = Pool.takeOut(RecoverName.ELEMENT);
if (!rock) {
rock = new Element(ElementType.ROCK)
} else {
rock.reset(ElementType.ROCK)
}
rock.x = p[0];
rock.y = p[1];
this.elementContainer.addChild(rock);
this.lattices[i].element = rock;
break;
}
}
//联通口
......@@ -326,63 +375,16 @@ export default class MainScene extends Scene {
this.lattices[connectedLat[0]].down = connectedLat[1];
this.lattices[connectedLat[1]].up = connectedLat[0];
}
}
//初始化石头
initRock() {
var data = this.chapterData.rockIndexs || [];
for (var i = 0; i < data.length; i++) {
var index = data[i]
let ele: Element = Pool.takeOut(RecoverName.ELEMENT);
if (!ele) {
ele = new Element(ElementType.ROCK)
} else {
ele.reset(ElementType.ROCK)
}
var p = Tool.getPositionByIndex(index);
ele.x = p[0];
ele.y = p[1];
this.elementContainer.addChild(ele);
this.lattices[index].element = ele;
}
}
//初始化元素
initElements() {
for (var i = 0; i < this.lattices.length; i++) {
if (this.lattices[i] && !this.lattices[i].element) {
var type = this.returnType(i);
let ele: Element = Pool.takeOut(RecoverName.ELEMENT);
if (!ele) {
ele = new Element(type)
} else {
ele.reset(type)
}
var p = Tool.getPositionByIndex(i);
ele.x = p[0];
ele.y = p[1];
this.elementContainer.addChild(ele);
this.lattices[i].element = ele;
//加特效
if (Math.random() < this.chapterData.effectInitProbability) {
ele.effectType = Tool.randomT([0, 1, 2, 3])
if (ele.effectType == EffectType.MAGICLION) {
this.elementContainer.addChildAt(ele, 0);
}
}
}
}
// this.lattices[79].element.effectType=EffectType.MAGICLION
// this.lattices[80].element.effectType = EffectType.VERTICAL;
this.lattices[78].element.isLock = true
//初始化完先检测死图
this.warningCop = this.dieMapCheck();
if (!this.warningCop) {
//替换顺序
this.upsetElement();
} else {
this.enableMouseEvt(true);
}
// else {
// this.enableMouseEvt(true);
// }
}
//返回元素类别
private returnType(index: number) {
var rc = Tool.indexToRc(index);
......@@ -557,7 +559,20 @@ export default class MainScene extends Scene {
this.oneStepScore = 0;
//开始执行消除
this.eliminate();
//同时考虑冰淇淋,是否可以落下,待加
//同时考虑判断棒棒糖交换后是否可以掉落,是否可以落下,待加
var aarr = [s, o]
for (var i = 0; i < aarr.length; i++) {
var ele = aarr[i];
if (ele.type == ElementType.LOLLIPOP && ele.row == Tool.rowNum - 1) {
this.recoverEle(ele.index);
this.lollipopCount--;
//通关目标还有棒棒糖,并且,图中已为0,下次需要生成
if (this.passElements[ElementType.LOLLIPOP] && this.lollipopCount <= 0) {
this.lollipopCount = 0;
this.lollipopMark = true
}
}
}
} else {
this.exchangeData(s, o);
this.exchangeElementAni(s, o);
......@@ -740,13 +755,19 @@ export default class MainScene extends Scene {
let count = 0;
let countAll = anis.length;
for (let i = 0; i < anis.length; i++) {
let obj = anis[i][0];
let obj: Element = anis[i][0];
let index = anis[i][1];
let rowCount = anis[i][2] || 1;
let position = Tool.getPositionByIndex(index);
if (!obj) {
//考虑如果需要生成冰淇淋掉落,到时加
var type = Tool.randomT(this.chapterData.baseElementTypes)
var type;
if (this.lollipopMark) {
this.lollipopMark = false;
type = ElementType.LOLLIPOP;
} else {
type = Tool.randomT(this.chapterData.baseElementTypes)
}
obj = Pool.takeOut(RecoverName.ELEMENT);
if (!obj) {
obj = new Element(type)
......@@ -768,10 +789,14 @@ export default class MainScene extends Scene {
obj.x = position[0];
obj.y = position[1];
//查看每个掉落的obj是否有冰淇淋,并且index是底部的索引,如果是,掉落完后,该格置空,加入emptys,并且需要掉落冰淇淋判断
if (obj.type == ElementType.LOLLIPOP && Tool.indexToRc(index)) {
// Tool.insert(index, emptys)
//执行冰淇淋动画,加入通关目标
//判断通关目标,生成冰淇淋标志
if (obj.type == ElementType.LOLLIPOP && Tool.indexToRc(index)[0] == Tool.rowNum - 1) {
this.recoverEle(index);
this.lollipopCount--;
//通关目标还有棒棒糖,并且,图中已为0,下次需要生成
if (this.passElements[ElementType.LOLLIPOP] && this.lollipopCount <= 0) {
this.lollipopCount = 0;
this.lollipopMark = true
}
}
count++;
if (count == countAll) {
......@@ -1244,7 +1269,7 @@ export default class MainScene extends Scene {
//连消倍数为1
this.commonContinuityTimes = 1;
this.effectContinuityTimes = 1;
//bonustime
//bonustime,toast,把所有有特效的消除先
this.terminateSteps()
} else {
//通关了
......@@ -1480,6 +1505,8 @@ export default class MainScene extends Scene {
if (ele.temEffectType != null) {
ele.effectType = ele.temEffectType;
ele.temEffectType = null;
//但是算个数
this.goElementTarget(ele);
} else {
//单纯元素消失特效
this.playAni(RecoverName.ELEDIS_ANI, p)
......@@ -1627,6 +1654,26 @@ export default class MainScene extends Scene {
* 消耗完所有步数,
*/
terminateSteps() {
//先出toast bonusTime
//遍历有特效的,和,基础元素
// var effectElements = [], elements = [];
// for (var i = Tool.colNum * Tool.rowNum - 1; i >= 0; i--) {
// var rc = Tool.indexToRc(i);
// var row = rc[0];
// var col = rc[1];
// var lat = this.lattices[i];
// if (!Tool.judgeMatch(lat)) continue
// if (lat.element.effectType != null) {
// effectElements.push(lat.element);
// } else {
// elements.push(lat.element)
// }
// }
// //如果特效有,消除特效
// if (effectElements.length) {
// Array.prototype.push.apply(this.eliminatedElements, effectElements);
// }
//动画一步一步
//将指定步数的的元素变成横竖的特效,同时加500分,并加入消除队列,执行消除,
}
......@@ -1750,21 +1797,14 @@ export default class MainScene extends Scene {
Pool.recover(RecoverName.ELEMENT, ele);
//置空格子的element,
this.lattices[index].element = null;
//如果格子有冰
this.iceBroke(this.lattices[index]);
//如果附近有石头
this.rokeBroke(this.lattices[index]);
//计算元素消除个数
if (this.passElements) {
if (ele.effectType != EffectType.MAGICLION && this.passElements[ele.type] != undefined) {
if (this.passElements[ele.type] != 0) {
this.passElements[ele.type]--;
//显示修改
}
//数量增加
this.hasEliminatedElements[ele.type]++;
}
if (ele.type != ElementType.LOLLIPOP) {
//如果格子有冰
this.iceBroke(this.lattices[index]);
//如果附近有石头
this.rokeBroke(this.lattices[index]);
}
//计算元素消除个数
this.goElementTarget(ele);
}
/**
......@@ -1820,8 +1860,7 @@ export default class MainScene extends Scene {
//回收
Pool.recover(RecoverName.ICE, ice);
lat.ice = null;
//如果通关目标有冰,还有飞入的动效
// fun=()=>{}
this.goElementTarget(ice);
} else {
ice.alpha = 0.6;
}
......@@ -1831,6 +1870,28 @@ export default class MainScene extends Scene {
}
}
goElementTarget(ele: Element | Ice) {
if (!this.passElements) return
var type: number;
if (ele instanceof Ice) {
type = ElementType.ICE;
} else {
type = ele.type;
}
if (this.passElements[type] != undefined) {
if (this.passElements[type] != 0) {
this.passElements[type]--;
//显示修改,在动画后修改
// this.elementTargets.targets[ElementType.ICE].count--
//如果通关目标有冰,还有飞入的动效
var p = this.elementTargets.targets[type].localToGlobal(40 * 0.8, 40 * 0.8)
FlyTargetAni(ele, [p.x, p.y], this)
}
//数量增加
this.hasEliminatedElements[type]++;
}
}
/**
* 附近是否有石头
* @param lat 格子
......
......@@ -10,11 +10,11 @@ export const Chapters: ChapterData[] = [
map: {
lattices: [
1, 1, 1, 0, 1, 1, 1, 1, 1,
1, 1, 1, 0, 1, 1, 1, 1, 1,
1, 1, 1, 0, 1, 1, 1, 1, 1,
1, 1, 1, 0, 1, 1, 1, 1, 1,
0, 0, 0, 0, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 0, 2, 1, 1, 1, 1,
1, 1, 1, 0, 1, 3, 1, 1, 1,
1, 1, 1, 0, 1, 1, 4, 1, 1,
0, 0, 0, 0, 1, 1, 1, 5, 1,
1, 1, 1, 1, 1, 1, 1, 1, 6,
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
......@@ -35,9 +35,6 @@ export const Chapters: ChapterData[] = [
],
connectedLats: [[27, 45], [28, 46], [29, 47]]
},
iceIndexs: [80],
lollipopCount: 0,
rockIndexs: [54, 75],
baseElementTypes: [0, 1, 2, 3],
effectInitProbability: 0.15,
stepCount: 50,
......@@ -48,9 +45,17 @@ export const Chapters: ChapterData[] = [
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
// {
// type: ElementType.ICE,
// count: 100,
// },
{
type: ElementType.RABBIT,
count: 56,
},
{
type: ElementType.ICE,
count: 100,
type: ElementType.LOLLIPOP,
count: 4,
}
],
},
......
......@@ -211,4 +211,20 @@ export class Tool {
}
return arr
}
//算角度,弧度,x正方向为0,0到2pi,顺时针为正
public static getForwardRotation(fromPoint: number[], toPoint: number[]) {
var deltaX = toPoint[0] - fromPoint[0];
var deltaY = toPoint[1] - fromPoint[1];
var vec1 = [1, 0];
var vec2 = [deltaX, deltaY];
var a = Math.sqrt(vec1[0] * vec1[0] + vec1[1] * vec1[1])
var b = Math.sqrt(vec2[0] * vec2[0] + vec2[1] * vec2[1])
var ab = vec1[0] * vec2[0] + vec1[1] * vec2[1]
var cos = ab / (a * b);//反余弦函数范围0到pi
var r = Math.acos(cos);
if (deltaY < 0) {
r = Math.PI * 2 - r;
}
}
}
\ No newline at end of file
import { ImageAni } from "../class/ImageAni";
import { Pool } from "../Pool";
import { RecoverName } from "../enum/RecoverName";
/**
* 需要回调的
* 手动修改this.shoot.rotation=
*/
export class BonusShootAni extends egret.DisplayObjectContainer {
shoot: egret.Bitmap;
imageAni: ImageAni
constructor() {
super()
this.shoot = new egret.Bitmap();
this.shoot.anchorOffsetX = 78;
this.shoot.anchorOffsetY = 37 / 2;
this.addChild(this.shoot);
var arr = []
for (var i = 1; i <= 27; i++) {
arr.push("bonusFra" + i + "_png");
}
this.imageAni = new ImageAni(arr);
this.addChild(this.imageAni);
this.imageAni.visible = false
}
reset() {
this.shoot.visible = true;
this.imageAni.visible = false
}
play(rotation: number, p: number[], callback: Function) {
this.reset()
this.shoot.rotation = rotation;
egret.Tween.get(this)
.to({ x: p[0], y: p[1] }, 1000 + Math.random() * 200 >> 0)
.call(() => {
this.imageAni.play(() => {
if (this.$parent) {
this.$parent.removeChild(this)
};
Pool.recover(RecoverName.BONUSSHOOT_ANI, this)
callback();
})
})
}
}
\ No newline at end of file
import { RecoverName } from "../enum/RecoverName";
import { Pool } from "../Pool";
import { Element } from "../class/Element";
import { Ice } from "../class/Ice";
import { ElementType } from "../enum/ElementType";
export function FlyTargetAni(ele: any, p: number[], con: egret.DisplayObjectContainer) {
//弄一个替代的
let eleC;
if (ele instanceof Element) {
eleC = Pool.takeOut(RecoverName.ELEMENT);
if (!eleC) {
eleC = new Element(ele.type)
} else {
eleC.reset(ele.type)
}
}
//是冰块
else if (ele instanceof Ice) {
eleC = Pool.takeOut(RecoverName.ICE);
if (!eleC) {
eleC = new Ice()
} else {
eleC.reset()
}
}
eleC.x = ele.x;
eleC.y = ele.y;
con.addChild(eleC);
var a = { t: 0 };
egret.Tween.get(eleC)
.to({ x: p[0], y: p[1], scaleX: 0.3, scaleY: 0.3 }, 500 + (Math.random() * 100) >> 0)
.call(() => {
//回收
con.removeChild(eleC);
if (ele instanceof Element) {
Pool.recover(RecoverName.ELEMENT, eleC);
con["elementTargets"].targets[eleC.type].count--
}
//是冰块
else if (ele instanceof Ice) {
Pool.recover(RecoverName.ICE, eleC);
con["elementTargets"].targets[ElementType.ICE].count--
}
// callback()
})
}
\ No newline at end of file
......@@ -29,6 +29,7 @@ export class Ice extends eui.Image {
reset(n: number = 2){
this.scaleX = this.scaleY = 1;
if (n == 2) {
this.alpha = 1;
} else {
......
......@@ -12,6 +12,7 @@ export enum RecoverName {
SCORE_ANI = "ScoreAni",
BONUSSHOOT_ANI = "BonusShootAni",
//元素身上
LOCK_ANI = "LockAni",
MAGICLIONBG_ANI = "MagicLionBgAni",
......
......@@ -10,18 +10,6 @@ export interface ChapterData {
* 地图数据
*/
map: MapData;
/**
* 冰块位置索引
*/
iceIndexs?: number[];
/**
* 棒棒糖数量,固定第一排生成
*/
lollipopCount?: number;
/**
* 石头位置索引
*/
rockIndexs?: number[];
/**
* 基础元素数量3-5,种类是否随机
*/
......
......@@ -6,7 +6,7 @@ import { PathData } from "./PathData";
export interface MapData {
/**
* 一维格子数组,步长9
* 1为有,0为空
* 0为空,1基本元素,2为浅冰块,3深冰块,4棒棒糖,5石头,6元素枷锁
* 最大9*9长度
*/
lattices: number[];
......
......@@ -26,12 +26,13 @@ export class ElementTarget extends egret.DisplayObjectContainer {
return this._count;
}
set count(value: number) {
this._count = value;
this.countNum.num = value;
if (value == 0) {
if (value <= 0) {
value = 0;
this.countNum.visible = false;
this.zeroMark.visible = true;
}
this._count = value;
this.countNum.num = value;
}
constructor(type: ElementType) {
super()
......
......@@ -27,7 +27,7 @@ export class ElementTargets extends egret.DisplayObjectContainer {
var len = this.$children.length;
var w = 80 * 0.8;
var space = 25
var right = len / 2 * w - w;
var right = len / 2 * w - w + (len - 1) / 2 * space;
for (var i = this.$children.length - 1; i >= 0; i--) {
this.$children[i].x = right - w * i - space * i;
}
......
......@@ -41,6 +41,17 @@ export enum SoundType {
good = 'good',
recover = 'recover',
shoot = 'shoot',
fall = 'fall',
magic = 'magic',
boom = 'boom',
sucess = 'sucess',
mapBg = 'mapBg',
eliminate = 'eliminate',
toast = 'toast',
fail = 'fail',
playBg = 'playBg',
line = 'line',
}
export const playSound = (type: SoundType) => {
......
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