Commit 93a7252c authored by zjz1994's avatar zjz1994

黑洞暂存

parent 741d00ef
...@@ -313,6 +313,8 @@ export default class MainBase extends eui.UILayer { ...@@ -313,6 +313,8 @@ export default class MainBase extends eui.UILayer {
RES.getResAsync("ele39_png"); RES.getResAsync("ele39_png");
RES.getResAsync("ele40_png"); RES.getResAsync("ele40_png");
RES.getResAsync("kuang_png"); RES.getResAsync("kuang_png");
RES.getResAsync("wormhole_png");
for (var i = 1; i <= 27; i++) { for (var i = 1; i <= 27; i++) {
RES.getResAsync("bonusFra" + i + "_png") RES.getResAsync("bonusFra" + i + "_png")
} }
......
...@@ -241,7 +241,7 @@ ...@@ -241,7 +241,7 @@
"name": "helpGroup" "name": "helpGroup"
}, },
{ {
"keys": "virprizebg_png,lightdi_png", "keys": "virprizebg_png,lightdi_png,wormhole_png",
"name": "preload" "name": "preload"
} }
], ],
...@@ -5396,6 +5396,11 @@ ...@@ -5396,6 +5396,11 @@
"url": "assets/mainScene/kuang.png", "url": "assets/mainScene/kuang.png",
"type": "image", "type": "image",
"name": "kuang_png" "name": "kuang_png"
},
{
"name": "wormhole_png",
"type": "image",
"url": "assets/mainScene/wormhole.png"
} }
] ]
} }
\ No newline at end of file
...@@ -118,6 +118,8 @@ import { getArrowDir, getArrowRotation, fillConveyor, getOneConveyorMask } from ...@@ -118,6 +118,8 @@ import { getArrowDir, getArrowRotation, fillConveyor, getOneConveyorMask } from
import createArrowBg from '../something/conveyor/createArrowBg'; import createArrowBg from '../something/conveyor/createArrowBg';
import doConveyorAI from './doConveyorAI'; import doConveyorAI from './doConveyorAI';
import Rect = eui.Rect; import Rect = eui.Rect;
import WormHole from '../something/class/WormHole';
import doWormHoleAI from './doWormHoleAI';
const aniClass = { const aniClass = {
"BoomAni": BoomAni, "BoomAni": BoomAni,
...@@ -219,6 +221,9 @@ export default class MainScene extends Scene { ...@@ -219,6 +221,9 @@ export default class MainScene extends Scene {
recycleIndexs: number[]; recycleIndexs: number[];
//元素的容器,为了移动事件简单 //元素的容器,为了移动事件简单
elementContainer: egret.DisplayObjectContainer; elementContainer: egret.DisplayObjectContainer;
//虫洞层
wormholeContainer:egret.DisplayObjectContainer;
//选中框 //选中框
choosed: eui.Image; choosed: eui.Image;
//消除后生成空格的索引 //消除后生成空格的索引
...@@ -360,8 +365,11 @@ export default class MainScene extends Scene { ...@@ -360,8 +365,11 @@ export default class MainScene extends Scene {
NetManager.ins.showLog(getlogItem(7)) NetManager.ins.showLog(getlogItem(7))
NetManager.ins.showLog(getlogItem(10)) NetManager.ins.showLog(getlogItem(10))
NetManager.ins.showLog(getlogItem(13)) NetManager.ins.showLog(getlogItem(13))
this.initConveyor(); this.initConveyor();
//虫洞
this.initWormHole();
//初始话地图格子数据 //初始话地图格子数据
this.initLattices(); this.initLattices();
//初始化回收口,如果是棒棒糖关卡,那么在地图底部增加棒棒糖洞,用到map //初始化回收口,如果是棒棒糖关卡,那么在地图底部增加棒棒糖洞,用到map
...@@ -695,6 +703,10 @@ export default class MainScene extends Scene { ...@@ -695,6 +703,10 @@ export default class MainScene extends Scene {
this.conveyorMap = {}; this.conveyorMap = {};
this.map = bg; this.map = bg;
this.map.addChild(conveyor); this.map.addChild(conveyor);
this.wormholeContainer = new egret.DisplayObjectContainer();
this.addChild(this.wormholeContainer);
//容器 //容器
this.elementContainer = new egret.DisplayObjectContainer(); this.elementContainer = new egret.DisplayObjectContainer();
this.addChild(this.elementContainer); this.addChild(this.elementContainer);
...@@ -862,6 +874,31 @@ export default class MainScene extends Scene { ...@@ -862,6 +874,31 @@ export default class MainScene extends Scene {
} }
} }
initWormHole(){
let wormholes = this.chapterData.map.WORMHOLE;
if(wormholes&&wormholes.length>0){
let tex = RES.getRes("wormhole_png");
for(var i=0;i<wormholes.length;i++){
var iwormhole = wormholes[i];
if(iwormhole.length>1){
for(var j=0;j<iwormhole.length;j++){
var jhole = iwormhole[j];
let jholepos = Tool.getPositionByIndex(jhole);
let onehole:WormHole = Tool.getOneWormHole();
onehole.init(jhole);
this.wormholeContainer.addChild(onehole);
onehole.x = jholepos[0];
onehole.y = jholepos[1];
console.log("添加了一个黑洞",onehole);
}
}else{
console.error(i+"号线仅存在一个黑洞????");
}
}
}
}
//初始化地图格子数据,包括生成口,联通口 //初始化地图格子数据,包括生成口,联通口
initLattices() { initLattices() {
var latticesD = this.chapterData.map.lattices; var latticesD = this.chapterData.map.lattices;
...@@ -2724,6 +2761,15 @@ export default class MainScene extends Scene { ...@@ -2724,6 +2761,15 @@ export default class MainScene extends Scene {
await doConveyorAI(this); await doConveyorAI(this);
this._converyorTag = false; this._converyorTag = false;
} }
//黑洞转移
let wormholes = this.chapterData.map.WORMHOLE;
if(wormholes&&wormholes.length>0){
await doWormHoleAI(this);
console.log("黑洞转移完毕");
}
//棒棒糖消除 //棒棒糖消除
var recoverlp:number = 0; var recoverlp:number = 0;
for(var lp=0;lp<this.recycleIndexs.length;lp++){ for(var lp=0;lp<this.recycleIndexs.length;lp++){
......
import MainScene from "./MainScene";
import { Lattice } from "../something/class/Lattice";
import { LatticeType } from "../something/enum/LatticeType";
import { Tool } from "../something/Tool";
const getMapsp = function(lattice:Lattice){
var mapcf:{
mapele:egret.DisplayObject,
mapdata:{}
} = {
mapele:null,
mapdata:{}
}
if(lattice){
if(lattice.ice){
mapcf.mapele = lattice.ice;
mapcf.mapdata["maptype"] = LatticeType.ICE;
mapcf.mapdata["maptypenum"] = lattice.ice.countNum;
}else if(lattice.sand){
mapcf.mapele = lattice.sand;
mapcf.mapdata["maptype"] = LatticeType.SAND;
}else if(lattice.block){
mapcf.mapele = lattice.block;
var blockice = lattice.block.ice;
var blockicecout = lattice.block.iceCountNum;
var blockstate = lattice.block.state;
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;
}
}
mapcf.mapdata["blockstate"] = lattice.block.state;
}else{//无地图元素
}
}
return mapcf;
}
const getElesp = function(lattice:Lattice){
var elecf:{
ele:egret.DisplayObject,
eledata:{
}
} = {
ele:null,
eledata:{}
};
if(lattice&&lattice.element){
var elesp = lattice.element;
var eletype = elesp.type;
var allstate = elesp.getAllState();
elecf.ele = elesp;
elecf.eledata["type"] = eletype;
elecf.eledata["states"] = allstate;
}
return elecf;
}
const tweenAnisp = function(sp:egret.DisplayObject,posx:number,posy:number,lattice:Lattice=null,mapcf:any=null,elecf:any=null){
var pro = new Promise(function(resolve,reject){
egret.Tween.get(sp)
.to({
scaleX:0,
scaleY:0,
},500)
.call(()=>{
sp.x = posx;
sp.y = posy;
console.log("黑洞转移位置",posx,posy);
})
.to({
scaleX:1,
scaleY:1
},500)
.call(()=>{
if(lattice&&mapcf&&elecf){
lattice.changeData(mapcf,elecf);
// console.log("替换数据",JSON.stringify(lattice));
}
resolve();
})
})
return pro;
}
export default async (thisObj:MainScene)=>{
const promiseList: Promise<any>[] = [];
let wormholes = thisObj.chapterData.map.WORMHOLE;
for(let i=0;i<wormholes.length;i++){
let iwormhole = wormholes[i];
if(iwormhole.length>1){
for(let j=0;j<iwormhole.length;j++){
let jholeidx = iwormhole[j];
let jlholeidx;
if(j==iwormhole.length-1){
jlholeidx = iwormhole[0];
}else{
jlholeidx = iwormhole[j+1];
}
let jidxlattice:Lattice = thisObj.lattices[jholeidx];
let jlidxlattice:Lattice = thisObj.lattices[jlholeidx];
let mapcf = getMapsp(jidxlattice);
let elecf = getElesp(jidxlattice);
let mapsp = mapcf.mapele;
let elesp = elecf.ele;
let jlidxpos = Tool.getPositionByIndex(jlholeidx);
// console.log("转移前1----------",JSON.stringify(jidxlattice),"\n2--------------",JSON.stringify(jlidxlattice))
console.log("11111111黑洞转移位置",jlholeidx,jlidxpos[0],jlidxpos[1]);
if(mapsp){
let mapro = tweenAnisp(mapsp,jlidxpos[0],jlidxpos[1]);
promiseList.push(mapro);
}
if(elesp){
let elepro = tweenAnisp(elesp,jlidxpos[0],jlidxpos[1],jlidxlattice,mapcf,elecf);
promiseList.push(elepro);
}
}
}
}
await Promise.all(promiseList).then(()=>{
console.log("替换数据");
console.log(thisObj.lattices);
// lattice:Lattice,mapcf:any,elecf:any
})
}
\ No newline at end of file
...@@ -10,6 +10,7 @@ import { GenerateLatData } from "./interface/GenerateLatData"; ...@@ -10,6 +10,7 @@ import { GenerateLatData } from "./interface/GenerateLatData";
import { Pool } from "./Pool"; import { Pool } from "./Pool";
import HoneyPotElement from "./class/HoneyPotElement"; import HoneyPotElement from "./class/HoneyPotElement";
import { ElementConfigType } from "./enum/ElementConfigType"; import { ElementConfigType } from "./enum/ElementConfigType";
import WormHole from "./class/WormHole";
//两种,0无棒棒糖,1有 //两种,0无棒棒糖,1有
const offsetYTwo: number[] = []; const offsetYTwo: number[] = [];
...@@ -1271,4 +1272,14 @@ export class Tool { ...@@ -1271,4 +1272,14 @@ export class Tool {
var roanum = [-90,0,90,180][roaidx]; var roanum = [-90,0,90,180][roaidx];
return roanum; return roanum;
} }
//黑洞
public static getOneWormHole(){
var onewormhole = Pool.takeOut("wormhole");
if(!onewormhole){
onewormhole = new WormHole();
}
return onewormhole;
}
} }
\ No newline at end of file
...@@ -9,6 +9,9 @@ export default class BaseBlock extends egret.DisplayObjectContainer { ...@@ -9,6 +9,9 @@ export default class BaseBlock extends egret.DisplayObjectContainer {
this._state = state; this._state = state;
this.initUI(); this.initUI();
} }
get state(){
return this._state;
}
initUI() { initUI() {
this._block = new egret.Bitmap(RES.getRes('common_block_png')); this._block = new egret.Bitmap(RES.getRes('common_block_png'));
......
...@@ -94,6 +94,9 @@ export const Chapters24: ChapterData[] = [ ...@@ -94,6 +94,9 @@ export const Chapters24: ChapterData[] = [
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 0, 0, 0, 0, 0, 0 1, 1, 1, 0, 0, 0, 0, 0, 0
], ],
WORMHOLE:[
[1,6,45,71]
],
connectedLats: [ connectedLats: [
[ 27, 45 ], [ 27, 45 ],
[ 28, 46 ], [ 28, 46 ],
...@@ -104,22 +107,22 @@ export const Chapters24: ChapterData[] = [ ...@@ -104,22 +107,22 @@ export const Chapters24: ChapterData[] = [
[ 34, 52 ], [ 34, 52 ],
[ 35, 53 ] [ 35, 53 ]
], ],
conveyor: [ // conveyor: [
[ 71, 66 ], // [ 71, 66 ],
[ 65, 74 ], // [ 65, 74 ],
[ 62, 56 ], // [ 62, 56 ],
[ 55, 73 ], // [ 55, 73 ],
[ 53, 46 ], // [ 53, 46 ],
[ 45, 72 ] // [ 45, 72 ]
], // ],
conveyorConnectedLats: [ // conveyorConnectedLats: [
[ 66, 65 ], // [ 66, 65 ],
[ 74, 71 ], // [ 74, 71 ],
[ 56, 55 ], // [ 56, 55 ],
[ 73, 62 ], // [ 73, 62 ],
[ 46, 45 ], // [ 46, 45 ],
[ 72, 53 ] // [ 72, 53 ]
], // ],
elements: [ 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, 1, 1, 1, 1, 1, 1, 1, 1, 1,
......
...@@ -73,7 +73,7 @@ chapters.forEach((chapter,index) => { ...@@ -73,7 +73,7 @@ chapters.forEach((chapter,index) => {
*/ */
export function getChapterData(index: number): ChapterData { export function getChapterData(index: number): ChapterData {
//没有数据就返回第一关数据 //没有数据就返回第一关数据
// return chapters[612]; return chapters[612];
return chapters[index] || chapters[1]; return chapters[index] || chapters[1];
} }
......
...@@ -1152,6 +1152,16 @@ export class Element extends eui.Component { ...@@ -1152,6 +1152,16 @@ export class Element extends eui.Component {
} }
return false return false
} }
getAllState():StateType[]{
var statearr = new Array();
for(var i=0;i<this.states.length;i++){
if(this.states[i]){
statearr.push(i);
}
}
return statearr;
}
/** /**
* 去掉所有状态 * 去掉所有状态
......
...@@ -3,6 +3,7 @@ import { Tool } from "../Tool"; ...@@ -3,6 +3,7 @@ import { Tool } from "../Tool";
import { Element } from "./Element"; import { Element } from "./Element";
import { Ice } from "./Ice"; import { Ice } from "./Ice";
import Sand from "../Sand"; import Sand from "../Sand";
import { LatticeType } from "../enum/LatticeType";
/** /**
* 位置信息直接用一个二维数组记录,然后用row,col取 * 位置信息直接用一个二维数组记录,然后用row,col取
...@@ -101,10 +102,42 @@ export class Lattice { ...@@ -101,10 +102,42 @@ export class Lattice {
this.column = rc[1]; this.column = rc[1];
//重置属性,后面自行赋值 //重置属性,后面自行赋值
this.ice = null; this.ice = null;
this.block = null;
this.sand = null;
this.element = null; this.element = null;
this.up = null; this.up = null;
this.down = null; this.down = null;
this.isGenerate = false; this.isGenerate = false;
} }
changeData(mapcf:any,elecf:any){
this.ice = null;
this.block = null;
this.sand = null;
this.element = null;
if(mapcf.mapdata["maptype"]){
var maptype = mapcf.mapdata["maptype"];
switch(maptype){
case LatticeType.ICE:
this.ice = mapcf.mapele;
break;
case LatticeType.SAND:
this.sand = mapcf.mapele;
break;
case LatticeType.BlOCK:
case LatticeType.BLOCK_AND_ICE:
case LatticeType.BLOCK_AND_DARK_ICE:
this.block = mapcf.mapele;
break;
default:
console.error("未定义地图类型,检查");
break;
}
}
if(elecf.eledata["type"]){
this.element = elecf.ele;
}
}
} }
\ No newline at end of file
export default class WormHole extends egret.Sprite{
showImage:eui.Image;
constructor(){
super();
this.showImage = new eui.Image();
this.addChild(this.showImage);
var texture: egret.Texture = RES.getRes("wormhole_png");
if(texture){
this.showImage.texture = texture;
this.showImage.x = 0;
this.showImage.y = 0;
this.showImage.anchorOffsetX = this.showImage.width/2;
this.showImage.anchorOffsetY = this.showImage.height/2;
this.showImage.scaleX = 1.5;
this.showImage.scaleY = 1.5;
}
}
index:number
init(index:number){
this.index = index;
}
recover(){
if(this.parent){
this.parent.removeChild(this);
}
}
}
\ No newline at end of file
...@@ -70,4 +70,8 @@ export interface MapData { ...@@ -70,4 +70,8 @@ export interface MapData {
* 格子索引 * 格子索引
*/ */
recycles?: number[]; recycles?: number[];
/**
* 黑洞
*/
WORMHOLE?:number[][];
} }
\ 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