Commit 7d9e81e0 authored by 18손재민's avatar 18손재민

Merge branch 'gameScene'

parents acb37829 9a90fb5b
......@@ -271,7 +271,7 @@ class GameRoom
{
if (this.currentPhase === GameServer.Phase.START)
{
if (this.phaseChanger < 0 && checkTime - this.startTime > 6000)
if (this.phaseChanger < 0 && checkTime - this.startTime > 1000)
{
this.currentPhase = GameServer.Phase.MAIN;
this.rateArrangePoint = 150;
......
......@@ -17,6 +17,16 @@
<script src="js/Enums.js"></script>
<script src="js/ResourceLoader.js"></script>
<script src="js/UIObject.js"></script>
<style media='screen' type='text/css'>
@font-face {
font-family: sejongFont;
src: url('assets/font/EBS주시경B.ttf');
font-weight:400;
font-weight:normal;
}
</style>
<div style="font-family:sejongFont; position:absolute; left:-1000px; visibility:hidden;">.</div>
<style>
img { position: relative; width: 100%; height: 100%; z-index: 0;}
......
......@@ -13,17 +13,17 @@ BackGround.otherCharacters = [];
BackGround.drawCharacter = function(scene)
{
RoomData.myself.playerImage = scene.add.sprite(game.config.width / 2, game.config.height * 41 / 48, 'pyeongminWrite').setScale(0.45).setDepth(2);
RoomData.myself.playerImage = scene.add.sprite(game.config.width / 2, game.config.height * 41 / 48, 'pyeongminWrite').setScale(0.45).setDepth(5);
RoomData.myself.position = new Phaser.Math.Vector2(RoomData.myself.playerImage.x, RoomData.myself.playerImage.y);
BackGround.characterPos = BackGround.characterPos.sort(function(){return 0.5-Math.random()});
RoomData.players.forEach(function(element){
if(element.id != RoomData.myself.id)
{
element.position = BackGround.characterPos.pop();
element.playerImage = scene.add.sprite(element.position.x, element.position.y, 'pyeongminWrite').setScale(0.315).setDepth(1);
element.playerImage = scene.add.sprite(element.position.x, element.position.y, 'pyeongminWrite').setScale(0.315).setDepth(5);
element.playerImage.flipX = element.position.x < game.config.width / 2 ? true : false;
element.nicknameText = scene.add.text(element.position.x, element.position.y - 90, element.nickname)
.setOrigin(0.5,0.5).setColor('#000000').setPadding(0.5,0.5,0.5,0.5).setDepth(1);
.setOrigin(0.5,0.5).setColor('#000000').setPadding(0.5,0.5,0.5,0.5).setDepth(5.1);
6 }
});
}
......@@ -32,7 +32,7 @@ BackGround.gameBackground = null;
BackGround.drawBrain = function(scene)
{
BackGround.gameBackground = scene.add.sprite(game.config.width / 2, game.config.height / 2, 'gameBackground').setDisplaySize(game.config.width, game.config.height).setDepth(1);
BackGround.gameBackground = scene.add.sprite(game.config.width / 2, game.config.height / 2, 'gameBackground').setDisplaySize(game.config.width, game.config.height).setDepth(3.1);
}
BackGround.drawBackground = function(scene)
......@@ -42,10 +42,10 @@ BackGround.drawBackground = function(scene)
BackGround.drawMenu = function(scene)
{
scene.add.sprite(game.config.width / 2, game.config.height / 2, 'menuBackground').setDisplaySize(game.config.width, game.config.height).setDepth(1);
scene.add.sprite(game.config.width / 2, game.config.height / 2, 'menuBackground').setDisplaySize(game.config.width, game.config.height).setDepth(3);
}
BackGround.drawRoom = function(scene)
{
scene.add.sprite(game.config.width / 2, game.config.height / 2, 'roomBackground').setDisplaySize(game.config.width, game.config.height).setDepth(1);
scene.add.sprite(game.config.width / 2, game.config.height / 2, 'roomBackground').setDisplaySize(game.config.width, game.config.height).setDepth(5.2);
}
\ No newline at end of file
......@@ -21,7 +21,7 @@ socket.on('alert', function(msg) // string errorcode
{
//toAlert = '승리!';
ScenesData.gameScene.add.text(game.config.width / 2, game.config.height / 2, '승리!!!!', {fontSize: '30pt'})
.setPadding(5,5,5,5).setOrigin(0.5, 0.5).setDepth(11)
.setPadding(5,5,5,5).setOrigin(0.5, 0.5).setDepth(9.9)
.setColor('#000000').setBackgroundColor('#ffffff');
gameOver();
......@@ -57,8 +57,8 @@ socket.on('syncRoomScene', function(msg)
let randY = Math.random() * 380 + 100;
var playerSet =
{
sprite: ScenesData.roomScene.add.sprite(randX, randY, 'playerStand').setOrigin(0.5, 0.5).setScale(0.2, 0.2),
nickname: ScenesData.roomScene.add.text(randX-10, randY-60, msg[i].nickname).setOrigin(0.5,0.5).setColor('#000000').setPadding(0.5,0.5,0.5,0.5),
sprite: ScenesData.roomScene.add.sprite(randX, randY, 'playerStand').setOrigin(0.5, 0.5).setScale(0.2, 0.2).setDepth(5),
nickname: ScenesData.roomScene.add.text(randX-10, randY-60, msg[i].nickname).setOrigin(0.5,0.5).setColor('#000000').setPadding(0.5,0.5,0.5,0.5).setDepth(5.1),
id: msg[i].id
}
ScenesData.roomScene.players.push(playerSet);
......@@ -79,8 +79,8 @@ socket.on('setRoomCount', function(msg)
let randY = Math.random() * 380 + 100;
var playerSet =
{
sprite: ScenesData.roomScene.add.sprite(randX, randY, 'playerStand').setOrigin(0.5, 0.5).setScale(0.2, 0.2),
nickname: ScenesData.roomScene.add.text(randX-10, randY-60, msg.player.nickname).setOrigin(0.5,0.5).setColor('#000000').setPadding(0.5,0.5,0.5,0.5),
sprite: ScenesData.roomScene.add.sprite(randX, randY, 'playerStand').setOrigin(0.5, 0.5).setScale(0.2, 0.2).setDepth(5),
nickname: ScenesData.roomScene.add.text(randX-10, randY-60, msg.player.nickname).setOrigin(0.5,0.5).setColor('#000000').setPadding(0.5,0.5,0.5,0.5).setDepth(5.1),
id: msg.player.id
}
ScenesData.roomScene.players.push(playerSet);
......@@ -124,22 +124,7 @@ socket.on('startGame', function()
// in game
socket.on('changePhase', function(msg) // number Phase
{
console.log('phase changed from ' + WordSpace.CurrentPhase + ' to ' + msg);
WordSpace.CurrentPhase = msg;
WordSpace.pauseCycle(true);
// 여기서 종이 드르륵 열면됨
let phaseChangeBgr = ScenesData.gameScene.add.sprite(game.config.width / 2, game.config.height / 2, 'phaseChangeBgr').setOrigin(0.5, 0.5).setDepth(10);
ScenesData.gameScene.scene.pause('gameScene');
setTimeout(function()
{
ScenesData.gameScene.scene.resume('gameScene');
// 여기서 종이 닫으면됨
phaseChangeBgr.destroy();
Audio.playSound(ScenesData.gameScene, 'startGame');
WordSpace.pauseCycle(false);
//console.log('start again');
}, 5000);
WordSpace.changePhase(msg);
});
socket.on('setPlayerTypingRate', function(msg) // number playerTypingRate
{
......@@ -183,6 +168,35 @@ socket.on('attacked', function(msg) // object attackData
WordSpace.attackedEvents.push(attackedEvent);
//console.log(timeout);
});
socket.on('someoneItemStart', function(msg)
{
let itemPlayer = RoomData.findPlayer(msg.id);
let size = msg.id == RoomData.myself.id ? 1 : 0.7;
let xOffset = msg.id != RoomData.myself.id && itemPlayer.position.x < game.config.width / 2 ? -1 : 1;
switch(msg.itemType)
{
case Enums.item.invincible:
itemPlayer.invincibleMark = ScenesData.gameScene.add.sprite(itemPlayer.position.x + 20 * size * xOffset, itemPlayer.position.y - 50 * size, 'attackPaper')
.setDepth(5.3).setOrigin(0.5, 0.5).setScale(size);
break;
default:
console.log('Improper item type.');
break;
}
});
socket.on('someoneItemEnd', function(msg)
{
let itemPlayer = RoomData.findPlayer(msg.id);
switch(msg.itemType)
{
case Enums.item.invincible:
itemPlayer.invincibleMark.destroy();
break;
default:
console.log('Improper item type.');
break;
}
});
socket.on('defeat', function(msg) // object player
{
......@@ -194,18 +208,60 @@ socket.on('defeat', function(msg) // object player
RoomData.players[msg.index].position = position;
RoomData.players[msg.index].nicknameText = nicknameText;
let victim = RoomData.findPlayer(msg.id);
RoomData.aliveCount--;
RoomData.findPlayer(msg.id).playerImage.play(WordSpace.pyeongminAnims[Enums.characterAnim.gameOver]);
victim.playerImage.play(WordSpace.pyeongminAnims[Enums.characterAnim.gameOver]);
if (msg.lastAttack != null)
{
let lastAttacker = RoomData.findPlayer(msg.lastAttack.attackerId).nickname;
console.log(RoomData.findPlayer(msg.id).nickname + ' defeated by ' + lastAttacker + ', with ' + msg.lastAttack.word);
WordSpace.killLogForTest += ('\n' + lastAttacker + ' --' + msg.lastAttack.word + '-> ' + RoomData.findPlayer(msg.id).nickname);
if(msg.lastAttack.attackerId == RoomData.myself.id)
let lastAttacker = RoomData.findPlayer(msg.lastAttack.attackerId);
let attackWord = msg.lastAttack.word;
console.log(victim.nickname + ' defeated by ' + lastAttacker.nickname + ', with ' + msg.lastAttack.word);
if(WordSpace.lastAttackGroup.length != 0)
{
var keys = Object.keys(Enums.item);
WordSpace.generateWord.Item(ScenesData.gameScene, Enums.item[keys[keys.length * Math.random() << 0]]);
let itemBag = ScenesData.gameScene.add.sprite(RoomData.myself.position.x, RoomData.myself.position.y, 'itemBag').setScale(0).setDepth(5);
WordSpace.lastAttackGroup.forEach(function(element){
element.destroy();
})
}
let attackerLabel = UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 - 400, 0, 10.2, 'nameBgr' + lastAttacker.nickname.length, 2,
'center', lastAttacker.nickname, 50, '#ffffff', 0.45, 0.5);
let wordLabel = UIObject.createLabel(ScenesData.gameScene, game.config.width / 2, 0, 10.2, 'wordBgr' + msg.lastAttack.wordGrade + '_' + attackWord.length, 2,
'center', attackWord, 50, '#000000', 0.45, 0.5);
let victimLabel = UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 + 400, 0, 10.2, 'nameBgr' + victim.nickname.length, 2,
'center', victim.nickname, 50, '#ffffff', 0.45, 0.5);
let explosionEffect = ScenesData.gameScene.add.sprite(game.config.width / 2, 0, 'wordBreak').setScale(1).setDepth(10.2);
explosionEffect.play('wordBreakAnim');
explosionEffect.anims.setRepeat(-1);
WordSpace.lastAttackGroup.push(attackerLabel);
WordSpace.lastAttackGroup.push(wordLabel);
WordSpace.lastAttackGroup.push(victimLabel);
WordSpace.lastAttackGroup.push(explosionEffect);
ScenesData.gameScene.tweens.add({
targets: [attackerLabel, wordLabel, victimLabel, explosionEffect],
y: 100,
ese: 'Linear',
duration: 500,
repeat: 0,
onComplete: function () {
setTimeout(function() {
ScenesData.gameScene.tweens.add({
targets: [attackerLabel, wordLabel, victimLabel, explosionEffect],
y: -100,
ease: 'Linear', // 'Cubic', 'Elastic', 'Bounce', 'Back'
duration: 500,
repeat: 0, // -1: infinity
yoyo: false });
}, 1000);
},
})
let itemBag = ScenesData.gameScene.add.sprite(lastAttacker.position.x, lastAttacker.position.y,
'itemBag').setScale(0).setDepth(5.3);
ScenesData.gameScene.tweens.add({
targets: itemBag,
scaleX: 1,
......@@ -222,27 +278,78 @@ socket.on('defeat', function(msg) // object player
scaleY: 0,
ease: 'Linear', // 'Cubic', 'Elastic', 'Bounce', 'Back'
duration: 500,
repeat: 0, // -1: infinity
yoyo: false });
}, 1500);
},
onCompleteScope: ScenesData.gameScene
repeat: 0,
onComplete: function()
{
attackerLabel.destroy();
wordLabel.destroy();
victimLabel.destroy();
explosionEffect.destroy();
}
});
}, 1000);
}
});
setTimeout(function() {
itemBag.destroy();
}, 3000);
if(msg.lastAttack.attackerId == RoomData.myself.id)
{
var keys = Object.keys(Enums.item);
WordSpace.generateWord.Item(ScenesData.gameScene, Enums.item[keys[keys.length * Math.random() << 0]]);
RoomData.myself.killCount++;
}
}
else
{
console.log(RoomData.findPlayer(msg.id).nickname + ' defeated');
WordSpace.killLogForTest += ('\n--Suicide->' + RoomData.findPlayer(msg.id).nickname);
console.log(victim.nickname + ' defeated');
if(WordSpace.lastAttackGroup.length != 0)
{
WordSpace.lastAttackGroup.forEach(function(element){
element.destroy();
})
}
let victimLabel = UIObject.createLabel(ScenesData.gameScene, game.config.width / 2, 0, 10.2, 'nameBgr' + victim.nickname.length, 2, 'center', victim.nickname, 50, '#ffffff', 0.45, 0.5);
let explosionEffect = ScenesData.gameScene.add.sprite(game.config.width / 2, 0, 'wordBreak').setScale(1).setDepth(10.2);
explosionEffect.play('wordBreakAnim');
explosionEffect.anims.setRepeat(-1);
explosionEffect.anims.setRepeat(-1);
WordSpace.lastAttackGroup.push(victimLabel);
WordSpace.lastAttackGroup.push(explosionEffect);
ScenesData.gameScene.tweens.add({
targets: [victimLabel, explosionEffect],
y: 100,
ese: 'Linear',
duration: 500,
repeat: 0,
onComplete: function () {
setTimeout(function() {
ScenesData.gameScene.tweens.add({
targets: [victimLabel, explosionEffect],
y: -100,
ease: 'Linear', // 'Cubic', 'Elastic', 'Bounce', 'Back'
duration: 500,
repeat: 0,
onComplete: function()
{
victimLabel.destroy();
explosionEffect.destroy();
}
});
}, 1000);
}
})
}
if(msg.id == RoomData.myself.id)
{
RoomData.myself = RoomData.players[msg.index];
backToMenu(false);
setTimeout(() => {
gameEndMenu(true);
}, 2000);
}
});
socket.on('gameEnd', function(msg) // number winnerId
......@@ -252,7 +359,9 @@ socket.on('gameEnd', function(msg) // number winnerId
if(msg == RoomData.myself.id)
{
RoomData.myself.rank = 1;
backToMenu(true);
setTimeout(() => {
gameEndMenu(true);
}, 2000);
}
});
......@@ -275,8 +384,11 @@ socket.on('userDisconnect', function(msg) // {num index , num id, str nickname}
RoomData.aliveCount--;
});
var backToMenu = function(isWin)
var gameEndMenu = function(isWin)
{
WordSpace.isGameOver = true;
ScenesData.gameScene.warningImage.destroy();
ScenesData.gameScene.warningTween.remove();
let earnedMoney = 0;
if(isWin) earnedMoney += 20;
earnedMoney += RoomData.myself.killCount * 3;
......@@ -284,6 +396,8 @@ var backToMenu = function(isWin)
earnedMoney += Math.max(20, Math.pow(RoomData.myself.attackSucceed, 2));
earnedMoney += parseInt(20 * (1 - (RoomData.myself.rank - 1) / (RoomData.players.length - 1)));
Input.inputField.text.destroy();
var temp = function(){
socket.emit('exitFromRoom', RoomData.myself.id);
......@@ -302,14 +416,14 @@ var backToMenu = function(isWin)
x: game.config.width / 2,
y: game.config.height / 2,
choices: [
UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 - 100, game.config.height / 2 - 100, 0, 'playerStand', 0.7, 'center'),
UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 + 120, game.config.height / 2 - 150, 0,
UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 - 100, game.config.height / 2 - 100, 10.2, 'playerStand', 0.7, 'center'),
UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 + 120, game.config.height / 2 - 150, 10.2,
'button', 1, 'center', '등수 : ' + RoomData.myself.rank + '', 30).layout(),
UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 + 120, game.config.height / 2 - 50, 0,
UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 + 120, game.config.height / 2 - 50, 10.2,
'button', 1, 'center', '킬 수 : ' + RoomData.myself.killCount + '', 30).layout(),
UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 + 120, game.config.height / 2 + 50, 0,
UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 + 120, game.config.height / 2 + 50, 10.2,
'button', 1, 'center', '획득 강호패 : ' + RoomData.myself.earnedStrongHopae + '', 30).layout(),
UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 + 120, game.config.height / 2 + 150, 0,
UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 + 120, game.config.height / 2 + 150, 10.2,
'button', 1, 'center', '획득 골드 : ' + earnedMoney + '', 30).layout()
],
......@@ -318,8 +432,8 @@ var backToMenu = function(isWin)
}
}),
actions: [
UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 - 120, game.config.height / 2 + 300, 20, 'button', 1, 'center', '나가기').layout(),
UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 + 120, game.config.height / 2 + 300, 20, 'button', 1, 'center', '관전하기').layout()
UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 - 120, game.config.height / 2 + 300, 10.2, 'button', 1, 'center', '나가기').layout(),
UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 + 120, game.config.height / 2 + 300, 10.2, 'button', 1, 'center', '관전하기').layout()
],
space: {
......@@ -334,7 +448,7 @@ var backToMenu = function(isWin)
align: {
actions: 'center' // 'center'|'left'|'right'
}
}).setDepth(20);
}).setDepth(10.2);
ScenesData.gameScene.backToMenuDialog
.on('button.click', function (button, groupName, index) {
......@@ -342,7 +456,7 @@ var backToMenu = function(isWin)
else
{
ScenesData.gameScene.backToMenuDialog.setVisible(false);
ScenesData.gameScene.backToMenuBtn = UIObject.createButton(ScenesData.gameScene, UIObject.createLabel(ScenesData.gameScene, 100, 900, 5, 'pyeongminThrow', 0.5, 'center'), 1, 0, 2, temp);
ScenesData.gameScene.backToMenuBtn = UIObject.createButton(ScenesData.gameScene, UIObject.createLabel(ScenesData.gameScene, 100, 900, 10.2, 'pyeongminThrow', 0.5, 'center'), 1, 0, 2, temp);
}
}, ScenesData.gameScene)
.on('button.over', function (button, groupName, index) {
......
......@@ -21,7 +21,7 @@ Input.attackOption = {
Input.gameSceneEnterReaction = function()
{
if (!Input.isEntered)
if (RoomData.myself.isAlive && !Input.isEntered)
{
if (Input.attackMode) WordSpace.attack(Input.removeConVow(Input.finalInput), Input.attackOption.wordGrade);
else WordSpace.findWord(Input.finalInput);
......@@ -384,7 +384,7 @@ Input.inputField =
Input.pushInput = function(inputKey)
{
if (this.justPressed != inputKey)
if ((ScenesData.currentScene != 'gameScene' || RoomData.myself.isAlive) && this.justPressed != inputKey)
{
this.justPressed = inputKey;
let output;
......
......@@ -2,7 +2,7 @@ var ResourceLoader = ResourceLoader || {};
ResourceLoader.loadBackGround = function(scene)
{
scene.load.image('brain', 'assets/image/background/brain.png');
scene.load.image('weightWarning', 'assets/image/background/weightWarning.png');
scene.load.image('baseBackground', 'assets/image/background/yellowBack.png');
scene.load.image('gameBackground', 'assets/image/background/background_brain.png');
scene.load.image('menuBackground', 'assets/placeholder/menuBackground.png');
......@@ -42,7 +42,9 @@ ResourceLoader.loadImage = function(scene)
scene.load.image('pyeongminStand', 'assets/image/character/pyeongmin/pyeong_stand.png');
scene.load.spritesheet('wordBreak', 'assets/image/word/wordbreak.png', { frameWidth: 180, frameHeight: 180 });
scene.load.image('phaseChangeBgr', 'assets/placeholder/phaseChange.png');
scene.load.spritesheet('phase1', 'assets/image/etc/scroll/startPhase/startPhase.png', { frameWidth: 280, frameHeight: 920 });
scene.load.spritesheet('phase2', 'assets/image/etc/scroll/bonPhase/bonPhase.png', { frameWidth: 280, frameHeight: 920 });
scene.load.spritesheet('phase3', 'assets/image/etc/scroll/poongPhase/poongPhase.png', { frameWidth: 280, frameHeight: 920 });
scene.load.image('attackPaper', 'assets/image/etc/paper_crumbled.png');
scene.load.image('panel', 'assets/placeholder/panel.png');
scene.load.image('button', 'assets/placeholder/button.png');
......@@ -55,56 +57,66 @@ ResourceLoader.loadAnimation = function(scene)
key: 'wordBreakAnim',
frames: scene.anims.generateFrameNumbers('wordBreak'),
frameRate: 10,
repeat: 0,
hideOnComplete: false
repeat: 0
});
scene.anims.create({
key: 'phase1Anim',
frames: scene.anims.generateFrameNumbers('phase1'),
frameRate: 20,
repeat: 0
});
scene.anims.create({
key: 'phase2Anim',
frames: scene.anims.generateFrameNumbers('phase2'),
frameRate: 20,
repeat: 0
});
scene.anims.create({
key: 'phase3Anim',
frames: scene.anims.generateFrameNumbers('phase3'),
frameRate: 20,
repeat: 0
});
WordSpace.pyeongminAnims[Enums.characterAnim.sit] = scene.anims.create({
key: 'pyeongminSitAnim',
frames: scene.anims.generateFrameNumbers('pyeongminSit'),
frameRate: 10,
repeat: 0,
hideOnComplete: false
repeat: 0
});
WordSpace.pyeongminAnims[Enums.characterAnim.write] = scene.anims.create({
key: 'pyeongminWriteAnim',
frames: scene.anims.generateFrameNumbers('pyeongminWrite'),
frameRate: 10,
repeat: 0,
hideOnComplete: false
repeat: 0
});
WordSpace.pyeongminAnims[Enums.characterAnim.notBurning] = scene.anims.create({
key: 'pyeongminnotBurningAnim',
frames: scene.anims.generateFrameNumbers('pyeongminWrite'),
frameRate: 10,
repeat: -1,
hideOnComplete: false
repeat: -1
});
WordSpace.pyeongminAnims[Enums.characterAnim.smallBurning] = scene.anims.create({
key: 'pyeongminsmallBurningAnim',
frames: scene.anims.generateFrameNumbers('pyeongminBurningSmall'),
frameRate: 10,
repeat: -1,
hideOnComplete: false
repeat: -1
});
WordSpace.pyeongminAnims[Enums.characterAnim.bigBurning] = scene.anims.create({
key: 'pyeongminbigBurningAnim',
frames: scene.anims.generateFrameNumbers('pyeongminBurningBig'),
frameRate: 10,
repeat: -1,
hideOnComplete: false
repeat: -1
});
WordSpace.pyeongminAnims[Enums.characterAnim.throw] = scene.anims.create({
key: 'pyeongminThrowAnim',
frames: scene.anims.generateFrameNumbers('pyeongminThrow'),
frameRate: 10,
repeat: 0,
hideOnComplete: false
repeat: 0
});
WordSpace.pyeongminAnims[Enums.characterAnim.gameOver] = scene.anims.create({
key: 'pyeongminGameOverAnim',
frames: scene.anims.generateFrameNumbers('pyeongminGameOver'),
frameRate: 10,
repeat: 0,
hideOnComplete: false
repeat: 0
});
}
\ No newline at end of file
......@@ -45,8 +45,8 @@ var menuScene = new Phaser.Class(
PlayerData.currentHopae = (PlayerData.userData.recentHopae == null) ? PlayerData.userData.hopae[0] : PlayerData.userData.recentHopae;
PlayerData.nickname = PlayerData.currentHopae.name;
this.userName = this.add.text(100, 100, '내 이름 : ' + PlayerData.userData.userName).setOrigin(0, 0.5).setColor('#000000').setDepth(10).setPadding(5,5,5,5).setFontSize(40);
this.money = this.add.text(100, 200, '소지 엽전 : ' + PlayerData.userData.money).setOrigin(0, 0.5).setColor('#000000').setDepth(10).setPadding(5,5,5,5).setFontSize(40);
this.userName = this.add.text(100, 100, '내 이름 : ' + PlayerData.userData.userName).setOrigin(0, 0.5).setColor('#000000').setDepth(9.9).setPadding(5,5,5,5).setFontSize(40);
this.money = this.add.text(100, 200, '소지 엽전 : ' + PlayerData.userData.money).setOrigin(0, 0.5).setColor('#000000').setDepth(9.9).setPadding(5,5,5,5).setFontSize(40);
this.organizeHopae = function()
{
......@@ -68,7 +68,7 @@ var menuScene = new Phaser.Class(
this.hopaeMenuObject = [];
for(let i = 0; i < this.myHopae.length; i++)
{
let temp = UIObject.createButton(this, UIObject.createLabel(this, 100, 300, 10,
let temp = UIObject.createButton(this, UIObject.createLabel(this, 100, 300, 5,
'nameBgr' + ScenesData.menuScene.myHopae[i].name.length, 1, 'left', ScenesData.menuScene.myHopae[i].name, 25, '#ffffff', 0.45, 0.5), 0, 0, 0,
function()
{
......@@ -101,7 +101,7 @@ var menuScene = new Phaser.Class(
this.createCurrentHopae = function()
{
this.currentHopaeBtn = UIObject.createButton(this, UIObject.createLabel(this, 100, 300, 10,
this.currentHopaeBtn = UIObject.createButton(this, UIObject.createLabel(this, 100, 300, 5,
'nameBgr' + PlayerData.nickname.length, 1, 'left', PlayerData.nickname, 25, '#ffffff', 0.45, 0.5), 0, 0, 0,
function()
{
......@@ -122,7 +122,7 @@ var menuScene = new Phaser.Class(
background: this.add.sprite(game.config.width / 2, game.config.height / 2, 'panel').setOrigin(0.5, 0.5),
content: this.add.text(0, 0, '대기실에 참가하시겠습니까?', {
font: '50pt 궁서'
font: '50pt sejongFont'
}),
actions: [
......@@ -147,7 +147,7 @@ var menuScene = new Phaser.Class(
expand: {
content: false, // Content is a pure text object
}
}).layout().setDepth(10).setVisible(false);
}).layout().setDepth(11).setVisible(false);
this.roomEnterDialog
.on('button.click', function (button, groupName, index) {
......@@ -230,8 +230,8 @@ var hopaeScene = new Phaser.Class(
background: this.add.sprite(game.config.width / 2, game.config.height / 2, 'panel').setOrigin(0.5, 0.5),
content: this.add.text(0, 0, '이 이름으로 하시겠습니까?' + (PlayerData.userData.hopae == undefined ? '\n(최초 호패는 비용이 들지 않습니다.)' : '\n변경에는 엽전이 소모됩니다.'), {
font: '50pt 궁서',
content: this.add.text(0, 0, '이 이름으로 하시겠습니까?' + (PlayerData.userData.hopae.length == 0 ? '\n(최초 호패는 비용이 들지 않습니다.)' : '\n변경에는 엽전이 소모됩니다.'), {
font: '50pt sejongFont',
color: '#000000',
align: 'center'
}),
......@@ -258,7 +258,7 @@ var hopaeScene = new Phaser.Class(
expand: {
content: false, // Content is a pure text object
}
}).layout().setDepth(10).setVisible(false);
}).layout().setDepth(11).setVisible(false);
this.checkDialog
.on('button.click', function (button, groupName, index) {
......@@ -295,7 +295,7 @@ var hopaeScene = new Phaser.Class(
.on('button.out', function (button, groupName, index) {
//console.log('button out');
});
this.warningText = UIObject.createLabel(this, game.config.width / 2, game.config.height / 2 - 100, 2, 'panel', 1, 'center',
this.warningText = UIObject.createLabel(this, game.config.width / 2, game.config.height / 2 - 100, 5, 'panel', 1, 'center',
'이름 타수가 많아 플레이에 패널티가 있을 수 있습니다', 40, '#000000').setVisible(false).layout();
this.checkBtn = UIObject.createButton(this, UIObject.createLabel(this, game.config.width / 2, 900, 5, 'pyeongminWrite', 0.5, 'center'), 1, 0, 2,
......@@ -347,8 +347,8 @@ var roomScene = new Phaser.Class(
this.isCountEnd = false;
this.endTime = 0;
this.peopleCount = 1;
this.countText = this.add.text(game.config.width / 2, game.config.height / 2, '사람들을 위해 대기중입니다...').setOrigin(0.5, 0.5).setColor('#000000').setBackgroundColor('#ffffff').setDepth(10).setPadding(5,5,5,5);
this.peopleText = this.add.text(game.config.width / 2, game.config.height / 9, '1 / 10').setOrigin(0.5, 0.5).setColor('#000000').setBackgroundColor('#ffffff').setDepth(10);
this.countText = this.add.text(game.config.width / 2, game.config.height / 2, '사람들을 위해 대기중입니다...').setOrigin(0.5, 0.5).setColor('#000000').setBackgroundColor('#ffffff').setDepth(9.9).setPadding(5,5,5,5);
this.peopleText = this.add.text(game.config.width / 2, game.config.height / 9, '1 / 10').setOrigin(0.5, 0.5).setColor('#000000').setBackgroundColor('#ffffff').setDepth(9.9);
},
update: function()
......@@ -431,8 +431,6 @@ var gameScene = new Phaser.Class(
sceneKey: 'button'
});
WordSpace.resetGame();
WordSpace.weightTextObjForTest = this.add.text(game.config.width * 5 / 64, game.config.height * 5 / 48, '뇌의 무게: (현재) 0 / ' + this.brainCapacity + ' (전체)').setDepth(10).setColor('#000000');
WordSpace.killLogTextForTest = this.add.text(game.config.width * 25 / 32, game.config.height * 5 / 72, WordSpace.killLogForTest).setDepth(10).setColor('#000000').setAlign('right');
},
create: function()
......@@ -445,6 +443,7 @@ var gameScene = new Phaser.Class(
BackGround.drawBrain(this);
BackGround.drawCharacter(this);
Audio.playSound(this, 'startGame');
WordSpace.attackPaperGroup = this.physics.add.group();
WordSpace.wordPhysicsGroup = this.physics.add.group();
Input.inputField.generate(this, Input.gameSceneEnterReaction,
......@@ -459,8 +458,20 @@ var gameScene = new Phaser.Class(
WordSpace.setPlayerTyping.initiate(this);
WordSpace.nameQueue.initiate();
//WordSpace.attackGauge.add(11);
this.warningImage = this.add.sprite(game.config.width / 2, game.config.height / 2, 'weightWarning').setDisplaySize(game.config.width, game.config.height).setDepth(0.1).setAlpha(0)
this.warningTween = this.tweens.add({
targets: this.warningImage,
alpha: 1,
duration: 500,
ease: 'Linear',
yoyo: true,
repeat: -1
});
this.warningTween.timeScale = 0;
WordSpace.changePhase(WordSpace.Phase.START);
},
update: function()
......@@ -476,13 +487,19 @@ var gameScene = new Phaser.Class(
{
element.attract();
})
WordSpace.attackPaperGroup.forEach(function(element){
WordSpace.attackPaperGroup.getChildren().forEach(function(element){
element.moveObject(element);
});
WordSpace.weightTextObjForTest.setText('뇌의 무게: (현재) '+WordSpace.totalWeight+' / '+ WordSpace.brainCapacity+' (전체)');
WordSpace.killLogTextForTest.setText(WordSpace.killLogForTest);
WordSpace.setPlayerTyping.add('');
if(!WordSpace.isGameOver)
{
if(WordSpace.totalWeight < 180) this.warningTween.timeScale = 0;
else if(WordSpace.totalWeight < 190) this.warningTween.timeScale = 0.3;
else if(WordSpace.totalWeight < 200) this.warningTween.timeScale = 0.6;
else if(WordSpace.isTimerOn) this.warningTween.timeScale = 0.6 + WordSpace.gameOverCycle.currentCycle.getElapsed() / WordSpace.delay.GameOver * 3;
}
}
}
});
......
......@@ -10,7 +10,7 @@ UIObject.createLabel = function (scene, x, y, depth, image, size, align, text =
background: scene.add.sprite(x, y, image).setScale(size).setOrigin(0.5, 0.5).setDepth(depth),
text: scene.add.text(x, y, text, {
font: textSize + 'pt 궁서',
font: textSize + 'pt sejongFont',
align: 'center'
}).setDepth(depth).setOrigin(textOriginX, textOriginY).setColor(textColor),
......
......@@ -20,7 +20,7 @@ class WordObject
var random = WordSpace.getSpawnPoint(lenRate);
this.physicsObj = scene.physics.add.sprite(random.x, random.y, spriteName).setMass(this.wordWeight * 10).setScale(this.scale)
.setFrictionX(0).setFrictionY(0).setBounce(0.5);
.setFrictionX(0).setFrictionY(0).setBounce(0.5).setDepth(1);
this.physicsObj.wordCollider = null;
let dist = Phaser.Math.Distance.Between(this.physicsObj.x, this.physicsObj.y, WordSpace.gravityPoint.x, WordSpace.gravityPoint.y);
let angle = Phaser.Math.Angle.Between(this.physicsObj.x, this.physicsObj.y, WordSpace.gravityPoint.x, WordSpace.gravityPoint.y);
......@@ -31,11 +31,10 @@ class WordObject
this.wordObj = scene.add.text(random.x, random.y, this.wordText,
{
fontSize: (this.scale * this.fontScale) +'pt',
fontFamily: '"궁서", 궁서체, serif',
font: (this.scale * this.fontScale) +'pt sejongFont',
//fontStyle: (this.wordWeight > 5 ? 'bold' : '')
});
this.wordObj.setColor(textColor).setOrigin(0.5,0.5);
this.wordObj.setColor(textColor).setOrigin(0.5,0.5).setDepth(1);
this.createdTime = WordSpace.gameTimer.now;
WordSpace.totalWeight += this.wordWeight;
WordSpace.totalWordNum += 1;
......@@ -54,7 +53,7 @@ class WordObject
const forceIdx = WordSpace.wordForcedGroup.findIndex(function(item) {return this.isEqualObject(item.generationCode)}, this);
if (forceIdx > -1) WordSpace.wordForcedGroup.splice(forceIdx, 1);
WordSpace.wordPhysicsGroup.remove(this.physicsObj);
let breakAnim = ScenesData.gameScene.add.sprite(this.physicsObj.x, this.physicsObj.y, 'wordBreak').setScale(0.5).setDepth(3).play('wordBreakAnim');
let breakAnim = ScenesData.gameScene.add.sprite(this.physicsObj.x, this.physicsObj.y, 'wordBreak').setScale(0.5).setDepth(1.1).play('wordBreakAnim');
setTimeout(function() {
breakAnim.destroy();
}, 200);
......@@ -261,8 +260,7 @@ class NameWord extends WordObject
{
this.physicsObj.setScale(this.follower.t < 0.2 ? 0.2 : this.follower.t * this.scale);
this.wordObj.setFont({
fontSize: (this.follower.t < 0.2 ? 0.05 : this.follower.t * this.scale * this.fontScale) +'pt',
fontFamily: '"궁서", 궁서체, serif',
font: (this.follower.t < 0.2 ? 0.05 : this.follower.t * this.scale * this.fontScale) +'pt sejongFont',
fontStyle: (this.wordWeight > 5 ? 'bold' : '')
});
}
......@@ -285,8 +283,8 @@ class NameWord extends WordObject
if(!this.isStrong) WordSpace.attackGauge.add(this.wordTyping * 0.1);
WordSpace.nameGroup.push(this);
this.isActive = false;
this.physicsObj.setVelocity(0, 0).setDepth(20);
this.wordObj.setPosition(this.physicsObj.x, this.physicsObj.y).setDepth(20);
this.physicsObj.setVelocity(0, 0).setDepth(10.2);
this.wordObj.setPosition(this.physicsObj.x, this.physicsObj.y).setDepth(10.2);
this.follower = { t: 0, vec: new Phaser.Math.Vector2() };
this.path = new Phaser.Curves.Spline([
this.physicsObj.x, this.physicsObj.y,
......@@ -363,8 +361,10 @@ class ItemWord extends WordObject
{
case Enums.item.invincible:
WordSpace.isInvincible = true;
socket.emit('itemStart', {id: RoomData.myself.id, itemType: Enums.item.invincible});
setTimeout(() => {
WordSpace.isInvincible = false;
socket.emit('itemEnd', {id: RoomData.myself.id, itemType: Enums.item.invincible});
}, 5000);
break;
case Enums.item.nameList:
......
var WordSpace = WordSpace || {};
// for test
WordSpace.weightTextObjForTest = null;
WordSpace.nameWordTextForTest = null;
WordSpace.killLogTextForTest = null;
WordSpace.killLogForTest = '';
WordSpace.nextWordCode = 0;
WordSpace.totalWeight = 0; //현재 단어 무게 총합
WordSpace.totalWordNum = 0;
WordSpace.brainCapacity = 200; //수용 가능한 단어 무게 최대치
WordSpace.gameTimer = null; //현재 게임 플레이 시간 타이머
WordSpace.isGameOver = false;
WordSpace.isTimerOn = false;
WordSpace.isInvincible = false;
WordSpace.pyeongminAnims = [];
WordSpace.wordGroup = [];
WordSpace.nameGroup = [];
WordSpace.attackPaperGroup = [];
WordSpace.attackPaperGroup = null;
WordSpace.wordForcedGroup = [];
WordSpace.wordPhysicsGroup = null;
WordSpace.lastAttackGroup = [];
WordSpace.GradeProb = [0.35, 0.6, 0.8];
WordSpace.Phase = {READY: 0, START: 1, MAIN: 2, MUSIC: 3};
......@@ -112,7 +110,7 @@ WordSpace.attackGauge =
generate: function(scene)
{
//console.log("created");
this.rectUI = scene.add.rectangle(game.config.width / 2, game.config.height * 5 / 6, 0, game.config.height * 11 / 720).setDepth(11);
this.rectUI = scene.add.rectangle(game.config.width / 2, game.config.height * 5 / 6, 0, game.config.height * 11 / 720).setDepth(10.1);
},
add: function(plus)
{
......@@ -143,7 +141,7 @@ WordSpace.attackGauge =
};
this.currentCycle = scene.time.addEvent(option);
this.text = scene.add.text(100,100,'게이지: ' + this.value.toFixed(1)).setDepth(10).setColor('#000000');
this.text = scene.add.text(100,100,'게이지: ' + this.value.toFixed(1)).setDepth(9.9).setColor('#000000');
//this.rectUI.setColor(this.gradeColor[0]);
},
pauseCycle: function(bool) {this.currentCycle.paused = bool;},
......@@ -343,7 +341,7 @@ WordSpace.setPlayerTyping =
},
initiate: function(scene)
{
this.text = scene.add.text(100,200,'현재 타수 : ' + WordSpace.playerTyping.toFixed(1)).setDepth(10).setColor('#000000');
this.text = scene.add.text(100,200,'현재 타수 : ' + WordSpace.playerTyping.toFixed(1)).setDepth(9.9).setColor('#000000');
},
reset: function()
{
......@@ -417,14 +415,17 @@ WordSpace.attack = function(wordText, grade)
WordSpace.makeAttackPaper = function(scene, attackFrom, attackTo, multiple)
{
var attackPaper = scene.add.sprite(attackFrom.x, attackFrom.y, 'attackPaper').setScale(0.5 * multiple).setDepth(3);
let size = attackTo == RoomData.myself.position ? 1 : 0.7;
let xOffset = attackTo != RoomData.myself.position && attackTo.x < game.config.width / 2 ? -1 : 1;
var attackPaper = scene.add.sprite(attackFrom.x, attackFrom.y, 'attackPaper').setScale(0.5 * multiple).setDepth(5.2);
attackPaper.mask = new Phaser.Display.Masks.BitmapMask(scene, BackGround.gameBackground);
attackPaper.throwTarget = attackTo;
attackPaper.follower = { t: 0, vec: new Phaser.Math.Vector2() };
attackPaper.path = new Phaser.Curves.Spline([
attackFrom.x, attackFrom.y,
(attackFrom.x + attackPaper.throwTarget.x) / 2, Math.min(attackFrom.y, attackPaper.throwTarget.y) - 100,
attackPaper.throwTarget.x, attackPaper.throwTarget.y - 10
attackPaper.throwTarget.x + 20 * size * xOffset, attackPaper.throwTarget.y - 50 * size
]);
scene.tweens.add({
targets: attackPaper.follower,
......@@ -432,9 +433,8 @@ WordSpace.makeAttackPaper = function(scene, attackFrom, attackTo, multiple)
ease: 'Linear',
duration: 4000,
repeat: 0,
onComplete: function() {
attackPaper.destroy();
WordSpace.attackPaperGroup = [];
onComplete: function() {
WordSpace.attackPaperGroup.remove(attackPaper, true);
}
});
attackPaper.moveObject = function(obj)
......@@ -443,7 +443,7 @@ WordSpace.makeAttackPaper = function(scene, attackFrom, attackTo, multiple)
obj.setPosition(obj.follower.vec.x, obj.follower.vec.y);
obj.angle = 720 * obj.follower.t;
}
WordSpace.attackPaperGroup.push(attackPaper);
WordSpace.attackPaperGroup.add(attackPaper);
}
WordSpace.nameQueue =
......@@ -488,25 +488,41 @@ WordSpace.nameQueue =
this.shuffle();
}
}
WordSpace.changePhase = function(newPhase)
{
console.log('phase changed from ' + WordSpace.CurrentPhase + ' to ' + newPhase);
WordSpace.CurrentPhase = newPhase;
//WordSpace.pauseCycle(true);
// 여기서 종이 드르륵 열면됨
let phaseChangeBgr = ScenesData.gameScene.add.sprite(game.config.width / 2, game.config.height / 2, 'phase' + newPhase).setOrigin(0.5, 0.5).setDepth(9.9).play('phase' + newPhase + 'Anim');
//ScenesData.gameScene.scene.pause('gameScene');
setTimeout(function()
{
//ScenesData.gameScene.scene.resume('gameScene');
// 여기서 종이 닫으면됨
phaseChangeBgr.anims.playReverse('phase' + newPhase + 'Anim');
phaseChangeBgr.on('animationcomplete', function(currentAnim, currentFrame, sprite){sprite.destroy()});
Audio.playSound(ScenesData.gameScene, 'startGame');
//WordSpace.pauseCycle(false);
//console.log('start again');
}, 5000);
}
WordSpace.resetGame = function()
{
WordSpace.weightTextObjForTest = null;
WordSpace.nameWordTextForTest = null;
WordSpace.killLogTextForTest = null;
WordSpace.killLogForTest = '';
WordSpace.nextWordCode = 0;
WordSpace.totalWeight = 0; //현재 단어 무게 총합
WordSpace.totalWordNum = 0;
WordSpace.brainCapacity = 200; //수용 가능한 단어 무게 최대치
WordSpace.gameTimer = null; //현재 게임 플레이 시간 타이머
WordSpace.isGameOver = false;
WordSpace.isTimerOn = false;
WordSpace.isInvincible = false;
WordSpace.pyeongminAnims = [];
WordSpace.wordGroup = [];
WordSpace.nameGroup = [];
WordSpace.attackPaperGroup = [];
WordSpace.attackPaperGroup = null;
WordSpace.wordForcedGroup = [];
WordSpace.wordPhysicsGroup = null;
......
......@@ -13,7 +13,7 @@ app.get('/', function(req, res) {
});
// http 기본 포트(80)에 서버 열기
server.listen(80, function() {
server.listen(8080, function() {
console.log('[SERVER] Listening on port ' + server.address().port);
GameServer.serverNumber = Math.floor(Math.random() * 1000 + 1);
console.log('[SERVER] server number is ' + GameServer.serverNumber);
......@@ -187,6 +187,15 @@ io.on('connection', function(socket)
if (wrongCountIndex !== -1) socket.playerData.playingData.lastAttacks[wrongCountIndex].wrongCount++;
});
socket.on('itemStart', function(msg) //playerID, item
{
socket.playerData.currentRoom.announceToRoom('someoneItemStart', msg);
});
socket.on('itemEnd', function(msg) //playerID, item
{
socket.playerData.currentRoom.announceToRoom('someoneItemEnd', msg);
});
socket.on('disconnect', function(reason)
{
GameServer.disconnectCount++;
......
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