Commit 7d3afc3f authored by zjz1994's avatar zjz1994

传送带+草坪

parent 17ae0401
......@@ -5,6 +5,13 @@ import { Tool } from "../something/Tool";
import MainScene from "./MainScene";
import wait from "../../libs/new_tc/wait";
import cloneElement from "../something/cloneElement";
import { LatticeType, isIce, isSand, onlyGrass } from "../something/enum/LatticeType";
import { Pool } from "../something/Pool";
import { RecoverName } from "../something/enum/RecoverName";
import { Ice } from "../something/class/Ice";
import { getSandDisplayBlock } from "../something/Sand";
import { Grass } from "../something/class/Grass";
import genBlockDisplay from "../something/block/genBlockDisplay";
export const CONVERYOR_ANI_DUR = 500;
const getTargetIndexs = (conveyor: number[]) => {
const dir = getArrowDir(conveyor);
......@@ -77,7 +84,7 @@ const getTargetConveyor = (thisObj: MainScene, targetIndex: number) => {
};
export default async (thisObj: MainScene) => {
const { elementContainer } = thisObj;
const { elementContainer, mapupContainer} = thisObj;
const conveyorList = thisObj.chapterData.map.conveyor;
if (!conveyorList) return;
const mapmentsList = [];//轨道地图元素组
......@@ -106,33 +113,143 @@ export default async (thisObj: MainScene) => {
}
// console.log(list, targetIndexs);
// const mapments = list.map(index=>
// thisObj.lattices[]
// );
console.log("传送带检查");
const mapments = list.map(index=>{
var mapcf:{
mapele:egret.DisplayObject,
mapdata:{}
} = {
mapele:null,
mapdata:{}
}
var maplattice = thisObj.lattices[index];
if(maplattice.ice){
mapcf.mapele = maplattice.ice;
mapcf.mapdata["maptype"] = LatticeType.ICE;
mapcf.mapdata["maptypenum"] = maplattice.ice.countNum;
}else if(maplattice.sand){
mapcf.mapele = maplattice.sand;
mapcf.mapdata["maptype"] = LatticeType.SAND;
}else if(maplattice.block){
mapcf.mapele = maplattice.block;
var blockice = maplattice.block.ice;
var blockicecout = maplattice.block.iceCountNum;
var blockstate = maplattice.block.state;
var blockgrass = maplattice.block.grass;
mapcf.mapdata["maptype"] = LatticeType.BlOCK;
if(blockice){
if(blockicecout==1){
mapcf.mapdata["maptype"] = LatticeType.BLOCK_AND_ICE
}else if(blockicecout==2){
mapcf.mapdata["maptype"] = LatticeType.BLOCK_AND_DARK_ICE;
}
}else if(blockgrass){
mapcf.mapdata["maptype"] = LatticeType.BLOCK_AND_GRASS;
}
mapcf.mapdata["blockstate"] = maplattice.block.state;
}
else if(maplattice.grass){
mapcf.mapele = maplattice.grass;
mapcf.mapdata["maptype"] = LatticeType.GRASS;
}
return mapcf;
});
console.log("1传送带检查",list,targetIndexs);
console.log("传送带新增地图元素",mapments);
const elements = list.map(index =>
thisObj.lattices[index].element
);//当前传送带元素
const lattices = list.map(index => thisObj.lattices[index]);//当前的lattices
const targetLattices = targetIndexs.map(index => thisObj.lattices[index]);
console.log("2传送带检查",elements,lattices,targetLattices);
mapmentsList.push(mapments);
elementsList.push(elements);
targetLatticesList.push(targetLattices);
latticesList.push(lattices);
targetIndexsList.push(targetIndexs);
console.log("3传送带检查",elementsList,targetLatticesList,latticesList,targetIndexsList);
}
console.log("4传送带检查",listItems);
listItems.forEach(item => thisObj.conveyorMap[item] = null);
latticesList.forEach(lattices => {
lattices.forEach(lat => lat.element = null);
});
const promiseList: Promise<any>[] = [];
elementsList.forEach((elements, i) => {
const conveyor = conveyorList[i];
const targetLattices = targetLatticesList[i];
const targetIndexs = targetIndexsList[i];
const lattices = latticesList[i];
const lastListIndex = getLastListIndex(conveyor);
const mapcfs = mapmentsList[i];
mapcfs.forEach((mapcf,mapidx)=>{
targetLattices[mapidx].changeData(mapcf,{ele:null,eledata:{}});
let mapsp = mapcf.mapele;
if(mapsp){
const targetP = Tool.getPositionByIndex(targetIndexs[mapidx]);
const promise = new Promise((r)=>{
if(lastListIndex==mapidx){
const lastItemTargetP = getLastPosition(conveyor,[mapsp.x,mapsp.y]);
const mask = getElementMask(mapsp.x,mapsp.y);
mapupContainer.addChild(mask);
mapsp.mask = mask;
egret.Tween.get(mapsp).to({ x: lastItemTargetP[0], y: lastItemTargetP[1] }, CONVERYOR_ANI_DUR).call(() => {
mapsp.x = targetP[0];
mapsp.y = targetP[1];
mapupContainer.removeChild(mask);
mapsp.mask = null;
r();
});
//
const targetIndex = targetIndexs[mapidx];
const targetConveyor = getTargetConveyor(thisObj, targetIndex)
const firstItemTargetP = getFirstPosition(targetConveyor, [targetP[0], targetP[1]]);
const maptype = mapcf.mapdata['maptype'];
let latticeDisplay:egret.DisplayObject;
if(isIce(maptype)){
let ice = Pool.takeOut(RecoverName.ICE);
if(!ice){
ice = new Ice(maptype-1);
}else{
ice.reset(maptype-1);
}
latticeDisplay = ice;
}else if(isSand(maptype)){
latticeDisplay = Pool.takeOut(RecoverName.SAND);
if(!latticeDisplay){
latticeDisplay = getSandDisplayBlock();
}
}else if(onlyGrass(maptype)){
latticeDisplay = Pool.takeOut(RecoverName.GRASS);
if(!latticeDisplay){
latticeDisplay = new Grass();
}
}else{
latticeDisplay = genBlockDisplay(maptype);
}
latticeDisplay.x = firstItemTargetP[0];
latticeDisplay.y = firstItemTargetP[1];
const mask2 = getElementMask(targetP[0],targetP[1]);
mapupContainer.addChild(mask2);
latticeDisplay.mask = mask2;
mapupContainer.addChild(latticeDisplay);
egret.Tween.get(latticeDisplay).to({ x: targetP[0], y: targetP[1] }, CONVERYOR_ANI_DUR).call(() => {
mapupContainer.removeChild(mask2);
mapupContainer.removeChild(latticeDisplay);
latticeDisplay.mask = null;
});
}else{
egret.Tween.get(mapsp).to({ x: targetP[0], y: targetP[1] }, CONVERYOR_ANI_DUR).call(r);
}
})
promiseList.push(promise);
}
})
elements.forEach((ele, eleIndex) => {
targetLattices[eleIndex].element = ele;
if (!ele) {
......
......@@ -15,8 +15,8 @@ export const Chapters28: ChapterData[] = [
0, 1, 1, 1, 1, 1, 1, 1, 0,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 1, 1, 3, 0, 0, 0 ], connectedLats: [],
conveyor: [ [ 19, 22 ], [ 45, 50 ], [ 75, 77 ] ],
conveyorConnectedLats: [ [ 22, 19 ], [ 50, 45 ], [ 77, 75 ] ],
conveyor: [ [ 19, 22 ] ],
conveyorConnectedLats: [ [ 22, 19 ] ],
// WORMHOLE: [[33,11,55,66]],
elements: [
1, 1, 1, 1, 1, 1, 1, 1, 1,
......@@ -39,4 +39,42 @@ export const Chapters28: ChapterData[] = [
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0
], recycles: [], generateLats: [ { index: 11, type: null }, { index: 3, type: null }, { index: 13, type: null }, { index: 4, type: null }, { index: 5, type: null }, { index: 19, type: null }, { index: 25, type: null }, { index: 27, type: null }, { index: 35, type: null } ] } },
//702
{ baseElementTypes: [ 0, 2, 3, 4 ], bubbleProbability: 0, stepCount: 21,
passTarget: { type: 1, elements: [ { type: 9, count: 56 } ] }, starScores: [ 15000, 20000, 25000 ], map: {
lattices: [
0, 0, 0, 1, 1, 1, 0, 0, 0,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 91, 1, 1, 1, 1, 1, 1, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
4, 4, 4, 4, 4, 4, 4, 4, 4,
0, 1, 1, 1, 1, 1, 1, 1, 0,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 8, 1, 3, 0, 0, 0 ], connectedLats: [],
conveyor: [ [ 75, 77 ] ],
conveyorConnectedLats: [ [ 77, 75 ] ],
// WORMHOLE: [[33,11,55,66]],
elements: [
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,
4, 19, 19, 1, 1, 1, 1, 1, 4,
2, 1, 1, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2,
1, 5, 4, 5, 12, 5, 4, 5, 1,
1, 1, 4, 4, 4, 4, 4, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1 ],
baseElements: [
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0
], recycles: [], generateLats: [ { index: 11, type: null }, { index: 3, type: null }, { index: 13, type: null }, { index: 4, type: null }, { index: 5, type: null }, { index: 19, type: null }, { index: 25, type: null }, { index: 27, type: null }, { index: 35, type: null } ] } },
]
......@@ -80,7 +80,7 @@ chapters.forEach((chapter,index) => {
*/
export function getChapterData(index: number): ChapterData {
//没有数据就返回第一关数据
return chapters[701];
return chapters[702];
return chapters[index] || chapters[1];
}
......
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