Commit 66c84562 authored by zjz1994's avatar zjz1994

消消乐暂存

parent bea870f5
This diff is collapsed.
This diff is collapsed.
...@@ -479,7 +479,6 @@ ...@@ -479,7 +479,6 @@
}; };
return Player; return Player;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=Player.js.map
var Strut = (function (_super) { var Strut = (function (_super) {
tslib.__extends(Strut, _super); tslib.__extends(Strut, _super);
...@@ -797,6 +796,7 @@ ...@@ -797,6 +796,7 @@
GameView.speed = 10; GameView.speed = 10;
return GameView; return GameView;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=GameView.js.map
var GameWrapper = (function (_super) { var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super); tslib.__extends(GameWrapper, _super);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -97,21 +97,21 @@ ...@@ -97,21 +97,21 @@
"assets": [ "assets": [
{ {
"name": "bg1", "name": "bg1",
"url": "//yun.duiba.com.cn/aurora/assets/e6ab7c1e191d30a2b068fa4a0e867040b9396226.png", "url": "//yun.duiba.com.cn/aurora/assets/f3fda198741657d9cab9418bd5d47248af065487.jpg",
"uuid": "bg1", "uuid": "bg1",
"ext": ".png" "ext": ".jpg"
}, },
{ {
"name": "bg2", "name": "bg2",
"url": "//yun.duiba.com.cn/aurora/assets/a2d611fa5af2b26ffd57a24ff524d2a0a4fe1564.png", "url": "//yun.duiba.com.cn/aurora/assets/8fa1de1570023f21b676a8602ec9315cee83a99b.jpg",
"uuid": "bg2", "uuid": "bg2",
"ext": ".png" "ext": ".jpg"
}, },
{ {
"name": "bg3", "name": "bg3",
"url": "//yun.duiba.com.cn/aurora/assets/89258aed59e36471a4136ce7fbc4ca7e300caf07.png", "url": "//yun.duiba.com.cn/aurora/assets/517fc529c79b18ff4881d206c942c8f2888ad6fd.jpg",
"uuid": "bg3", "uuid": "bg3",
"ext": ".png" "ext": ".jpg"
}, },
{ {
"name": "car1", "name": "car1",
......
...@@ -16,7 +16,7 @@ export class Player extends engine.Container{ ...@@ -16,7 +16,7 @@ export class Player extends engine.Container{
this._container.addChild(this.playerNode); this._container.addChild(this.playerNode);
this.playerNode.y = this.playery; this.playerNode.y = this.playery;
this.playerNode.x = pierWidth/2 - 50; this.playerNode.x = pierWidth/2 - 50;
this.playerNode.stop(); this.playerNode.play();
this._container.visible = false; this._container.visible = false;
} }
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -5,8 +5,9 @@ ...@@ -5,8 +5,9 @@
import { props } from "../props"; import { props } from "../props";
import { playSound, createSvga,getTextureByName } from "./utils"; import { playSound, createSvga,getTextureByName } from "./utils";
import ObjectPool = engine.ObjectPool; import ObjectPool = engine.ObjectPool;
import MapData, { GameEvent } from "./MapData"; import MapData, { GameEvent, ElementType } from "./MapData";
import Element from "./ele/Element"; import Element from "./ele/Element";
import CountDownGroup from "../../../recycling/src/game/views/CountDownGroup";
...@@ -48,6 +49,8 @@ export default class GameView extends engine.Container { ...@@ -48,6 +49,8 @@ export default class GameView extends engine.Container {
canation = true; canation = true;
setup() { setup() {
MapData.initPoolEle();
this.selectimg = new engine.Image(getTextureByName("选中框")); this.selectimg = new engine.Image(getTextureByName("选中框"));
this.selectimg.mouseEnabled = false; this.selectimg.mouseEnabled = false;
...@@ -59,7 +62,7 @@ export default class GameView extends engine.Container { ...@@ -59,7 +62,7 @@ export default class GameView extends engine.Container {
this.homeimg.x = this.homex; this.homeimg.x = this.homex;
this.homeimg.y = -40; this.homeimg.y = -40;
this.homeimg.stop(); this.homeimg.stop();
console.log("房子动画",this.homeimg); // console.log("房子动画",this.homeimg);
this.container = new engine.Container(); this.container = new engine.Container();
this.addChild(this.container); this.addChild(this.container);
...@@ -104,7 +107,6 @@ export default class GameView extends engine.Container { ...@@ -104,7 +107,6 @@ export default class GameView extends engine.Container {
} }
playComp(){ playComp(){
console.log("动画播放完毕");
this.homeimg.stop(1); this.homeimg.stop(1);
} }
...@@ -135,7 +137,7 @@ export default class GameView extends engine.Container { ...@@ -135,7 +137,7 @@ export default class GameView extends engine.Container {
initContainer(){ initContainer(){
this.lattices = {}; this.lattices = {};
let testdata = [ let testdata = [
[1,2,5,3,3], [1,2,5,3,4],
[3,1,4,4,5], [3,1,4,4,5],
[2,5,3,5,1], [2,5,3,5,1],
[5,4,1,2,3], [5,4,1,2,3],
...@@ -318,11 +320,12 @@ export default class GameView extends engine.Container { ...@@ -318,11 +320,12 @@ export default class GameView extends engine.Container {
let ielitype = ielidata.type; let ielitype = ielidata.type;
let ieliname = this.lattices[ielidxname]; let ieliname = this.lattices[ielidxname];
let ielinode = this.container.getChildByName(ieliname); let ielinode:Element = this.container.getChildByName(ieliname);
let ielix = ielinode.x; let ielix = ielinode.x;
let ieliy = ielinode.y; let ieliy = ielinode.y;
let ietype = ielinode.type;
this.container.removeChild(ielinode); this.container.removeChild(ielinode);
MapData.recoverEle(ielinode); MapData.recoverEle(ielinode,ietype);
this.lattices[ielidxname] = "empty"; this.lattices[ielidxname] = "empty";
//元素层消除,动画层添加 //元素层消除,动画层添加
...@@ -332,14 +335,14 @@ export default class GameView extends engine.Container { ...@@ -332,14 +335,14 @@ export default class GameView extends engine.Container {
await new Promise(res=>{ await new Promise(res=>{
setTimeout(function(){ setTimeout(function(){
res(); res();
},800); },400);
}) })
this.fall(); this.fall();
await new Promise(res1=>{ await new Promise(res1=>{
setTimeout(function(){ setTimeout(function(){
res1(); res1();
},550) },400)
}) })
this.homeimg.play() this.homeimg.play()
} }
...@@ -477,7 +480,6 @@ export default class GameView extends engine.Container { ...@@ -477,7 +480,6 @@ export default class GameView extends engine.Container {
let attiondata = this.attionEliminate(); let attiondata = this.attionEliminate();
if(attiondata&&attiondata.length==2){ if(attiondata&&attiondata.length==2){
this.ination = true; this.ination = true;
console.log("可以提示");
this.attiondata = [attiondata[0],attiondata[1]]; this.attiondata = [attiondata[0],attiondata[1]];
let atname1 = this.lattices[attiondata[0]]; let atname1 = this.lattices[attiondata[0]];
let atname2 = this.lattices[attiondata[1]]; let atname2 = this.lattices[attiondata[1]];
...@@ -522,8 +524,9 @@ export default class GameView extends engine.Container { ...@@ -522,8 +524,9 @@ export default class GameView extends engine.Container {
//死图调整 //死图调整
solveDieMap(){ solveDieMap(){
this.changeEnable(false); this.changeEnable(false);
console.error("死图调整"); // console.error("死图调整");
console.log(this.lattices); // console.log(this.lattices);
// return false;
let elearr = new Array(); let elearr = new Array();
for(let key in this.lattices){ for(let key in this.lattices){
let keyval = this.lattices[key]; let keyval = this.lattices[key];
...@@ -539,7 +542,7 @@ export default class GameView extends engine.Container { ...@@ -539,7 +542,7 @@ export default class GameView extends engine.Container {
console.error("可以复活了,转移位置"); console.error("可以复活了,转移位置");
this.changeToFuHuoPos(); this.changeToFuHuoPos();
}else{ }else{
console.error("依然死亡,寻求复活"); // console.error("依然死亡,寻求复活");
return this.solveDieMap(); return this.solveDieMap();
} }
} }
...@@ -558,8 +561,13 @@ export default class GameView extends engine.Container { ...@@ -558,8 +561,13 @@ export default class GameView extends engine.Container {
this.setLatticeEleRc(key); this.setLatticeEleRc(key);
} }
await Promise.all(prolist) await Promise.all(prolist)
console.error("死亡转移完毕");
this.changeEnable(true); this.checkEliminate();
if(this.eliminateArr.length>0){
this.eliminate();
}else{
this.changeEnable(true);
}
} }
//相邻检测 //相邻检测
...@@ -576,10 +584,10 @@ export default class GameView extends engine.Container { ...@@ -576,10 +584,10 @@ export default class GameView extends engine.Container {
let edatacol = this.getEliminateCol(r,c); let edatacol = this.getEliminateCol(r,c);
if(edatarow.length>2||edatacol.length>2){ if(edatarow.length>2||edatacol.length>2){
console.error("啥情况,检查----------------"); // console.error("啥情况,检查----------------");
} }
if(edatarow.length==2){ if(edatarow.length==2){
console.log("横向查找",edatarow,checktype); // console.log("横向查找",edatarow,checktype);
let releidx1 = edatarow[0]; let releidx1 = edatarow[0];
let releidx2 = edatarow[1]; let releidx2 = edatarow[1];
...@@ -591,7 +599,10 @@ export default class GameView extends engine.Container { ...@@ -591,7 +599,10 @@ export default class GameView extends engine.Container {
let uprow = relerow2-1; let uprow = relerow2-1;
let rightcol = relecol+1; let rightcol = relecol+1;
let leftcol = relecol-1; let leftcol = relecol-1;
let uprow1 = relerow2-2;
let downrow1 = relerow1+2;
if(downrow<MapData.row){ if(downrow<MapData.row){
if(rightcol<MapData.col){ if(rightcol<MapData.col){
let nexttype = this.getEleTypeByRc(downrow,rightcol); let nexttype = this.getEleTypeByRc(downrow,rightcol);
...@@ -626,6 +637,20 @@ export default class GameView extends engine.Container { ...@@ -626,6 +637,20 @@ export default class GameView extends engine.Container {
} }
} }
} }
if(uprow1>-1){
let nexttype = this.getEleTypeByRc(uprow1,relecol);
if(nexttype==checktype){
attiondata = [uprow+"_"+relecol,uprow1+"_"+relecol];
break;
}
}
if(downrow1<MapData.row){
let nexttype = this.getEleTypeByRc(downrow1,relecol);
if(nexttype==checktype){
attiondata = [downrow1+"_"+relecol,downrow+"_"+relecol];
break;
}
}
// for(let ir=0;ir<mayeleidxs.length;ir++){ // for(let ir=0;ir<mayeleidxs.length;ir++){
// let iridx = mayeleidxs[ir]; // let iridx = mayeleidxs[ir];
// let irename = this.lattices[iridx]; // let irename = this.lattices[iridx];
...@@ -642,7 +667,7 @@ export default class GameView extends engine.Container { ...@@ -642,7 +667,7 @@ export default class GameView extends engine.Container {
// } // }
} }
if(edatacol.length==2){ if(edatacol.length==2){
console.log("竖向查找",edatacol,checktype); // console.log("竖向查找",edatacol,checktype);
let releidx1 = edatacol[0]; let releidx1 = edatacol[0];
let releidx2 = edatacol[1]; let releidx2 = edatacol[1];
...@@ -655,6 +680,9 @@ export default class GameView extends engine.Container { ...@@ -655,6 +680,9 @@ export default class GameView extends engine.Container {
let uprow = relerow-1; let uprow = relerow-1;
let downrow = relerow+1; let downrow = relerow+1;
let rightcol1 = relecol1+2;
let leftcol1 = relecol2-2;
if(leftcol>-1){ if(leftcol>-1){
if(uprow>-1){ if(uprow>-1){
let nexttype = this.getEleTypeByRc(uprow,leftcol); let nexttype = this.getEleTypeByRc(uprow,leftcol);
...@@ -687,12 +715,75 @@ export default class GameView extends engine.Container { ...@@ -687,12 +715,75 @@ export default class GameView extends engine.Container {
} }
} }
} }
if(rightcol1<MapData.col){
let nexttype = this.getEleTypeByRc(relerow,rightcol1);
if(nexttype==checktype){
attiondata = [relerow+"_"+rightcol1,relerow+"_"+rightcol];
break;
}
}
if(leftcol1>-1){
let nexttype = this.getEleTypeByRc(relerow,leftcol1);
if(nexttype==checktype){
attiondata = [relerow+"_"+leftcol1,relerow+"_"+leftcol];
break;
}
}
// console.log("竖向检查啦啦啦",relerow,relecol1,relecol2); // console.log("竖向检查啦啦啦",relerow,relecol1,relecol2);
} }
//中间插的,俩边一样的这种
let jianrow = this.getEliminateRowR(r,c);
if(jianrow.length==2){
// console.log("中间插入33",jianrow);
let jianr = Number(jianrow[0].split("_")[0])-1;
let jianc = Number(jianrow[0].split("_")[1]);
let ljianc = jianc-1;
if(ljianc>-1){
let nexttype = this.getEleTypeByRc(jianr,ljianc);
if(nexttype==checktype){
attiondata = [jianr+"_"+ljianc,jianr+"_"+jianc];
break;
}
}
let rjianc = jianc+1;
if(rjianc<MapData.col){
let nexttype = this.getEleTypeByRc(jianr,rjianc);
if(nexttype==checktype){
attiondata = [jianr+"_"+rjianc,jianr+"_"+jianc];
break;
}
}
}
let jiancol = this.getEliminateRowC(r,c);
if(jiancol.length==2){
// console.log("中间插入44",jiancol);
let jianr = Number(jiancol[0].split("_")[0]);
let jianc = Number(jianrow[0].split("_")[1])-1;
let ujianr = jianr-1;
if(ujianr>-1){
let nexttype = this.getEleTypeByRc(ujianr,jianc);
if(nexttype==checktype){
attiondata = [ujianr+"_"+jianc,jianr+"_"+jianc];
break;
}
}
let djianr = jianr+1;
if(djianr<MapData.row){
let nexttype = this.getEleTypeByRc(djianr,jianc);
if(nexttype==checktype){
attiondata = [djianr+"_"+jianc,jianr+"_"+jianc];
break;
}
}
}
} }
} }
console.log("相邻检测--------------",attiondata); // console.log("相邻检测--------------",attiondata);
return attiondata; return attiondata;
} }
//检测消除 //检测消除
...@@ -710,6 +801,38 @@ export default class GameView extends engine.Container { ...@@ -710,6 +801,38 @@ export default class GameView extends engine.Container {
} }
} }
//两边一样,中间插入,row
getEliminateRowR(x,y){
let checktype = this.getEleTypeByRc(x,y);
let jianrow = x-2;
let relearr = new Array();
relearr.push(x+"_"+y);
if(jianrow>-1){
let jiantype = this.getEleTypeByRc(jianrow,y);
if(jiantype==checktype){
relearr.push(jianrow+"_"+y);
}
}
return relearr;
}
//两边一样,中间插入,col
getEliminateRowC(x,y){
let checktype = this.getEleTypeByRc(x,y);
let jiancol = y-2;
let relearr = new Array();
relearr.push(x+"_"+y);
if(jiancol>-1){
let jiantype = this.getEleTypeByRc(x,jiancol);
if(jiantype==checktype){
relearr.push(x+"_"+jiancol);
}
}
return relearr;
}
getEliminateRow(x,y){ getEliminateRow(x,y){
let checktype = this.getEleTypeByRc(x,y); let checktype = this.getEleTypeByRc(x,y);
......
import Element from "./ele/Element"; import Element from "./ele/Element";
import { getTextureByName } from "./utils";
export enum ElementType{ export enum ElementType{
btiger = 1, btiger = 1,
gtiger, gtiger,
...@@ -9,7 +9,6 @@ export enum ElementType{ ...@@ -9,7 +9,6 @@ export enum ElementType{
} }
export enum GameEvent{ export enum GameEvent{
SelectEle = "SelectEle", SelectEle = "SelectEle",
} }
export default class MapData{ export default class MapData{
//单格大小 //单格大小
...@@ -25,9 +24,16 @@ export default class MapData{ ...@@ -25,9 +24,16 @@ export default class MapData{
}; };
static eleidx = 1; static eleidx = 1;
static elePool = []; static elePool = {};
static anispeed = 860; static anispeed = 860;
static btigerTex:engine.Texture;
static gtigerTex:engine.Texture;
static monkeyTex:engine.Texture;
static birdTex:engine.Texture;
static koalaTex:engine.Texture;
static getRy(r){ static getRy(r){
return this.paddingb+r*(this.itemsize+this.paddingi); return this.paddingb+r*(this.itemsize+this.paddingi);
} }
...@@ -69,6 +75,30 @@ export default class MapData{ ...@@ -69,6 +75,30 @@ export default class MapData{
} }
return ename; return ename;
} }
static getEtypeImgTex(type:ElementType){
let etex:engine.Texture;
switch(type){
case ElementType.btiger:
etex = this.btigerTex||getTextureByName("白虎");
break;
case ElementType.gtiger:
etex = this.gtigerTex||getTextureByName("雌虎");
break;
case ElementType.monkey:
etex = this.monkeyTex||getTextureByName("猴子");
break;
case ElementType.bird:
etex = this.birdTex||getTextureByName("鸟");
break;
case ElementType.koala:
etex = this.koalaTex||getTextureByName("树熊");
break;
default:
console.error("未定义元素类型");
break;
}
return etex;
}
static getRandEtype(){ static getRandEtype(){
let eletypeArr = [ElementType.btiger,ElementType.gtiger,ElementType.monkey,ElementType.bird,ElementType.koala]; let eletypeArr = [ElementType.btiger,ElementType.gtiger,ElementType.monkey,ElementType.bird,ElementType.koala];
...@@ -76,22 +106,43 @@ export default class MapData{ ...@@ -76,22 +106,43 @@ export default class MapData{
return etype; return etype;
} }
static initPoolEle(){
console.error("初始化元素池");
let eletypes = [ElementType.btiger,ElementType.gtiger,ElementType.monkey,ElementType.bird,ElementType.koala];
for(let i=0;i<eletypes.length;i++){
let itype = eletypes[i];
this.elePool[itype] = new Array();
for(let a=0;a<10;a++){
let iele = new Element();
iele.eimage.texture = this.getEtypeImgTex(itype);
this.elePool[itype].push(iele);
}
}
}
static getOneEle(type:ElementType):Element{ static getOneEle(type:ElementType):Element{
let ele:Element; let ele:Element;
if(this.elePool.length>0){ if(this.elePool[type]){
ele = this.elePool.shift(); if(this.elePool[type].length>0){
ele = this.elePool[type].shift();
}
}else{ }else{
this.elePool[type] = new Array();
}
if(!ele){
console.error("创建了新的了");
ele = new Element(); ele = new Element();
ele.eimage.texture = getTextureByName(this.getEtypeImgName(type));
} }
ele.name = "ele_"+this.eleidx; ele.name = "ele_"+this.eleidx;
this.eleidx += 1; this.eleidx += 1;
ele.init(type) ele.init(type)
return ele; return ele;
} }
static recoverEle(ele:Element){ static recoverEle(ele:Element,type:ElementType){
this.elePool.push(ele); this.elePool[type].push(ele);
} }
static getDistance(p1,p2){ static getDistance(p1,p2){
let p1x = p1[0]; let p1x = p1[0];
......
...@@ -31,7 +31,7 @@ export default class Element extends engine.Container{ ...@@ -31,7 +31,7 @@ export default class Element extends engine.Container{
this.type = type; this.type = type;
let ename = MapData.getEtypeImgName(type); let ename = MapData.getEtypeImgName(type);
this.eimage.texture = getTextureByName(ename); // this.eimage.texture = MapData.getTextureType(type);
let imgwid = this.eimage.texture.width; let imgwid = this.eimage.texture.width;
let imghei = this.eimage.texture.height; let imghei = this.eimage.texture.height;
...@@ -102,7 +102,7 @@ export default class Element extends engine.Container{ ...@@ -102,7 +102,7 @@ export default class Element extends engine.Container{
.call(()=>{ .call(()=>{
let nodeparent:engine.Container = this.parent; let nodeparent:engine.Container = this.parent;
nodeparent&&nodeparent.removeChild(this); nodeparent&&nodeparent.removeChild(this);
MapData.recoverEle(this); MapData.recoverEle(this,this.type);
}) })
}) })
} }
......
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