Commit 59181f75 authored by zjz1994's avatar zjz1994

冰下食物暂存

parent d39883bb
......@@ -20,5 +20,9 @@
<e:Image id="icon34" width="70" height="70" source="startpanel_ele34_png"/>
<e:Image id="icon36" width="70" height="70" source="startpanel_ele36_png"/>
<e:Image id="icon41" width="70" height="70" source="ele41_png"/>
<e:Image id="icon42" width="70" height="70" source="ele42_png"/>
<e:Image id="icon43" width="70" height="70" source="ele43_png"/>
<e:Image id="icon44" width="70" height="70" source="ele44_png"/>
<e:Image id="icon45" width="70" height="70" source="ele45_png"/>
<e:BitmapLabel id="txt" text="0" font="nums4_fnt" verticalCenter="20.5" x="73.2" scaleX="0.85" scaleY="0.85"/>
</e:Skin>
\ No newline at end of file
......@@ -344,6 +344,17 @@ export default class MainScene extends Scene {
readyCannoArr:number[] = [];
//发射队列炮台
fireteamCannoArr:number[] = [];
//冰下食物,关卡总的
icefoodArr:Array<{
name:string,
inidxs:Array<number>
}> = [];
//解锁的冰下食物
ficefoodArr:Array<{
name:string,
inidxs:Array<number>
}> = [];
get steps(): number {
return this._steps
}
......@@ -480,13 +491,13 @@ export default class MainScene extends Scene {
this.wormholeContainer = new egret.DisplayObjectContainer();
this.addChild(this.wormholeContainer);
//修改流沙的问题
this.mapupContainer = new egret.DisplayObjectContainer();
this.addChild(this.mapupContainer);
//食物层
this.mapupfoodContainer = new egret.DisplayObjectContainer();
this.addChild(this.mapupfoodContainer);
//修改流沙的问题
this.mapupContainer = new egret.DisplayObjectContainer();
this.addChild(this.mapupContainer);
this.elementContainer = new egret.DisplayObjectContainer();
this.addChild(this.elementContainer);
......@@ -534,6 +545,9 @@ export default class MainScene extends Scene {
this.freepongoArr = new Array();
this.gopongoArr = new Array();
this.actpongoArr = new Array();
this.icefoodArr = new Array();
this.ficefoodArr = new Array();
this.initTurf();
......@@ -1176,12 +1190,22 @@ export default class MainScene extends Scene {
var ifoodtype = ifood.type;
var ifoodidx = ifood.luidx;
var ifoodir = ifood.dir;
var ifood1 = new Food(ifoodtype);
var ipos = ifood1.resetFood(ifoodir,ifoodidx);
var ifood1:Food = Pool.takeOut(RecoverName.FOOD);
if(!ifood1){
ifood1 = new Food();
}
var ipos = ifood1.resetFood(ifoodtype,ifoodir,ifoodidx);
ifood1.x = ipos[0];
ifood1.y = ipos[1];
this.mapupfoodContainer.addChild(ifood1);
console.log("食物处理",ifoodtype);
var ifoodname = 'food_'+i;
ifood1.name = ifoodname;
this.icefoodArr.push({
name:ifoodname,
inidxs:JSON.parse(JSON.stringify(ifood1.lockidxs))
});
// console.log("食物处理",ifoodtype);
}
}
......@@ -5054,6 +5078,7 @@ export default class MainScene extends Scene {
Pool.recover(RecoverName.ICE, ice);
lat.ice = null;
this.goElementTarget(ElementType.ICE, [ice.x, ice.y]);
this.checkReleaseFood(lat.index);
} else {
ice.alpha = 0.6;
}
......@@ -5064,6 +5089,7 @@ export default class MainScene extends Scene {
// console.log("冰块pro",lat.index);
this.wormHolePromise.push(pro);
}
} else if(lat.block && lat.block.ice && lat.block.canIceBroken && lat.block.ice.alpha!=0) {//石门(可能带冰) && 石门反转了可以消除了
const block = lat.block;
block.iceCountNum--;
......@@ -6955,4 +6981,89 @@ export default class MainScene extends Scene {
}
return zhijepuArr;
}
/**
* 食物的释放
* @param idx
*/
checkReleaseFood(idx:number){
var eliminatearr:Array<number> = new Array();
for(var i=0;i<this.icefoodArr.length;i++){
var ifoodata = this.icefoodArr[i];
var ifoodidxs = ifoodata.inidxs;
if(ifoodidxs.indexOf(idx)!=-1){
var ifoodname = ifoodata.name;
var ifood:Food = this.mapupfoodContainer.getChildByName(ifoodname) as Food;
if(ifood.freeidxs.indexOf(idx)==-1){
ifood.freeidxs.push(idx);
if(ifood.freeidxs.length==ifood.lockidxs.length){
eliminatearr.push(...ifood.freeidxs);
if(ifood&&ifood.parent){
ifood.parent.removeChild(ifood);
Pool.recover(RecoverName.FOOD,ifood);
}
this.addFreeiceFoodArr(ifoodname,ifood.freeidxs);
console.log("食物自由了,消除上面的动物,播放食物自由动画");
//食物动效播完,进行食物的通关目标完成
this.goElementTarget(ifood.type,[ifood.x,ifood.y]);
}
}
}
}
//
if(eliminatearr.length>0){
for(var e=0;e<eliminatearr.length;e++){
var eidx = eliminatearr[e];
var lat = this.lattices[eidx];
var caneliminate = Tool.judgeEliminate(lat);
if(caneliminate){
if(this.eliminatedElements.indexOf(eidx)==-1){
this.eliminatedElements.push(eidx);
}
}
}
}
}
addFreeiceFoodArr(name:string,idxs:Array<number>){
var ishave:boolean = false;
for(var i=0;i<this.ficefoodArr.length;i++){
var ificedata = this.ficefoodArr[i];
if(ificedata.name==name){
ishave = true;
}
}
if(!ishave){
this.ficefoodArr.push({
name:name,
inidxs:idxs
})
}
}
judgeNoFood(idx:number){
var isInfood:boolean = false;
for(var i=0;i<this.icefoodArr.length;i++){
var ifoodata = this.icefoodArr[i];
var ifoodidxs = ifoodata.inidxs;
if(ifoodidxs.indexOf(idx)!=-1){
isInfood = true;
break;
}
}
if(isInfood){
for(var j=0;j<this.ficefoodArr.length;j++){
var fifoodata = this.ficefoodArr[j];
var fifoodidxs = fifoodata.inidxs;
if(fifoodidxs.indexOf(idx)!=-1){
isInfood = false;
break
}
}
}
console.log("判断有无食物");
return isInfood;
}
}
\ No newline at end of file
......@@ -23,7 +23,7 @@ export default async (thisObj: MainScene) => {
// const sands = [];
for (let i = 0; i < sandLattices.length; i++) {
const sandLattice = sandLattices[i];
const indexEnd = judgeActionIndex(sandLattice.index, thisObj.lattices,thisObj.chapterData.map.WORMHOLE)
const indexEnd = judgeActionIndex(sandLattice.index, thisObj.lattices,thisObj.chapterData.map.WORMHOLE,thisObj)
if (indexEnd) {//判断是否有地方可以
//先修改数据,再进行动画播放
const sand = sandLattice.sand;
......@@ -51,7 +51,7 @@ export default async (thisObj: MainScene) => {
}
//找到毛球移动的目标位置
const judgeActionIndex = (index: number, lattices: Lattice[],worms:number[][]): number => {
const judgeActionIndex = (index: number, lattices: Lattice[],worms:number[][],thisObj:MainScene): number => {
//四个方向尽量随机
var arr = [index - Tool.colNum, index + Tool.colNum];
var rc = Tool.indexToRc(index);
......@@ -75,6 +75,7 @@ const judgeActionIndex = (index: number, lattices: Lattice[],worms:number[][]):
)||
(lattices[i]&&lattices[i].element&&lattices[i].element.inPongoPart))//猩猩支持流沙
&&!lattices[i].grass
&&!thisObj.judgeNoFood(i)
) {
return i
}
......
......@@ -21,7 +21,26 @@ export function FlyTargetAni(
}
eleC.x = fromP[0];
eleC.y = fromP[1];
egret.Tween.get(eleC)
//食物的是专门的
if(type==ElementType.food1||type==ElementType.food2
||type==ElementType.food3||type==ElementType.food4){
eleC.anchorOffsetX = texture.textureWidth/2;
eleC.anchorOffsetY = texture.textureHeight/2;
egret.Tween.get(eleC)
.to({ x: targetP[0], y: targetP[1], width:63,height:63 }, 500 + (Math.random() * 100) >> 0)
.call(()=>{
if(eleC.parent){
eleC.parent.removeChild(eleC);
Pool.recover(RecoverName.BITMAPRECYCLE,eleC);
}
callback&&callback();
})
}else{
eleC.anchorOffsetX = 0;
eleC.anchorOffsetY = 0;
egret.Tween.get(eleC)
.to({ x: targetP[0], y: targetP[1], scaleX: 0.3, scaleY: 0.3 }, 500 + (Math.random() * 100) >> 0)
.call(() => {
//回收
......@@ -30,9 +49,9 @@ export function FlyTargetAni(
Pool.recover(RecoverName.BITMAPRECYCLE, eleC);
}
//回调
callback();
callback&&callback();
// con["elementTargets"].targets[type].count--;
})
})
}
return eleC
}
\ No newline at end of file
......@@ -6,41 +6,57 @@ export const Chapters30: ChapterData[] = [
baseElementTypes: [ 0, 1, 2, 3 ], bubbleProbability: 0, stepCount: 24,
passTarget: { type: 1,
elements: [
{ type: 34, count: 20 },
{ type: 36, count: 60 },
{ type: 0, count: 115 }
{ type: 42, count: 1 },
{ type: 43, count: 1 },
{ type: 44, count: 1 },
{ type: 45, count: 1}
] },
starScores: [ 15000, 20000, 25000 ],
map: {
lattices: [
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1,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, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1
],
baseElements: [
0, 0, 0, 0, 0, 0, 0, 0, 0,
......
......@@ -12,19 +12,24 @@ export default class Food extends eui.Component{
type:ElementType;
userow:number;
usecol:number;
constructor(type:ElementType){
lockidxs:Array<number> = [];
freeidxs:Array<number> = [];
constructor(){
super();
this.showImage = new eui.Image();
this.addChild(this.showImage);
}
resetFood(type:ElementType,dir:string,luidx:number){
this.type = type;
this.userow = [3,2,3,1][this.type-ElementType.food1];
this.usecol = [3,2,2,2][this.type-ElementType.food1];
this.showImage = new eui.Image();
this.addChild(this.showImage);
var texture:egret.Texture = RES.getRes('ele'+type+'_png');
this.showImage.texture = texture;
this.showImage.anchorOffsetX = texture.textureWidth/2;
this.showImage.anchorOffsetY = texture.textureHeight/2;
}
resetFood(dir:string,luidx:number){
var roa:number;
var inidx:number = 0;
if(dir=='left'){
......@@ -43,6 +48,20 @@ export default class Food extends eui.Component{
var irow:number = [this.userow,this.usecol][inidx];
var icol:number = [this.usecol,this.userow][inidx];
//row和col反了
console.log(this.type+'食物占位'+inidx+'row:'+irow+';col:'+icol);
this.lockidxs = new Array();
this.freeidxs = new Array();
for(var i=0;i<icol;i++){
var startridx = luidx + i*Tool.colNum;
for(var j=0;j<irow;j++){
var latidx = startridx+j;
this.lockidxs.push(latidx);
}
}
console.log('解锁idxs',this.lockidxs);
this.showImage.rotation = roa;
var onelength = 78;
var posx = Tool.getPositionByIndex(luidx)[0]+irow*onelength/2-onelength/2;
......
......@@ -260,6 +260,11 @@ export const submitTran = {
34: 16,
36: 17,
41: 18,
42: 19,
43: 20,
44: 21,
45: 22,
}
// SCORE(1, "分数"),
......
......@@ -93,5 +93,6 @@ export enum RecoverName {
GRASS = 'GRASS',
GRASS_BLOCK = 'GRASS_BLOCK',
FOOD = 'FOOD',
}
\ No newline at end of file
......@@ -40,6 +40,8 @@ export class ElementTarget extends egret.DisplayObjectContainer {
super()
var texture: egret.Texture = RES.getRes("ele" + type + "_png");
var showImage = new egret.Bitmap(texture);
showImage.width = 90;
showImage.height = 90;
showImage.scaleX = showImage.scaleY = 0.7;
showImage.y = 10;
this.addChild(showImage);
......
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