Commit 4ec33419 authored by zjz1994's avatar zjz1994

0717代码暂存

parent 30ba01b7
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -338,9 +338,11 @@ ...@@ -338,9 +338,11 @@
_this.canation = true; _this.canation = true;
_this._gametime = 60; _this._gametime = 60;
_this._gamestat = 2; _this._gamestat = 2;
_this.ingameover = false;
_this._seq = 1; _this._seq = 1;
_this.sptime = Date.now(); _this.sptime = Date.now();
_this._score = 0; _this._score = 0;
_this.inEliminate = false;
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this); _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this; return _this;
} }
...@@ -373,11 +375,18 @@ ...@@ -373,11 +375,18 @@
this.selectimg.mouseEnabled = false; this.selectimg.mouseEnabled = false;
var row = MapData.row; var row = MapData.row;
var col = MapData.col; var col = MapData.col;
this.homeimg = createSvga("房子动画"); this.homeimgday = createSvga("房子动画");
this.addChild(this.homeimg); this.homeimgday.x = this.homex;
this.homeimg.x = this.homex; this.homeimgday.y = this.homey;
this.homeimg.y = this.homey; this.homeimgday.stop();
this.homeimg.stop(); this.homeimgday.visible = false;
this.addChild(this.homeimgday);
this.homeimgnight = createSvga("夜晚房子");
this.homeimgnight.x = this.homex;
this.homeimgnight.y = this.homey;
this.homeimgnight.stop();
this.homeimgnight.visible = false;
this.addChild(this.homeimgnight);
this.container = new engine.Container(); this.container = new engine.Container();
this.addChild(this.container); this.addChild(this.container);
this.container.y = this.conty; this.container.y = this.conty;
...@@ -413,14 +422,19 @@ ...@@ -413,14 +422,19 @@
this.lastatime = Date.now(); this.lastatime = Date.now();
this.addEventListener(engine.Event.ENTER_FRAME, this.onUpdate, this); this.addEventListener(engine.Event.ENTER_FRAME, this.onUpdate, this);
}; };
GameView.prototype.changeAni = function () {
this.changeHomeShow("night");
};
GameView.prototype.playComp = function () { GameView.prototype.playComp = function () {
this.homeimg.stop(1); this.homeimgday.stop(1);
this.homeimgnight.stop(1);
}; };
GameView.prototype.init = function (time, level) { GameView.prototype.init = function (time, level, mode) {
console.log("gameview-init", time, level);
this.score = 0; this.score = 0;
this.gametime = time; this.gametime = time;
this.seq = 1; this.seq = 1;
this.ingameover = false;
this.changeHomeShow(mode);
this.initContainer(); this.initContainer();
}; };
Object.defineProperty(GameView.prototype, "score", { Object.defineProperty(GameView.prototype, "score", {
...@@ -456,21 +470,28 @@ ...@@ -456,21 +470,28 @@
this.gamestat = 2; this.gamestat = 2;
this.unShowEleAttion(); this.unShowEleAttion();
this.anicontainer.removeChild(this.selectimg); this.anicontainer.removeChild(this.selectimg);
this.ingameover = true;
this.checkGameOver();
};
GameView.prototype.checkGameOver = function () {
if (this.ingameover && !this.inEliminate) {
engine.globalEvent.dispatchEvent("game-over", { engine.globalEvent.dispatchEvent("game-over", {
score: this.score score: this.score
}); });
}
}; };
GameView.prototype.reset = function (time, level) { GameView.prototype.reset = function (time, level, mode) {
return tslib.__awaiter(this, void 0, void 0, function () { return tslib.__awaiter(this, void 0, void 0, function () {
var key, rcname, rcele, rcelex, rceley, rcetype, fallpro, testdata; var key, rcname, rcele, rcelex, rceley, rcetype, fallpro, testdata;
return tslib.__generator(this, function (_a) { return tslib.__generator(this, function (_a) {
switch (_a.label) { switch (_a.label) {
case 0: case 0:
console.log("gameview-reset", time, level);
this.anicontainer.removeChild(this.selectimg); this.anicontainer.removeChild(this.selectimg);
this.selectArr = new Array(); this.selectArr = new Array();
this.gametime = time; this.gametime = time;
this.ingameover = false;
this.seq = 1; this.seq = 1;
this.changeHomeShow(mode);
this.changeEnable(false); this.changeEnable(false);
for (key in this.lattices) { for (key in this.lattices) {
rcname = this.lattices[key]; rcname = this.lattices[key];
...@@ -508,6 +529,8 @@ ...@@ -508,6 +529,8 @@
}; };
GameView.prototype.start = function () { GameView.prototype.start = function () {
this.gamestat = 1; this.gamestat = 1;
this.selectArr = new Array();
this.changeEnable(true);
}; };
GameView.prototype.onUpdate = function () { GameView.prototype.onUpdate = function () {
var ntime = Date.now(); var ntime = Date.now();
...@@ -520,10 +543,16 @@ ...@@ -520,10 +543,16 @@
this.gametime -= passtime / 1000; this.gametime -= passtime / 1000;
} }
} }
if (this.homeimg) { if (this.homeimgday) {
var curframe = this.homeimg.currentFrame; var curframe = this.homeimgday.currentFrame;
if (curframe == this.homeimg.totalFrames) { if (curframe == this.homeimgday.totalFrames) {
this.homeimg.gotoAndStop(1); this.homeimgday.gotoAndStop(1);
}
}
if (this.homeimgnight) {
var curframe = this.homeimgnight.currentFrame;
if (curframe == this.homeimgnight.totalFrames) {
this.homeimgnight.gotoAndStop(1);
} }
} }
this.lastframeTime = ntime; this.lastframeTime = ntime;
...@@ -736,6 +765,7 @@ ...@@ -736,6 +765,7 @@
return tslib.__generator(this, function (_a) { return tslib.__generator(this, function (_a) {
switch (_a.label) { switch (_a.label) {
case 0: case 0:
this.inEliminate = true;
for (i = 0; i < this.eliminateArr.length; i++) { for (i = 0; i < this.eliminateArr.length; i++) {
ielidata1 = this.eliminateArr[i]; ielidata1 = this.eliminateArr[i];
ielileng = ielidata1.length; ielileng = ielidata1.length;
...@@ -784,7 +814,8 @@ ...@@ -784,7 +814,8 @@
})]; })];
case 2: case 2:
_a.sent(); _a.sent();
this.homeimg.play(1, 1); this.homeimgday.play(1, 1);
this.homeimgnight.play(1, 1);
return [2]; return [2];
} }
}); });
...@@ -883,6 +914,8 @@ ...@@ -883,6 +914,8 @@
this.selectArr = new Array(); this.selectArr = new Array();
isdiedata = this.attionEliminate(); isdiedata = this.attionEliminate();
if (isdiedata && isdiedata.length == 2) { if (isdiedata && isdiedata.length == 2) {
this.inEliminate = false;
this.checkGameOver();
this.recordGame(); this.recordGame();
this.changeEnable(true); this.changeEnable(true);
} }
...@@ -1059,6 +1092,8 @@ ...@@ -1059,6 +1092,8 @@
this.recordGame(); this.recordGame();
} }
this.changeEnable(true); this.changeEnable(true);
this.inEliminate = false;
this.checkGameOver();
} }
return [2]; return [2];
} }
...@@ -1469,9 +1504,20 @@ ...@@ -1469,9 +1504,20 @@
MapData.recoverTxt(anitxt); MapData.recoverTxt(anitxt);
}); });
}; };
GameView.prototype.changeHomeShow = function (mode) {
if (mode === void 0) { mode = "day"; }
var _v = true;
if (mode == "day") {
_v = true;
}
else {
_v = false;
}
this.homeimgday.visible = _v;
this.homeimgnight.visible = !_v;
};
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);
...@@ -1486,11 +1532,17 @@ ...@@ -1486,11 +1532,17 @@
} }
GameWrapper.prototype.init = function (event) { GameWrapper.prototype.init = function (event) {
console.log("gamewrapper-init", event); console.log("gamewrapper-init", event);
this._gameView.init(event.data.time, event.data.level); var time = event.data.time;
var level = event.data.level;
var mode = event.data.mode;
this._gameView.init(time, level, mode);
}; };
GameWrapper.prototype.reset = function (event) { GameWrapper.prototype.reset = function (event) {
console.log("gamewrapper-reset", event); console.log("gamewrapper-reset", event);
this._gameView.reset(event.data.time, event.data.level); var time = event.data.time;
var level = event.data.level;
var mode = event.data.mode;
this._gameView.reset(time, level, mode);
}; };
GameWrapper.prototype.start = function () { GameWrapper.prototype.start = function () {
this._gameView.start(); this._gameView.start();
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -25,12 +25,6 @@ ...@@ -25,12 +25,6 @@
"uuid": "map", "uuid": "map",
"ext": ".png" "ext": ".png"
}, },
{
"name": "房子",
"url": "//yun.duiba.com.cn/aurora/assets/df155804a46c708a714365b7247141ba0add45e5.png",
"uuid": "home",
"ext": ".png"
},
{ {
"name": "白虎", "name": "白虎",
"url": "//yun.duiba.com.cn/aurora/assets/b486b4a72c58850bbd1930b994e08802e34fb3e3.png", "url": "//yun.duiba.com.cn/aurora/assets/b486b4a72c58850bbd1930b994e08802e34fb3e3.png",
...@@ -72,6 +66,12 @@ ...@@ -72,6 +66,12 @@
"url": "//yun.duiba.com.cn/aurora/assets/10d6c3c657e4f26eee2e6f1edca36ec468d57353.svga", "url": "//yun.duiba.com.cn/aurora/assets/10d6c3c657e4f26eee2e6f1edca36ec468d57353.svga",
"uuid": "homeani", "uuid": "homeani",
"ext": ".svga" "ext": ".svga"
},
{
"name": "夜晚房子",
"url": "//yun.duiba.com.cn/aurora/assets/aa9261273423b4b9343b4526b7e5f71a6a35a345.svga",
"uuid": "homenight",
"ext": ".svga"
} }
], ],
"events": { "events": {
......
...@@ -33,7 +33,8 @@ export default class GameView extends engine.Container { ...@@ -33,7 +33,8 @@ export default class GameView extends engine.Container {
selectimg:engine.Image; selectimg:engine.Image;
//屋子 //屋子
homeimg; homeimgday;
homeimgnight;
conty = 140; conty = 140;
homex = 562; homex = 562;
...@@ -52,6 +53,8 @@ export default class GameView extends engine.Container { ...@@ -52,6 +53,8 @@ export default class GameView extends engine.Container {
_gametime = 60; _gametime = 60;
_gamestat=2; _gamestat=2;
ingameover = false;
set gamestat(stat){//1游戏中,2,游戏外 set gamestat(stat){//1游戏中,2,游戏外
this._gamestat = stat; this._gamestat = stat;
if(stat==2){ if(stat==2){
...@@ -75,19 +78,31 @@ export default class GameView extends engine.Container { ...@@ -75,19 +78,31 @@ export default class GameView extends engine.Container {
setup() { setup() {
MapData.initPoolEle(); MapData.initPoolEle();
this.selectimg = new engine.Image(getTextureByName("选中框")); this.selectimg = new engine.Image(getTextureByName("选中框"));
this.selectimg.mouseEnabled = false; this.selectimg.mouseEnabled = false;
let row = MapData.row; let row = MapData.row;
let col = MapData.col; let col = MapData.col;
this.homeimg = createSvga("房子动画"); this.homeimgday = createSvga("房子动画");
this.addChild(this.homeimg); this.homeimgday.x = this.homex;
this.homeimg.x = this.homex; this.homeimgday.y = this.homey;
this.homeimg.y = this.homey; this.homeimgday.stop();
this.homeimg.stop(); this.homeimgday.visible = false;
// console.log("房子动画",this.homeimg); this.addChild(this.homeimgday);
this.homeimgnight = createSvga("夜晚房子");
this.homeimgnight.x = this.homex;
this.homeimgnight.y = this.homey;
this.homeimgnight.stop();
this.homeimgnight.visible = false;
this.addChild(this.homeimgnight);
this.container = new engine.Container(); this.container = new engine.Container();
this.addChild(this.container); this.addChild(this.container);
...@@ -141,17 +156,22 @@ export default class GameView extends engine.Container { ...@@ -141,17 +156,22 @@ export default class GameView extends engine.Container {
// this.addChild(testbtn); // this.addChild(testbtn);
// testbtn.y = 900; // testbtn.y = 900;
// testbtn.fillColor = "red"; // testbtn.fillColor = "red";
// testbtn.addEventListener(engine.MouseEvent.CLICK,this.reset,this); // testbtn.addEventListener(engine.MouseEvent.CLICK,this.changeAni,this);
}
changeAni(){
this.changeHomeShow("night");
} }
playComp(){ playComp(){
this.homeimg.stop(1); this.homeimgday.stop(1);
this.homeimgnight.stop(1);
} }
init(time,level){ init(time,level,mode){
console.log("gameview-init",time,level);
this.score = 0; this.score = 0;
this.gametime = time; this.gametime = time;
this.seq = 1; this.seq = 1;
this.ingameover = false;
this.changeHomeShow(mode);
this.initContainer(); this.initContainer();
} }
_score = 0; _score = 0;
...@@ -177,24 +197,31 @@ export default class GameView extends engine.Container { ...@@ -177,24 +197,31 @@ export default class GameView extends engine.Container {
get gametime(){ get gametime(){
return this._gametime; return this._gametime;
} }
inEliminate:boolean = false;
gameOver(){ gameOver(){
// console.log("游戏结束"); // console.log("游戏结束");
this.gamestat = 2; this.gamestat = 2;
this.unShowEleAttion(); this.unShowEleAttion();
this.anicontainer.removeChild(this.selectimg); this.anicontainer.removeChild(this.selectimg);
this.ingameover = true;
this.checkGameOver();
};
checkGameOver(){
if(this.ingameover&&!this.inEliminate){
engine.globalEvent.dispatchEvent("game-over",{ engine.globalEvent.dispatchEvent("game-over",{
score:this.score score:this.score
}) })
}; }
}
levelData; levelData;
async reset(time,level){ async reset(time,level,mode){
console.log("gameview-reset",time,level);
this.anicontainer.removeChild(this.selectimg); this.anicontainer.removeChild(this.selectimg);
this.selectArr = new Array(); this.selectArr = new Array();
this.gametime = time; this.gametime = time;
this.ingameover = false;
this.seq = 1; this.seq = 1;
this.changeHomeShow(mode);
this.changeEnable(false); this.changeEnable(false);
for(let key in this.lattices){ for(let key in this.lattices){
...@@ -230,6 +257,8 @@ export default class GameView extends engine.Container { ...@@ -230,6 +257,8 @@ export default class GameView extends engine.Container {
} }
start(){ start(){
this.gamestat = 1; this.gamestat = 1;
this.selectArr = new Array();
this.changeEnable(true);
} }
onUpdate(){ onUpdate(){
let ntime = Date.now(); let ntime = Date.now();
...@@ -242,10 +271,16 @@ export default class GameView extends engine.Container { ...@@ -242,10 +271,16 @@ export default class GameView extends engine.Container {
this.gametime -= passtime/1000; this.gametime -= passtime/1000;
} }
} }
if(this.homeimg){ if(this.homeimgday){
let curframe = this.homeimg.currentFrame; let curframe = this.homeimgday.currentFrame;
if(curframe==this.homeimg.totalFrames){ if(curframe==this.homeimgday.totalFrames){
this.homeimg.gotoAndStop(1); this.homeimgday.gotoAndStop(1);
}
}
if(this.homeimgnight){
let curframe = this.homeimgnight.currentFrame;
if(curframe==this.homeimgnight.totalFrames){
this.homeimgnight.gotoAndStop(1);
} }
} }
...@@ -483,6 +518,7 @@ export default class GameView extends engine.Container { ...@@ -483,6 +518,7 @@ export default class GameView extends engine.Container {
//消除 //消除
async eliminate(){ async eliminate(){
this.inEliminate = true;
for(let i=0;i<this.eliminateArr.length;i++){ for(let i=0;i<this.eliminateArr.length;i++){
let ielidata1 = this.eliminateArr[i]; let ielidata1 = this.eliminateArr[i];
let ielileng = ielidata1.length; let ielileng = ielidata1.length;
...@@ -533,7 +569,8 @@ export default class GameView extends engine.Container { ...@@ -533,7 +569,8 @@ export default class GameView extends engine.Container {
res1(); res1();
},500) },500)
}) })
this.homeimg.play(1,1); this.homeimgday.play(1,1);
this.homeimgnight.play(1,1);
} }
//掉落 //掉落
async fall(type="normal"){ async fall(type="normal"){
...@@ -627,6 +664,8 @@ export default class GameView extends engine.Container { ...@@ -627,6 +664,8 @@ export default class GameView extends engine.Container {
let isdiedata = this.attionEliminate(); let isdiedata = this.attionEliminate();
if(isdiedata&&isdiedata.length==2){//没死 if(isdiedata&&isdiedata.length==2){//没死
this.inEliminate = false;
this.checkGameOver();
this.recordGame(); this.recordGame();
this.changeEnable(true); this.changeEnable(true);
}else{//死图处理 }else{//死图处理
...@@ -818,6 +857,8 @@ export default class GameView extends engine.Container { ...@@ -818,6 +857,8 @@ export default class GameView extends engine.Container {
this.recordGame(); this.recordGame();
} }
this.changeEnable(true); this.changeEnable(true);
this.inEliminate = false;
this.checkGameOver();
} }
} }
//游戏记录 //游戏记录
...@@ -1283,4 +1324,15 @@ export default class GameView extends engine.Container { ...@@ -1283,4 +1324,15 @@ export default class GameView extends engine.Container {
MapData.recoverTxt(anitxt); MapData.recoverTxt(anitxt);
}) })
} }
changeHomeShow(mode="day"){
let _v = true;
if(mode=="day"){
_v = true;
}else{
_v = false;
}
this.homeimgday.visible = _v;
this.homeimgnight.visible = !_v;
}
} }
...@@ -21,11 +21,17 @@ export class GameWrapper extends engine.Container { ...@@ -21,11 +21,17 @@ export class GameWrapper extends engine.Container {
init(event:engine.Event){ init(event:engine.Event){
console.log("gamewrapper-init",event); console.log("gamewrapper-init",event);
this._gameView.init(event.data.time,event.data.level); let time = event.data.time;
let level = event.data.level;
let mode = event.data.mode;
this._gameView.init(time,level,mode);
} }
reset(event:engine.Event){ reset(event:engine.Event){
console.log("gamewrapper-reset",event); console.log("gamewrapper-reset",event);
this._gameView.reset(event.data.time,event.data.level);; let time = event.data.time;
let level = event.data.level;
let mode = event.data.mode;
this._gameView.reset(time,level,mode);;
} }
start(){ start(){
this._gameView.start(); this._gameView.start();
......
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