Commit d403ece2 authored by zjz1994's avatar zjz1994

代码暂存

parent e4229d77
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -320,6 +320,43 @@ ...@@ -320,6 +320,43 @@
MapData.eleidx = 1; MapData.eleidx = 1;
MapData.elePool = {}; MapData.elePool = {};
MapData.anispeed = 1000; MapData.anispeed = 1000;
MapData.levelData = [
[
[1, 2, 5, 3, 4],
[3, 1, 2, 4, 5],
[2, 5, 3, 4, 1],
[5, 4, 1, 2, 3],
[4, 1, 3, 5, 2],
],
[
[5, 2, 1, 2, 1],
[3, 1, 4, 5, 4],
[2, 5, 3, 5, 1],
[5, 4, 1, 2, 3],
[4, 1, 3, 1, 2],
],
[
[2, 4, 1, 5, 2],
[2, 3, 4, 1, 3],
[4, 1, 3, 2, 3],
[3, 2, 1, 1, 4],
[1, 1, 3, 5, 4],
],
[
[3, 2, 1, 4, 5],
[2, 4, 1, 2, 3],
[2, 3, 2, 3, 3],
[4, 4, 5, 5, 4],
[3, 3, 1, 2, 4],
],
[
[4, 5, 1, 2, 4],
[3, 2, 3, 4, 2],
[1, 5, 2, 3, 5],
[4, 5, 5, 1, 3],
[1, 2, 3, 2, 4],
]
];
return MapData; return MapData;
}()); }());
//# sourceMappingURL=MapData.js.map //# sourceMappingURL=MapData.js.map
...@@ -339,6 +376,8 @@ ...@@ -339,6 +376,8 @@
_this._gametime = 60; _this._gametime = 60;
_this._gamestat = 2; _this._gamestat = 2;
_this.ingameover = false; _this.ingameover = false;
_this.ingame = true;
_this.level = 0;
_this._seq = 1; _this._seq = 1;
_this.sptime = Date.now(); _this.sptime = Date.now();
_this._score = 0; _this._score = 0;
...@@ -461,6 +500,7 @@ ...@@ -461,6 +500,7 @@
this.score = 0; this.score = 0;
this.gametime = time; this.gametime = time;
this.seq = 1; this.seq = 1;
this.level = level;
this.ingameover = false; this.ingameover = false;
this.changeHomeShow(mode); this.changeHomeShow(mode);
this.initContainer(); this.initContainer();
...@@ -517,6 +557,7 @@ ...@@ -517,6 +557,7 @@
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.level = level;
this.ingameover = false; this.ingameover = false;
this.seq = 1; this.seq = 1;
this.changeHomeShow(mode); this.changeHomeShow(mode);
...@@ -541,13 +582,7 @@ ...@@ -541,13 +582,7 @@
return [4, fallpro]; return [4, fallpro];
case 1: case 1:
_a.sent(); _a.sent();
testdata = [ testdata = MapData.levelData[this.level];
[1, 2, 5, 3, 4],
[3, 1, 4, 4, 5],
[2, 5, 3, 5, 1],
[5, 4, 1, 2, 3],
[4, 1, 3, 5, 2],
];
this.levelData = testdata; this.levelData = testdata;
this.fall("newlevel"); this.fall("newlevel");
return [2]; return [2];
...@@ -560,9 +595,18 @@ ...@@ -560,9 +595,18 @@
this.selectArr = new Array(); this.selectArr = new Array();
this.changeEnable(true); this.changeEnable(true);
}; };
GameView.prototype.pause = function () {
console.log("游戏暂停");
this.ingame = false;
};
GameView.prototype.resume = function () {
console.log("游戏继续");
this.lastframeTime = Date.now();
this.ingame = true;
};
GameView.prototype.onUpdate = function () { GameView.prototype.onUpdate = function () {
var ntime = Date.now(); var ntime = Date.now();
if (this.gamestat == 1) { if (this.gamestat == 1 && this.ingame) {
var passtime = ntime - this.lastframeTime; var passtime = ntime - this.lastframeTime;
if (ntime - this.lastatime >= 5000 && !this.ination && this.canation && this.selectArr.length == 0) { if (ntime - this.lastatime >= 5000 && !this.ination && this.canation && this.selectArr.length == 0) {
this.attionEliShow(); this.attionEliShow();
...@@ -601,13 +645,7 @@ ...@@ -601,13 +645,7 @@
else { else {
this.lattices = {}; this.lattices = {};
} }
var testdata = [ var testdata = MapData.levelData[this.level];
[1, 2, 5, 3, 4],
[3, 1, 5, 4, 5],
[2, 5, 3, 5, 1],
[5, 4, 5, 2, 3],
[4, 1, 5, 5, 2],
];
this.levelData = testdata; this.levelData = testdata;
for (var r = 0; r < testdata.length; r++) { for (var r = 0; r < testdata.length; r++) {
var rdata = testdata[r]; var rdata = testdata[r];
...@@ -758,6 +796,7 @@ ...@@ -758,6 +796,7 @@
engine.Tween.removeTweens(snode1); engine.Tween.removeTweens(snode1);
engine.Tween.removeTweens(snode2); engine.Tween.removeTweens(snode2);
if (this.eliminateArr.length > 0) { if (this.eliminateArr.length > 0) {
this.inEliminate = true;
engine.Tween.get(snode1).to({ engine.Tween.get(snode1).to({
x: snode2x, x: snode2x,
y: snode2y y: snode2y
...@@ -1632,6 +1671,8 @@ ...@@ -1632,6 +1671,8 @@
engine.globalEvent.addEventListener('game-init', _this.init, _this); engine.globalEvent.addEventListener('game-init', _this.init, _this);
engine.globalEvent.addEventListener('game-reset', _this.reset, _this); engine.globalEvent.addEventListener('game-reset', _this.reset, _this);
engine.globalEvent.addEventListener('game-start', _this.start, _this); engine.globalEvent.addEventListener('game-start', _this.start, _this);
engine.globalEvent.addEventListener('game-pause', _this.pause, _this);
engine.globalEvent.addEventListener('game-resume', _this.resume, _this);
return _this; return _this;
} }
GameWrapper.prototype.init = function (event) { GameWrapper.prototype.init = function (event) {
...@@ -1651,6 +1692,12 @@ ...@@ -1651,6 +1692,12 @@
GameWrapper.prototype.start = function () { GameWrapper.prototype.start = function () {
this._gameView.start(); this._gameView.start();
}; };
GameWrapper.prototype.pause = function () {
this._gameView.pause();
};
GameWrapper.prototype.resume = function () {
this._gameView.resume();
};
return GameWrapper; return GameWrapper;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=GameWrapper.js.map //# sourceMappingURL=GameWrapper.js.map
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -96,6 +96,12 @@ ...@@ -96,6 +96,12 @@
}, },
"game-start": { "game-start": {
"alias": "开始" "alias": "开始"
},
"game-pause": {
"alias": "暂停"
},
"game-resume": {
"alias": "继续"
} }
}, },
"out": { "out": {
......
...@@ -69,6 +69,8 @@ export default class GameView extends engine.Container { ...@@ -69,6 +69,8 @@ export default class GameView extends engine.Container {
jtex2; jtex2;
jtey2; jtey2;
ingame = true;
level = 0;
set gamestat(stat){//1游戏中,2,游戏外 set gamestat(stat){//1游戏中,2,游戏外
this._gamestat = stat; this._gamestat = stat;
if(stat==2){ if(stat==2){
...@@ -223,6 +225,7 @@ export default class GameView extends engine.Container { ...@@ -223,6 +225,7 @@ export default class GameView extends engine.Container {
this.score = 0; this.score = 0;
this.gametime = time; this.gametime = time;
this.seq = 1; this.seq = 1;
this.level = level;
this.ingameover = false; this.ingameover = false;
this.changeHomeShow(mode); this.changeHomeShow(mode);
this.initContainer(); this.initContainer();
...@@ -272,6 +275,7 @@ export default class GameView extends engine.Container { ...@@ -272,6 +275,7 @@ export default class GameView extends engine.Container {
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.level = level;
this.ingameover = false; this.ingameover = false;
this.seq = 1; this.seq = 1;
this.changeHomeShow(mode); this.changeHomeShow(mode);
...@@ -298,13 +302,7 @@ export default class GameView extends engine.Container { ...@@ -298,13 +302,7 @@ export default class GameView extends engine.Container {
}) })
await fallpro; await fallpro;
let testdata = [ let testdata = MapData.levelData[this.level];
[1,2,5,3,4],
[3,1,4,4,5],
[2,5,3,5,1],
[5,4,1,2,3],
[4,1,3,5,2],
];
this.levelData = testdata; this.levelData = testdata;
this.fall("newlevel"); this.fall("newlevel");
} }
...@@ -313,9 +311,18 @@ export default class GameView extends engine.Container { ...@@ -313,9 +311,18 @@ export default class GameView extends engine.Container {
this.selectArr = new Array(); this.selectArr = new Array();
this.changeEnable(true); this.changeEnable(true);
} }
pause(){
console.log("游戏暂停");
this.ingame = false;
}
resume(){
console.log("游戏继续");
this.lastframeTime = Date.now();
this.ingame = true;
}
onUpdate(){ onUpdate(){
let ntime = Date.now(); let ntime = Date.now();
if(this.gamestat==1){ if(this.gamestat==1&&this.ingame){
let passtime = ntime - this.lastframeTime; let passtime = ntime - this.lastframeTime;
if(ntime-this.lastatime>=5000&&!this.ination&&this.canation&&this.selectArr.length==0){ if(ntime-this.lastatime>=5000&&!this.ination&&this.canation&&this.selectArr.length==0){
this.attionEliShow(); this.attionEliShow();
...@@ -355,20 +362,8 @@ export default class GameView extends engine.Container { ...@@ -355,20 +362,8 @@ export default class GameView extends engine.Container {
this.lattices = {}; this.lattices = {};
} }
let testdata = [ let testdata = MapData.levelData[this.level];
[1,2,5,3,4],
[3,1,5,4,5],
[2,5,3,5,1],
[5,4,5,2,3],
[4,1,5,5,2],
];
// let testdata = [
// [1,2,1,4,1],
// [3,1,4,5,4],
// [2,5,3,5,1],
// [5,4,1,2,3],
// [4,1,3,1,2],
// ];
this.levelData = testdata; this.levelData = testdata;
for(let r=0;r<testdata.length;r++){ for(let r=0;r<testdata.length;r++){
...@@ -549,6 +544,7 @@ export default class GameView extends engine.Container { ...@@ -549,6 +544,7 @@ export default class GameView extends engine.Container {
engine.Tween.removeTweens(snode2); engine.Tween.removeTweens(snode2);
if(this.eliminateArr.length>0){ if(this.eliminateArr.length>0){
this.inEliminate = true;
engine.Tween.get(snode1).to({ engine.Tween.get(snode1).to({
x:snode2x, x:snode2x,
y:snode2y y:snode2y
......
...@@ -17,6 +17,8 @@ export class GameWrapper extends engine.Container { ...@@ -17,6 +17,8 @@ export class GameWrapper extends engine.Container {
engine.globalEvent.addEventListener('game-init',this.init,this); engine.globalEvent.addEventListener('game-init',this.init,this);
engine.globalEvent.addEventListener('game-reset',this.reset,this); engine.globalEvent.addEventListener('game-reset',this.reset,this);
engine.globalEvent.addEventListener('game-start',this.start,this); engine.globalEvent.addEventListener('game-start',this.start,this);
engine.globalEvent.addEventListener('game-pause',this.pause,this);
engine.globalEvent.addEventListener('game-resume',this.resume,this);
} }
init(event:engine.Event){ init(event:engine.Event){
...@@ -36,4 +38,10 @@ export class GameWrapper extends engine.Container { ...@@ -36,4 +38,10 @@ export class GameWrapper extends engine.Container {
start(){ start(){
this._gameView.start(); this._gameView.start();
} }
pause(){
this._gameView.pause();
}
resume(){
this._gameView.resume();
}
} }
...@@ -34,6 +34,44 @@ export default class MapData{ ...@@ -34,6 +34,44 @@ export default class MapData{
static birdTex:engine.Texture; static birdTex:engine.Texture;
static koalaTex:engine.Texture; static koalaTex:engine.Texture;
static levelData:Array<Array<Array<number>>> = [
[
[1,2,5,3,4],
[3,1,2,4,5],
[2,5,3,4,1],
[5,4,1,2,3],
[4,1,3,5,2],
],
[
[5,2,1,2,1],
[3,1,4,5,4],
[2,5,3,5,1],
[5,4,1,2,3],
[4,1,3,1,2],
],
[
[2,4,1,5,2],
[2,3,4,1,3],
[4,1,3,2,3],
[3,2,1,1,4],
[1,1,3,5,4],
],
[
[3,2,1,4,5],
[2,4,1,2,3],
[2,3,2,3,3],
[4,4,5,5,4],
[3,3,1,2,4],
],
[
[4,5,1,2,4],
[3,2,3,4,2],
[1,5,2,3,5],
[4,5,5,1,3],
[1,2,3,2,4],
]
]
static getRy(r){ static getRy(r){
return this.paddingb+r*(this.itemsize+this.paddingi); return this.paddingb+r*(this.itemsize+this.paddingi);
} }
......
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