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

Merge branch 'gameScene'

parents acb37829 9a90fb5b
...@@ -271,7 +271,7 @@ class GameRoom ...@@ -271,7 +271,7 @@ class GameRoom
{ {
if (this.currentPhase === GameServer.Phase.START) 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.currentPhase = GameServer.Phase.MAIN;
this.rateArrangePoint = 150; this.rateArrangePoint = 150;
......
...@@ -17,6 +17,16 @@ ...@@ -17,6 +17,16 @@
<script src="js/Enums.js"></script> <script src="js/Enums.js"></script>
<script src="js/ResourceLoader.js"></script> <script src="js/ResourceLoader.js"></script>
<script src="js/UIObject.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> <style>
img { position: relative; width: 100%; height: 100%; z-index: 0;} img { position: relative; width: 100%; height: 100%; z-index: 0;}
......
...@@ -13,17 +13,17 @@ BackGround.otherCharacters = []; ...@@ -13,17 +13,17 @@ BackGround.otherCharacters = [];
BackGround.drawCharacter = function(scene) 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); 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()}); BackGround.characterPos = BackGround.characterPos.sort(function(){return 0.5-Math.random()});
RoomData.players.forEach(function(element){ RoomData.players.forEach(function(element){
if(element.id != RoomData.myself.id) if(element.id != RoomData.myself.id)
{ {
element.position = BackGround.characterPos.pop(); 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.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) 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 } 6 }
}); });
} }
...@@ -32,7 +32,7 @@ BackGround.gameBackground = null; ...@@ -32,7 +32,7 @@ BackGround.gameBackground = null;
BackGround.drawBrain = function(scene) 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) BackGround.drawBackground = function(scene)
...@@ -42,10 +42,10 @@ BackGround.drawBackground = function(scene) ...@@ -42,10 +42,10 @@ BackGround.drawBackground = function(scene)
BackGround.drawMenu = 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) 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
This diff is collapsed.
...@@ -21,7 +21,7 @@ Input.attackOption = { ...@@ -21,7 +21,7 @@ Input.attackOption = {
Input.gameSceneEnterReaction = function() Input.gameSceneEnterReaction = function()
{ {
if (!Input.isEntered) if (RoomData.myself.isAlive && !Input.isEntered)
{ {
if (Input.attackMode) WordSpace.attack(Input.removeConVow(Input.finalInput), Input.attackOption.wordGrade); if (Input.attackMode) WordSpace.attack(Input.removeConVow(Input.finalInput), Input.attackOption.wordGrade);
else WordSpace.findWord(Input.finalInput); else WordSpace.findWord(Input.finalInput);
...@@ -384,7 +384,7 @@ Input.inputField = ...@@ -384,7 +384,7 @@ Input.inputField =
Input.pushInput = function(inputKey) Input.pushInput = function(inputKey)
{ {
if (this.justPressed != inputKey) if ((ScenesData.currentScene != 'gameScene' || RoomData.myself.isAlive) && this.justPressed != inputKey)
{ {
this.justPressed = inputKey; this.justPressed = inputKey;
let output; let output;
......
...@@ -2,7 +2,7 @@ var ResourceLoader = ResourceLoader || {}; ...@@ -2,7 +2,7 @@ var ResourceLoader = ResourceLoader || {};
ResourceLoader.loadBackGround = function(scene) 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('baseBackground', 'assets/image/background/yellowBack.png');
scene.load.image('gameBackground', 'assets/image/background/background_brain.png'); scene.load.image('gameBackground', 'assets/image/background/background_brain.png');
scene.load.image('menuBackground', 'assets/placeholder/menuBackground.png'); scene.load.image('menuBackground', 'assets/placeholder/menuBackground.png');
...@@ -42,7 +42,9 @@ ResourceLoader.loadImage = function(scene) ...@@ -42,7 +42,9 @@ ResourceLoader.loadImage = function(scene)
scene.load.image('pyeongminStand', 'assets/image/character/pyeongmin/pyeong_stand.png'); 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.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('attackPaper', 'assets/image/etc/paper_crumbled.png');
scene.load.image('panel', 'assets/placeholder/panel.png'); scene.load.image('panel', 'assets/placeholder/panel.png');
scene.load.image('button', 'assets/placeholder/button.png'); scene.load.image('button', 'assets/placeholder/button.png');
...@@ -55,56 +57,66 @@ ResourceLoader.loadAnimation = function(scene) ...@@ -55,56 +57,66 @@ ResourceLoader.loadAnimation = function(scene)
key: 'wordBreakAnim', key: 'wordBreakAnim',
frames: scene.anims.generateFrameNumbers('wordBreak'), frames: scene.anims.generateFrameNumbers('wordBreak'),
frameRate: 10, frameRate: 10,
repeat: 0, repeat: 0
hideOnComplete: false });
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({ WordSpace.pyeongminAnims[Enums.characterAnim.sit] = scene.anims.create({
key: 'pyeongminSitAnim', key: 'pyeongminSitAnim',
frames: scene.anims.generateFrameNumbers('pyeongminSit'), frames: scene.anims.generateFrameNumbers('pyeongminSit'),
frameRate: 10, frameRate: 10,
repeat: 0, repeat: 0
hideOnComplete: false
}); });
WordSpace.pyeongminAnims[Enums.characterAnim.write] = scene.anims.create({ WordSpace.pyeongminAnims[Enums.characterAnim.write] = scene.anims.create({
key: 'pyeongminWriteAnim', key: 'pyeongminWriteAnim',
frames: scene.anims.generateFrameNumbers('pyeongminWrite'), frames: scene.anims.generateFrameNumbers('pyeongminWrite'),
frameRate: 10, frameRate: 10,
repeat: 0, repeat: 0
hideOnComplete: false
}); });
WordSpace.pyeongminAnims[Enums.characterAnim.notBurning] = scene.anims.create({ WordSpace.pyeongminAnims[Enums.characterAnim.notBurning] = scene.anims.create({
key: 'pyeongminnotBurningAnim', key: 'pyeongminnotBurningAnim',
frames: scene.anims.generateFrameNumbers('pyeongminWrite'), frames: scene.anims.generateFrameNumbers('pyeongminWrite'),
frameRate: 10, frameRate: 10,
repeat: -1, repeat: -1
hideOnComplete: false
}); });
WordSpace.pyeongminAnims[Enums.characterAnim.smallBurning] = scene.anims.create({ WordSpace.pyeongminAnims[Enums.characterAnim.smallBurning] = scene.anims.create({
key: 'pyeongminsmallBurningAnim', key: 'pyeongminsmallBurningAnim',
frames: scene.anims.generateFrameNumbers('pyeongminBurningSmall'), frames: scene.anims.generateFrameNumbers('pyeongminBurningSmall'),
frameRate: 10, frameRate: 10,
repeat: -1, repeat: -1
hideOnComplete: false
}); });
WordSpace.pyeongminAnims[Enums.characterAnim.bigBurning] = scene.anims.create({ WordSpace.pyeongminAnims[Enums.characterAnim.bigBurning] = scene.anims.create({
key: 'pyeongminbigBurningAnim', key: 'pyeongminbigBurningAnim',
frames: scene.anims.generateFrameNumbers('pyeongminBurningBig'), frames: scene.anims.generateFrameNumbers('pyeongminBurningBig'),
frameRate: 10, frameRate: 10,
repeat: -1, repeat: -1
hideOnComplete: false
}); });
WordSpace.pyeongminAnims[Enums.characterAnim.throw] = scene.anims.create({ WordSpace.pyeongminAnims[Enums.characterAnim.throw] = scene.anims.create({
key: 'pyeongminThrowAnim', key: 'pyeongminThrowAnim',
frames: scene.anims.generateFrameNumbers('pyeongminThrow'), frames: scene.anims.generateFrameNumbers('pyeongminThrow'),
frameRate: 10, frameRate: 10,
repeat: 0, repeat: 0
hideOnComplete: false
}); });
WordSpace.pyeongminAnims[Enums.characterAnim.gameOver] = scene.anims.create({ WordSpace.pyeongminAnims[Enums.characterAnim.gameOver] = scene.anims.create({
key: 'pyeongminGameOverAnim', key: 'pyeongminGameOverAnim',
frames: scene.anims.generateFrameNumbers('pyeongminGameOver'), frames: scene.anims.generateFrameNumbers('pyeongminGameOver'),
frameRate: 10, frameRate: 10,
repeat: 0, repeat: 0
hideOnComplete: false
}); });
} }
\ No newline at end of file
...@@ -45,8 +45,8 @@ var menuScene = new Phaser.Class( ...@@ -45,8 +45,8 @@ var menuScene = new Phaser.Class(
PlayerData.currentHopae = (PlayerData.userData.recentHopae == null) ? PlayerData.userData.hopae[0] : PlayerData.userData.recentHopae; PlayerData.currentHopae = (PlayerData.userData.recentHopae == null) ? PlayerData.userData.hopae[0] : PlayerData.userData.recentHopae;
PlayerData.nickname = PlayerData.currentHopae.name; 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.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(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(9.9).setPadding(5,5,5,5).setFontSize(40);
this.organizeHopae = function() this.organizeHopae = function()
{ {
...@@ -68,7 +68,7 @@ var menuScene = new Phaser.Class( ...@@ -68,7 +68,7 @@ var menuScene = new Phaser.Class(
this.hopaeMenuObject = []; this.hopaeMenuObject = [];
for(let i = 0; i < this.myHopae.length; i++) 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, 'nameBgr' + ScenesData.menuScene.myHopae[i].name.length, 1, 'left', ScenesData.menuScene.myHopae[i].name, 25, '#ffffff', 0.45, 0.5), 0, 0, 0,
function() function()
{ {
...@@ -101,7 +101,7 @@ var menuScene = new Phaser.Class( ...@@ -101,7 +101,7 @@ var menuScene = new Phaser.Class(
this.createCurrentHopae = function() 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, 'nameBgr' + PlayerData.nickname.length, 1, 'left', PlayerData.nickname, 25, '#ffffff', 0.45, 0.5), 0, 0, 0,
function() function()
{ {
...@@ -122,7 +122,7 @@ var menuScene = new Phaser.Class( ...@@ -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), background: this.add.sprite(game.config.width / 2, game.config.height / 2, 'panel').setOrigin(0.5, 0.5),
content: this.add.text(0, 0, '대기실에 참가하시겠습니까?', { content: this.add.text(0, 0, '대기실에 참가하시겠습니까?', {
font: '50pt 궁서' font: '50pt sejongFont'
}), }),
actions: [ actions: [
...@@ -147,7 +147,7 @@ var menuScene = new Phaser.Class( ...@@ -147,7 +147,7 @@ var menuScene = new Phaser.Class(
expand: { expand: {
content: false, // Content is a pure text object content: false, // Content is a pure text object
} }
}).layout().setDepth(10).setVisible(false); }).layout().setDepth(11).setVisible(false);
this.roomEnterDialog this.roomEnterDialog
.on('button.click', function (button, groupName, index) { .on('button.click', function (button, groupName, index) {
...@@ -230,8 +230,8 @@ var hopaeScene = new Phaser.Class( ...@@ -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), 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변경에는 엽전이 소모됩니다.'), { content: this.add.text(0, 0, '이 이름으로 하시겠습니까?' + (PlayerData.userData.hopae.length == 0 ? '\n(최초 호패는 비용이 들지 않습니다.)' : '\n변경에는 엽전이 소모됩니다.'), {
font: '50pt 궁서', font: '50pt sejongFont',
color: '#000000', color: '#000000',
align: 'center' align: 'center'
}), }),
...@@ -258,7 +258,7 @@ var hopaeScene = new Phaser.Class( ...@@ -258,7 +258,7 @@ var hopaeScene = new Phaser.Class(
expand: { expand: {
content: false, // Content is a pure text object content: false, // Content is a pure text object
} }
}).layout().setDepth(10).setVisible(false); }).layout().setDepth(11).setVisible(false);
this.checkDialog this.checkDialog
.on('button.click', function (button, groupName, index) { .on('button.click', function (button, groupName, index) {
...@@ -295,7 +295,7 @@ var hopaeScene = new Phaser.Class( ...@@ -295,7 +295,7 @@ var hopaeScene = new Phaser.Class(
.on('button.out', function (button, groupName, index) { .on('button.out', function (button, groupName, index) {
//console.log('button out'); //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(); '이름 타수가 많아 플레이에 패널티가 있을 수 있습니다', 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, 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( ...@@ -347,8 +347,8 @@ var roomScene = new Phaser.Class(
this.isCountEnd = false; this.isCountEnd = false;
this.endTime = 0; this.endTime = 0;
this.peopleCount = 1; 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.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(10); 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() update: function()
...@@ -431,8 +431,6 @@ var gameScene = new Phaser.Class( ...@@ -431,8 +431,6 @@ var gameScene = new Phaser.Class(
sceneKey: 'button' sceneKey: 'button'
}); });
WordSpace.resetGame(); 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() create: function()
...@@ -445,6 +443,7 @@ var gameScene = new Phaser.Class( ...@@ -445,6 +443,7 @@ var gameScene = new Phaser.Class(
BackGround.drawBrain(this); BackGround.drawBrain(this);
BackGround.drawCharacter(this); BackGround.drawCharacter(this);
Audio.playSound(this, 'startGame'); Audio.playSound(this, 'startGame');
WordSpace.attackPaperGroup = this.physics.add.group();
WordSpace.wordPhysicsGroup = this.physics.add.group(); WordSpace.wordPhysicsGroup = this.physics.add.group();
Input.inputField.generate(this, Input.gameSceneEnterReaction, Input.inputField.generate(this, Input.gameSceneEnterReaction,
...@@ -459,8 +458,20 @@ var gameScene = new Phaser.Class( ...@@ -459,8 +458,20 @@ var gameScene = new Phaser.Class(
WordSpace.setPlayerTyping.initiate(this); WordSpace.setPlayerTyping.initiate(this);
WordSpace.nameQueue.initiate(); 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() update: function()
...@@ -476,13 +487,19 @@ var gameScene = new Phaser.Class( ...@@ -476,13 +487,19 @@ var gameScene = new Phaser.Class(
{ {
element.attract(); element.attract();
}) })
WordSpace.attackPaperGroup.forEach(function(element){ WordSpace.attackPaperGroup.getChildren().forEach(function(element){
element.moveObject(element); element.moveObject(element);
}); });
WordSpace.weightTextObjForTest.setText('뇌의 무게: (현재) '+WordSpace.totalWeight+' / '+ WordSpace.brainCapacity+' (전체)');
WordSpace.killLogTextForTest.setText(WordSpace.killLogForTest);
WordSpace.setPlayerTyping.add(''); 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 = ...@@ -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), background: scene.add.sprite(x, y, image).setScale(size).setOrigin(0.5, 0.5).setDepth(depth),
text: scene.add.text(x, y, text, { text: scene.add.text(x, y, text, {
font: textSize + 'pt 궁서', font: textSize + 'pt sejongFont',
align: 'center' align: 'center'
}).setDepth(depth).setOrigin(textOriginX, textOriginY).setColor(textColor), }).setDepth(depth).setOrigin(textOriginX, textOriginY).setColor(textColor),
......
...@@ -20,7 +20,7 @@ class WordObject ...@@ -20,7 +20,7 @@ class WordObject
var random = WordSpace.getSpawnPoint(lenRate); var random = WordSpace.getSpawnPoint(lenRate);
this.physicsObj = scene.physics.add.sprite(random.x, random.y, spriteName).setMass(this.wordWeight * 10).setScale(this.scale) 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; this.physicsObj.wordCollider = null;
let dist = Phaser.Math.Distance.Between(this.physicsObj.x, this.physicsObj.y, WordSpace.gravityPoint.x, WordSpace.gravityPoint.y); 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); let angle = Phaser.Math.Angle.Between(this.physicsObj.x, this.physicsObj.y, WordSpace.gravityPoint.x, WordSpace.gravityPoint.y);
...@@ -31,11 +31,10 @@ class WordObject ...@@ -31,11 +31,10 @@ class WordObject
this.wordObj = scene.add.text(random.x, random.y, this.wordText, this.wordObj = scene.add.text(random.x, random.y, this.wordText,
{ {
fontSize: (this.scale * this.fontScale) +'pt', font: (this.scale * this.fontScale) +'pt sejongFont',
fontFamily: '"궁서", 궁서체, serif',
//fontStyle: (this.wordWeight > 5 ? 'bold' : '') //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; this.createdTime = WordSpace.gameTimer.now;
WordSpace.totalWeight += this.wordWeight; WordSpace.totalWeight += this.wordWeight;
WordSpace.totalWordNum += 1; WordSpace.totalWordNum += 1;
...@@ -54,7 +53,7 @@ class WordObject ...@@ -54,7 +53,7 @@ class WordObject
const forceIdx = WordSpace.wordForcedGroup.findIndex(function(item) {return this.isEqualObject(item.generationCode)}, this); const forceIdx = WordSpace.wordForcedGroup.findIndex(function(item) {return this.isEqualObject(item.generationCode)}, this);
if (forceIdx > -1) WordSpace.wordForcedGroup.splice(forceIdx, 1); if (forceIdx > -1) WordSpace.wordForcedGroup.splice(forceIdx, 1);
WordSpace.wordPhysicsGroup.remove(this.physicsObj); 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() { setTimeout(function() {
breakAnim.destroy(); breakAnim.destroy();
}, 200); }, 200);
...@@ -261,8 +260,7 @@ class NameWord extends WordObject ...@@ -261,8 +260,7 @@ class NameWord extends WordObject
{ {
this.physicsObj.setScale(this.follower.t < 0.2 ? 0.2 : this.follower.t * this.scale); this.physicsObj.setScale(this.follower.t < 0.2 ? 0.2 : this.follower.t * this.scale);
this.wordObj.setFont({ this.wordObj.setFont({
fontSize: (this.follower.t < 0.2 ? 0.05 : this.follower.t * this.scale * this.fontScale) +'pt', font: (this.follower.t < 0.2 ? 0.05 : this.follower.t * this.scale * this.fontScale) +'pt sejongFont',
fontFamily: '"궁서", 궁서체, serif',
fontStyle: (this.wordWeight > 5 ? 'bold' : '') fontStyle: (this.wordWeight > 5 ? 'bold' : '')
}); });
} }
...@@ -285,8 +283,8 @@ class NameWord extends WordObject ...@@ -285,8 +283,8 @@ class NameWord extends WordObject
if(!this.isStrong) WordSpace.attackGauge.add(this.wordTyping * 0.1); if(!this.isStrong) WordSpace.attackGauge.add(this.wordTyping * 0.1);
WordSpace.nameGroup.push(this); WordSpace.nameGroup.push(this);
this.isActive = false; this.isActive = false;
this.physicsObj.setVelocity(0, 0).setDepth(20); this.physicsObj.setVelocity(0, 0).setDepth(10.2);
this.wordObj.setPosition(this.physicsObj.x, this.physicsObj.y).setDepth(20); this.wordObj.setPosition(this.physicsObj.x, this.physicsObj.y).setDepth(10.2);
this.follower = { t: 0, vec: new Phaser.Math.Vector2() }; this.follower = { t: 0, vec: new Phaser.Math.Vector2() };
this.path = new Phaser.Curves.Spline([ this.path = new Phaser.Curves.Spline([
this.physicsObj.x, this.physicsObj.y, this.physicsObj.x, this.physicsObj.y,
...@@ -363,8 +361,10 @@ class ItemWord extends WordObject ...@@ -363,8 +361,10 @@ class ItemWord extends WordObject
{ {
case Enums.item.invincible: case Enums.item.invincible:
WordSpace.isInvincible = true; WordSpace.isInvincible = true;
socket.emit('itemStart', {id: RoomData.myself.id, itemType: Enums.item.invincible});
setTimeout(() => { setTimeout(() => {
WordSpace.isInvincible = false; WordSpace.isInvincible = false;
socket.emit('itemEnd', {id: RoomData.myself.id, itemType: Enums.item.invincible});
}, 5000); }, 5000);
break; break;
case Enums.item.nameList: case Enums.item.nameList:
......
var WordSpace = WordSpace || {}; var WordSpace = WordSpace || {};
// for test
WordSpace.weightTextObjForTest = null;
WordSpace.nameWordTextForTest = null; WordSpace.nameWordTextForTest = null;
WordSpace.killLogTextForTest = null;
WordSpace.killLogForTest = '';
WordSpace.nextWordCode = 0; WordSpace.nextWordCode = 0;
WordSpace.totalWeight = 0; //현재 단어 무게 총합 WordSpace.totalWeight = 0; //현재 단어 무게 총합
WordSpace.totalWordNum = 0; WordSpace.totalWordNum = 0;
WordSpace.brainCapacity = 200; //수용 가능한 단어 무게 최대치 WordSpace.brainCapacity = 200; //수용 가능한 단어 무게 최대치
WordSpace.gameTimer = null; //현재 게임 플레이 시간 타이머 WordSpace.gameTimer = null; //현재 게임 플레이 시간 타이머
WordSpace.isGameOver = false;
WordSpace.isTimerOn = false; WordSpace.isTimerOn = false;
WordSpace.isInvincible = false; WordSpace.isInvincible = false;
WordSpace.pyeongminAnims = []; WordSpace.pyeongminAnims = [];
WordSpace.wordGroup = []; WordSpace.wordGroup = [];
WordSpace.nameGroup = []; WordSpace.nameGroup = [];
WordSpace.attackPaperGroup = []; WordSpace.attackPaperGroup = null;
WordSpace.wordForcedGroup = []; WordSpace.wordForcedGroup = [];
WordSpace.wordPhysicsGroup = null; WordSpace.wordPhysicsGroup = null;
WordSpace.lastAttackGroup = [];
WordSpace.GradeProb = [0.35, 0.6, 0.8]; WordSpace.GradeProb = [0.35, 0.6, 0.8];
WordSpace.Phase = {READY: 0, START: 1, MAIN: 2, MUSIC: 3}; WordSpace.Phase = {READY: 0, START: 1, MAIN: 2, MUSIC: 3};
...@@ -112,7 +110,7 @@ WordSpace.attackGauge = ...@@ -112,7 +110,7 @@ WordSpace.attackGauge =
generate: function(scene) generate: function(scene)
{ {
//console.log("created"); //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) add: function(plus)
{ {
...@@ -143,7 +141,7 @@ WordSpace.attackGauge = ...@@ -143,7 +141,7 @@ WordSpace.attackGauge =
}; };
this.currentCycle = scene.time.addEvent(option); 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]); //this.rectUI.setColor(this.gradeColor[0]);
}, },
pauseCycle: function(bool) {this.currentCycle.paused = bool;}, pauseCycle: function(bool) {this.currentCycle.paused = bool;},
...@@ -343,7 +341,7 @@ WordSpace.setPlayerTyping = ...@@ -343,7 +341,7 @@ WordSpace.setPlayerTyping =
}, },
initiate: function(scene) 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() reset: function()
{ {
...@@ -417,14 +415,17 @@ WordSpace.attack = function(wordText, grade) ...@@ -417,14 +415,17 @@ WordSpace.attack = function(wordText, grade)
WordSpace.makeAttackPaper = function(scene, attackFrom, attackTo, multiple) 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.mask = new Phaser.Display.Masks.BitmapMask(scene, BackGround.gameBackground);
attackPaper.throwTarget = attackTo; attackPaper.throwTarget = attackTo;
attackPaper.follower = { t: 0, vec: new Phaser.Math.Vector2() }; attackPaper.follower = { t: 0, vec: new Phaser.Math.Vector2() };
attackPaper.path = new Phaser.Curves.Spline([ attackPaper.path = new Phaser.Curves.Spline([
attackFrom.x, attackFrom.y, attackFrom.x, attackFrom.y,
(attackFrom.x + attackPaper.throwTarget.x) / 2, Math.min(attackFrom.y, attackPaper.throwTarget.y) - 100, (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({ scene.tweens.add({
targets: attackPaper.follower, targets: attackPaper.follower,
...@@ -432,9 +433,8 @@ WordSpace.makeAttackPaper = function(scene, attackFrom, attackTo, multiple) ...@@ -432,9 +433,8 @@ WordSpace.makeAttackPaper = function(scene, attackFrom, attackTo, multiple)
ease: 'Linear', ease: 'Linear',
duration: 4000, duration: 4000,
repeat: 0, repeat: 0,
onComplete: function() { onComplete: function() {
attackPaper.destroy(); WordSpace.attackPaperGroup.remove(attackPaper, true);
WordSpace.attackPaperGroup = [];
} }
}); });
attackPaper.moveObject = function(obj) attackPaper.moveObject = function(obj)
...@@ -443,7 +443,7 @@ WordSpace.makeAttackPaper = function(scene, attackFrom, attackTo, multiple) ...@@ -443,7 +443,7 @@ WordSpace.makeAttackPaper = function(scene, attackFrom, attackTo, multiple)
obj.setPosition(obj.follower.vec.x, obj.follower.vec.y); obj.setPosition(obj.follower.vec.x, obj.follower.vec.y);
obj.angle = 720 * obj.follower.t; obj.angle = 720 * obj.follower.t;
} }
WordSpace.attackPaperGroup.push(attackPaper); WordSpace.attackPaperGroup.add(attackPaper);
} }
WordSpace.nameQueue = WordSpace.nameQueue =
...@@ -488,25 +488,41 @@ WordSpace.nameQueue = ...@@ -488,25 +488,41 @@ WordSpace.nameQueue =
this.shuffle(); 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.resetGame = function()
{ {
WordSpace.weightTextObjForTest = null;
WordSpace.nameWordTextForTest = null;
WordSpace.killLogTextForTest = null;
WordSpace.killLogForTest = '';
WordSpace.nextWordCode = 0; WordSpace.nextWordCode = 0;
WordSpace.totalWeight = 0; //현재 단어 무게 총합 WordSpace.totalWeight = 0; //현재 단어 무게 총합
WordSpace.totalWordNum = 0; WordSpace.totalWordNum = 0;
WordSpace.brainCapacity = 200; //수용 가능한 단어 무게 최대치 WordSpace.brainCapacity = 200; //수용 가능한 단어 무게 최대치
WordSpace.gameTimer = null; //현재 게임 플레이 시간 타이머 WordSpace.gameTimer = null; //현재 게임 플레이 시간 타이머
WordSpace.isGameOver = false;
WordSpace.isTimerOn = false; WordSpace.isTimerOn = false;
WordSpace.isInvincible = false; WordSpace.isInvincible = false;
WordSpace.pyeongminAnims = []; WordSpace.pyeongminAnims = [];
WordSpace.wordGroup = []; WordSpace.wordGroup = [];
WordSpace.nameGroup = []; WordSpace.nameGroup = [];
WordSpace.attackPaperGroup = []; WordSpace.attackPaperGroup = null;
WordSpace.wordForcedGroup = []; WordSpace.wordForcedGroup = [];
WordSpace.wordPhysicsGroup = null; WordSpace.wordPhysicsGroup = null;
......
...@@ -13,7 +13,7 @@ app.get('/', function(req, res) { ...@@ -13,7 +13,7 @@ app.get('/', function(req, res) {
}); });
// http 기본 포트(80)에 서버 열기 // http 기본 포트(80)에 서버 열기
server.listen(80, function() { server.listen(8080, function() {
console.log('[SERVER] Listening on port ' + server.address().port); console.log('[SERVER] Listening on port ' + server.address().port);
GameServer.serverNumber = Math.floor(Math.random() * 1000 + 1); GameServer.serverNumber = Math.floor(Math.random() * 1000 + 1);
console.log('[SERVER] server number is ' + GameServer.serverNumber); console.log('[SERVER] server number is ' + GameServer.serverNumber);
...@@ -187,6 +187,15 @@ io.on('connection', function(socket) ...@@ -187,6 +187,15 @@ io.on('connection', function(socket)
if (wrongCountIndex !== -1) socket.playerData.playingData.lastAttacks[wrongCountIndex].wrongCount++; 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) socket.on('disconnect', function(reason)
{ {
GameServer.disconnectCount++; 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