Fix: porting done

This commit is contained in:
2018-10-31 22:59:43 +09:00
parent 5464642d9b
commit 9c91dcbe22
6 changed files with 349 additions and 53 deletions
+240 -2
View File
@@ -46,7 +46,7 @@ var Game = {
Game.GAME_TIME_SEC,
(function() {
this.setClickEnable(false);
this.showStageNotice("시간 종료");
this.gameOver();
}).bind(this)
);
@@ -60,7 +60,36 @@ var Game = {
this.plusScoreGroup = game.add.group();
var textStyle = { font: "bold 32px Arial", fill: "#fff", align: "center", boundsAlignH: "center", boundsAlignV: "middle" };
this.stageNoticeText = game.add.text(0, 0, "", textStyle);
this.stageNoticeText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
this.stageNoticeText.setTextBounds(0, 60, 1000, 80);
var table = game.add.tileSprite(0, 340, GAME_SCREEN_SIZE.x, 660, 'wooden_table');
this.meatPlate = game.add.image(220, Game.MEAT_PLATE_POSITION_Y, 'plate');
this.meatPlate.anchor.set(0.5);
this.meatPlate.smoothed = false;
this.heatPlate = game.add.image(game.world.centerX, Game.HEAT_PLATE_POSITION_Y, 'heat_plate');
this.heatPlate.anchor.set(0.5);
this.heatPlate.smoothed = false;
this.heatPlate.scale.set(1);
this.god = new God(game.world.width - 120, Game.GOD_POSITION_Y + 100, this);
// meat
this.meatGroup = game.add.group();
for(var i = 0; i < Game.MAX_MEAT_COUNT; i++) {
var meat = new Meat(this);
meat.name = "meat" + i;
meat.setActive(false, -100, -100, "");
this.meatGroup.add(meat);
}
// speech bubble
this.speechBubble = new SpeechBubble(game.world.centerX + 100, game.world.centerY - 160);
this.speechBubble.hideSpeechBubble();
// bottom ui
@@ -75,6 +104,29 @@ var Game = {
},
initVariables: function() {
this.playingStageNo;
this.activatedMeatCount;
this.clearedMeatCount;
// this.score;
// this.scoreText;
// this.highscore;
// this.highscoreText;
this.plusScoreTextGroup;
this.stageNoticeText;
this.popup;
this.popupTween = null;
this.startButton;
// this.leftTimeText;
// this.leftTimeSec;
this.timeEvent;
this.gameTimeEvents = [];
this.meatCount;
},
@@ -116,9 +168,35 @@ var Game = {
*/
startGame: function() {
this.playingStageNo = 1;
// this.leftTimeSec = 0; // INIT_LEFT_TIME_MIN * 60;
// this.score = 0;
// this.updateScore();
this.startStage();
},
startStage: function() {
var bonusTime = this.getBonusTime();
if(this.playingStageNo == 1)
this.showStageNotice(this.playingStageNo + "단계 시작 (제한 시간 : " + bonusTime + "초)");
else if(bonusTime == 0)
this.showStageNotice(this.playingStageNo + "단계 시작");
else
this.showStageNotice(this.playingStageNo + "단계 시작 (보너스 +" + bonusTime + "초)");
// this.leftTimeSec += bonusTime;
this.stageTimer.start();
// this.stageTimer.add(bonusTime);
// this.updateLeftTime();
// if(this.playingStageNo == 1)
// this.timeEvent = game.time.events.loop(1000, this.updateLeftTime, this);
this.activatedMeatCount = this.getStageMeatCount();
this.clearedMeatCount = 0;
this.serveMeats();
},
startNextStage: function() {
@@ -129,6 +207,151 @@ var Game = {
this.isEnableClick = value;
},
getStageMeatCount: function() {
this.activatedMeatCount = this.playingStageNo + 2;
return this.activatedMeatCount;
},
serveMeats: function() {
for(var i = 0; i < Game.MAX_MEAT_COUNT; i++) {
var meat = this.meatGroup.children[i];
meat.setActive(false, -100, -100, "");
}
for(var i = 0; i < this.activatedMeatCount; i++) {
var meat = this.meatGroup.children[i];
var randX = this.meatPlate.x - game.rnd.integerInRange(-100, 100);
var randY = this.meatPlate.y - game.rnd.integerInRange(-30, 30);
meat.setActive(true, randX, randY, "");
}
},
getBonusTime: function() {
if(this.playingStageNo == 1)
return Game.INIT_LEFT_TIME_MIN * 60;
var bonusTime = 0;
if(this.playingStageNo < 10)
bonusTime = Math.floor(10 / this.playingStageNo) * (Game.INIT_LEFT_TIME_MIN * 2);
return bonusTime;
},
// updateLeftTime: function() {
// this.leftTimeSec--;
// this.leftTimeText.text = this.leftTimeSec;
// if(this.leftTimeSec == 0) {
// this.showStageNotice("시간 종료");
// this.gameOver();
// }
// },
showStageNotice: function(text) {
this.stageNoticeText.alpha = 0;
this.stageNoticeText.text = text;
this.animateTextAlpha(this.stageNoticeText, 1, 0, 1000, Phaser.Easing.Linear.None);
},
// addScore: function() {
// // this.score += 10 * this.playingStageNo;
// this.scoreManager.addScore(10 * this.playingStageNo);
// },
// updateScore: function() {
// this.scoreText.text = this.score;
// },
// updateHighscore: function() {
// if(this.score > this.highscore) {
// highscore = score;
// highscoreText.text = highscore;
// showStageNotice("!!! 최고 점수 갱신 !!!");
// }
// },
isOverHeatPlate: function(x, y, width, height) {
var plateHalfWidth = (this.heatPlate.width - Game.HEAT_PLATE_HANDLE_WIDTH) / 2;
var plateHalfHeight = this.heatPlate.height / 2;
if(x < this.heatPlate.x - plateHalfWidth) {
return false;
} else if(this.heatPlate.x + plateHalfWidth < x) {
return false;
} else if(y < this.heatPlate.y - plateHalfHeight + Game.HEAT_PLATE_START_OFFSET_Y) {
return false;
} else if(this.heatPlate.y + plateHalfHeight + Game.HEAT_PLATE_START_OFFSET_Y - Game.HEAT_PLATE_HEIGHT< y) {
return false;
}
return true;
},
isOverGod: function(x, y, width, height) {
// console.log("isOverGod : " + x + ", " + y + ", " + width + ", " + height);
var godHalfWidth = (this.god.width - Game.GOD_OUT_OF_FACE_WIDTH) / 2;
var godHalfHeight = this.god.height / 2;
if(x < this.god.x - godHalfWidth) {
return false;
} else if(this.god.x + godHalfWidth < x) {
return false;
} else if(y < this.god.y - this.god.height + Game.GOD_OUT_OF_FACE_HEIGHT) {
return false;
} else if(this.god.y - Game.GOD_OUT_OF_FACE_HEIGHT < y) {
return false;
}
return true;
},
godEatMeat: function(meat) {
// console.log("isOverGod : " + x + ", " + y + ", " + width + ", " + height);
// console.log("god eat : " + meat);
// console.log("meat grade : " + meat.getMeatGrade());
if(meat.getMeatGrade() == Meat.DONENESS_WELLDONE) {
this.god.animateHappy(Meat.DONENESS_WELLDONE); // "맛있어♥♡♥");
// this.addScore();
// this.updateScore();
this.scoreManager.plusScore(10 * this.playingStageNo);
var tempPlusScore = new PlusScore(this.god.x, this.god.y - 180, 10 * this.playingStageNo);
this.plusScoreGroup.add(tempPlusScore);
} else {
if(meat.getMeatGrade() == Meat.DONENESS_RARE) {
this.god.animateAngry(Meat.DONENESS_RARE); // "날고기 싫어!!!");
} else { // Meat.DONENESS_BURN_BLACK
this.god.animateAngry(Meat.DONENESS_BURN_BLACK); // "탄 고기 안먹어!!!");
}
}
meat.setActive(false, -100, -100, '');
this.clearedMeatCount++;
if(this.clearedMeatCount == this.activatedMeatCount) {
this.clearStage();
}
},
clearStage: function() {
this.showStageNotice(this.playingStageNo + "단계 완료");
this.playingStageNo++;
var startStageTimeEvent = game.time.events.add(Phaser.Timer.SECOND * 1, this.startStage, this);
this.gameTimeEvents[this.gameTimeEvents.length + 1] = startStageTimeEvent;
},
animateTextAlpha: function(targetText, startAlpha, endAlpha, msTime, effectType) {
targetText.alpha = startAlpha;
game.add.tween(targetText).to({alpha: endAlpha}, msTime, effectType, true);
},
gameOver: function() {
@@ -142,4 +365,19 @@ var Game = {
Game.GAME_TIME_SEC = 60;
Game.NEXT_STAGE_DELAY_MS = 500;
Game.NEXT_STAGE_DELAY_MS = 500;
Game.INIT_LEFT_TIME_MIN = 2;
Game.MAX_MEAT_COUNT = 20;
Game.HEAT_PLATE_HANDLE_WIDTH = 440;
Game.HEAT_PLATE_START_OFFSET_Y = 80;
Game.HEAT_PLATE_HEIGHT = 220;
Game.GOD_OUT_OF_FACE_WIDTH = 30;
Game.GOD_OUT_OF_FACE_HEIGHT = 30;
Game.MEAT_PLATE_POSITION_Y = 360;
Game.GOD_POSITION_Y = 240;
Game.HEAT_PLATE_POSITION_Y = GAME_SCREEN_SIZE.y / 2 + 220;