Commit 58f0c50f authored by 18김재민's avatar 18김재민

Merge branch 'sound' of https://git.kucatdog.net/tear-of-sejong/sejong25 into sound

parents a01b2512 e1bc4116
......@@ -15,7 +15,7 @@ GameServer.findRoom = function(roomId)
{
if (GameServer.playingRoom[i].roomId === roomId) return GameServer.playingRoom[i];
}
console.log('[ERR] no room with num ' + roomId);
console.log(new Date().toLocaleTimeString('ko-KR') + ' [ERR] no room with num ' + roomId);
}
GameServer.findPlayerSocket = function(playerId)
{
......@@ -26,7 +26,7 @@ GameServer.findPlayerSocket = function(playerId)
if (idx != -1) return this.currentPlayer[idx];
else
{
console.log('[ERR] wrong playerId('+ playerId +') to find');
console.log(new Date().toLocaleTimeString('ko-KR') + ' [ERR] wrong playerId('+ playerId +') to find');
return null;
}
}
......@@ -82,7 +82,7 @@ class GameRoom
{
this.roomId = GameServer.getRoomNumber();
this.roomIndex = -1;
this.startCount = 2;
this.startCount = 5;
this.maxPlayer = 100;
this.nextRank = 100;
......@@ -115,7 +115,7 @@ class GameRoom
{
GameServer.playingRoom[this.roomIndex] = this;
}
console.log('[LOG] new room #'+this.roomId+' made, roomCount: ' + GameServer.playingRoom.length);
console.log(new Date().toLocaleTimeString('ko-KR') + ' [LOG] new room #'+this.roomId+' made, roomCount: ' + GameServer.playingRoom.length);
}
checkHopae(newHopae)
......@@ -136,14 +136,14 @@ class GameRoom
this.announceToTarget(playerInst.id, 'syncRoomScene', this.currentPlayer);
this.currentPlayer.push(playerInst);
console.log('[' + playerInst.id + '] entered to room #' + this.roomId);
console.log(new Date().toLocaleTimeString('ko-KR') + ' [' + playerInst.id + '] entered to room #' + this.roomId);
this.aliveCount++;
if (this.currentPlayer.length >= this.startCount)
{
if (this.currentPhase === GameServer.Phase.READY)
{
this.endTime = Date.now() + 10000; // 테스트용 10초
this.endTime = Date.now() + 30000; // 방 대기 시간
this.announceToRoom('setRoomCount',
{
isEnable: true, endTime: this.endTime, playerCount: this.currentPlayer.length,
......@@ -190,7 +190,6 @@ class GameRoom
isEnter: false, player: this.currentPlayer[i]
});
this.currentPhase = GameServer.Phase.READY;
this.refreshRoom();
}
else this.announceToRoom('setRoomCount',
{
......@@ -202,7 +201,7 @@ class GameRoom
return;
}
}
console.log('[ERR] No player who have ' + playerId);
console.log(new Date().toLocaleTimeString('ko-KR') + ' [ERR] No player who have ' + playerId);
return;
}
......@@ -223,7 +222,7 @@ class GameRoom
isEnable: false, endTime: 0, playerCount: this.currentPlayer.length,
isEnter: false, player: {id: -1}
});
console.error('[ROOM#' + this.roomId + '] room Refreshed');
console.error(new Date().toLocaleTimeString('ko-KR') + ' [ROOM#' + this.roomId + '] room Refreshed');
}
else
{
......@@ -238,7 +237,7 @@ class GameRoom
this.rateArrangePoint = 300;
this.maxTypingPlayer = null;
this.minTypingPlayer = null;
console.log('[ROOM#' + this.roomId + '] room Refreshed with End of Game');
console.log(new Date().toLocaleTimeString('ko-KR') + ' [ROOM#' + this.roomId + '] room Refreshed with End of Game');
}
}
......@@ -261,7 +260,7 @@ class GameRoom
};
this.announceToRoom('syncRoomData', toSync);
console.log('[ROOM#'+this.roomId+'] Game Start with ' + this.currentPlayer.length + ' players');
console.log(new Date().toLocaleTimeString('ko-KR') + ' [ROOM#'+this.roomId+'] Game Start with ' + this.currentPlayer.length + ' players');
console.table(this.currentPlayer);
this.announceToRoom('startGame');
this.startTime = Date.now();
......@@ -309,7 +308,7 @@ class GameRoom
{
if (this.aliveCount > 0)
{
console.log('[ERR] can not destroy room#' + this.roomId + ', cause player left');
console.log(new Date().toLocaleTimeString('ko-KR') + ' [ERR] can not destroy room#' + this.roomId + ', cause player left');
}
else
{
......@@ -358,10 +357,12 @@ class Player
this.index = gameRoom.currentPlayer.length;
this.nickname = playerData.nickname;
this.playerImage = null;
this.mat = null;
this.position = null;
this.killCount = 0;
this.earnedStrongHopae = 0;
this.attackSucceed = 0;
this.skin = playerData.skin;
this.isAlive = false;
this.isInThisRoom = true;
......@@ -406,7 +407,7 @@ class Player
}
room.announceToRoom('defeat', this);
console.log('[' + this.id + '] defeated, rank: ' + this.rank + ', ' + room.aliveCount + ' player left');
console.log(new Date().toLocaleTimeString('ko-KR') + ' [' + this.id + '] defeated, rank: ' + this.rank + ', ' + room.aliveCount + ' player left');
if (room.aliveCount === 1)
{
......@@ -418,7 +419,7 @@ class Player
room.announceToRoom('gameEnd', winner.id);
room.announceToTarget(winner.id, 'alert', 'gameWin');
room.currentPhase = GameServer.Phase.GAMEEND;
console.log('['+winner.id+']' + ' winner! ' + winner.nickname);
console.log(new Date().toLocaleTimeString('ko-KR') + ' ['+winner.id+']' + ' winner! ' + winner.nickname);
}
}
}
......
This diff is collapsed.
......@@ -3,24 +3,24 @@
<head>
<meta charset="utf-8"/>
<script src="/socket.io/socket.io.js"></script>
<script src="js/phaser.js"></script>
<script src="js/ScenesData.js"></script>
<script src="js/Background.js"></script>
<script src="js/Input.js"></script>
<script src="js/WordSpace.js"></script>
<script src="js/GameCycle.js"></script>
<script src="js/WordObject.js"></script>
<script src="js/WordReader.js"></script>
<script src="js/CSVParsing.js"></script>
<script src="js/SelectWord.js"></script>
<script src="js/BGMsound.js"></script>
<script src="js/Enums.js"></script>
<script src="js/ResourceLoader.js"></script>
<script src="js/UIObject.js"></script>
<script src="/js/phaser.js"></script>
<script src="/js/ScenesData.js"></script>
<script src="/js/Background.js"></script>
<script src="/js/Input.js"></script>
<script src="/js/WordSpace.js"></script>
<script src="/js/GameCycle.js"></script>
<script src="/js/WordObject.js"></script>
<script src="/js/WordReader.js"></script>
<script src="/js/CSVParsing.js"></script>
<script src="/js/SelectWord.js"></script>
<script src="/js/BGMsound.js"></script>
<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');
src: url('assets/font/EBS훈민정음새론SB.ttf');
font-weight:400;
font-weight:normal;
}
......@@ -31,18 +31,29 @@
<style>
img { position: relative; width: 100%; height: 100%; z-index: 0;}
#dvLogin { position: absolute; left: 65%; top: 35%; width: 30%; height: 30%; padding: 10px; background: black; z-index: 1;}
#dvNewEmail { position:absolute; left: 35%; top: 35%; width: 30%; height: 30%; padding: 10px; background: black; z-index: 1; display: none; }
#notSupport { position: absolute; left: 25%; top: 25%; background: white; z-index: 2; width: 50%; height: 50%; display: none;}
</style>
</head>
<body>
<div id="mainTitle">
<img id="titleImg" src="assets/image/background/title.png" alt="title">
<img id="titleImg" src="/assets/image/background/title.png" alt="title">
<div id="dvLogin">
<input id="userEmail" type="email" placeholder="email" style="width: 100%; height: 10%;"></br>
<input id="userPassword" type="password" placeholder="password" maxlength="17" style="width: 100%; height: 10%;"></br>
<button id="joinBtn" style="width: 100%; height: 10%;">이메일로 가입하기</button></br>
<button id="joinOpenBtn" style="width: 100%; height: 10%;">이메일로 가입하기</button></br>
<button id="emailBtn" style="width: 100%; height: 10%;">이메일로 로그인</button></br>
<button id="googleBtn" style="width: 10%; height: 10%;"><img src="assets/title/googleBtn.png" style="object-fit: contain"></button></br>
<button id="googleBtn" style="width: 10%; height: 10%;"><img src="/assets/title/googleBtn.png" style="object-fit: contain"></button></br>
</div>
<div id="dvNewEmail">
<input id="newEmail" type="email" placeholder="email" style="width: 100%; height: 10%;"></br>
<input id="newPassword" type="password" placeholder="password" maxlength="17" style="width: 100%; height: 10%;"></br>
<input id="newPasswordCheck" type="password" placeholder="password again" maxlength="17" style="width: 100%; height: 10%;"></br>
<input id="newName" placeholder="user name" maxlength="8" style="width: 100%; height: 10%;"></br>
<button id="joinBtn" style="width: 50%; height: 10%;">가입하기</button>
<button id="joinCancelBtn" style="width: 50%; height: 10%;">취소</button>
</div>
<p id="notSupport">해당하는 환경에서는 지원되지 않습니다. PC에서 이용 부탁드립니다.</p>
</div>
<script src="https://www.gstatic.com/firebasejs/6.3.3/firebase-app.js"></script>
......@@ -64,8 +75,8 @@
firebase.initializeApp(firebaseConfig);
</script>
<script src="js/Client.js"></script>
<script src="js/Main.js"></script>
<script src="js/FirebaseClient.js"></script>
<script src="/js/Client.js"></script>
<script src="/js/main.js"></script>
<script src="/js/FirebaseClient.js"></script>
</body>
</html>
\ No newline at end of file
......@@ -13,15 +13,22 @@ 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(5);
RoomData.myself.position = new Phaser.Math.Vector2(RoomData.myself.playerImage.x, RoomData.myself.playerImage.y);
RoomData.myself.playerImage = scene.add.sprite(game.config.width / 2, game.config.height * 41 / 48, Enums.characterSkin[PlayerData.userData.skin] + 'Write')
.setScale(0.45).setDepth(5);
RoomData.myself.position = new Phaser.Math.Vector2(RoomData.myself.playerImage.x - 20, RoomData.myself.playerImage.y - 20);
RoomData.myself.mat = scene.add.sprite(RoomData.myself.position.x, RoomData.myself.position.y, 'mat')
.setScale(0.45).setDepth(4);
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(5);
element.playerImage = scene.add.sprite(element.position.x, element.position.y, Enums.characterSkin[element.skin] + 'Write')
.setScale(0.315).setDepth(5);
element.playerImage.flipX = element.position.x < game.config.width / 2 ? true : false;
element.mat = scene.add.sprite(element.position.x - 14 * (element.position.x < game.config.width / 2 ? -1 : 1), element.position.y - 14, 'mat')
.setScale(0.315).setDepth(4);
element.mat.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(5.1);
6 }
......
......@@ -85,7 +85,7 @@ socket.on('setRoomCount', function(msg)
}
ScenesData.roomScene.players.push(playerSet);
}
else // remove character
else if (msg.id != -1) // remove character
{
let idx = ScenesData.roomScene.players.findIndex(function(element)
{
......@@ -205,6 +205,7 @@ socket.on('defeat', function(msg) // object player
let playerImage = RoomData.findPlayer(msg.id).playerImage;
let position = RoomData.findPlayer(msg.id).position;
let nicknameText = RoomData.findPlayer(msg.id).nicknameText;
let earnedStrongHopae = RoomData.findPlayer(msg.id).earnedStrongHopae;
if(WordSpace.CurrentPhase == 1)
Audio.killSound(ScenesData.gameScene, 'Phase1');
......@@ -218,10 +219,11 @@ socket.on('defeat', function(msg) // object player
RoomData.players[msg.index].playerImage = playerImage;
RoomData.players[msg.index].position = position;
RoomData.players[msg.index].nicknameText = nicknameText;
RoomData.players[msg.index].earnedStrongHopae = earnedStrongHopae;
let victim = RoomData.findPlayer(msg.id);
RoomData.aliveCount--;
victim.playerImage.play(WordSpace.pyeongminAnims[Enums.characterAnim.gameOver]);
victim.playerImage.play(WordSpace.characterAnims[victim.skin][Enums.characterAnim.gameOver]);
if (msg.lastAttack != null)
......@@ -270,7 +272,7 @@ socket.on('defeat', function(msg) // object player
duration: 500,
repeat: 0, // -1: infinity
yoyo: false });
}, 1000);
}, 5000);
},
})
......@@ -311,6 +313,7 @@ socket.on('defeat', function(msg) // object player
{
var keys = Object.keys(Enums.item);
WordSpace.generateWord.Item(ScenesData.gameScene, Enums.item[keys[keys.length * Math.random() << 0]]);
Audio.playSound(ScenesData.gameScene, 'getItem');
RoomData.myself.killCount++;
}
}
......@@ -355,14 +358,12 @@ socket.on('defeat', function(msg) // object player
}, 1000);
}
})
}
if(msg.id == RoomData.myself.id)
{
RoomData.myself = RoomData.players[msg.index];
setTimeout(() => {
gameEndMenu(true);
gameEndMenu(false);
}, 2000);
}
});
......@@ -392,6 +393,7 @@ socket.on('attackSucceed', function(msg)
{
//console.log('client');
let tempWord = WordSpace.generateWord.Name(ScenesData.gameScene, true, RoomData.findPlayer(msg.victimId));
tempWord.instantiate(ScenesData.gameScene);
let victimPos = RoomData.findPlayer(msg.victimId).position;
tempWord.physicsObj.setPosition(victimPos.x, victimPos.y);
tempWord.wordObj.setPosition(tempWord.physicsObj.x, tempWord.physicsObj.y);
......@@ -415,13 +417,14 @@ var gameEndMenu = function(isWin)
let earnedMoney = 0;
if(isWin) earnedMoney += 20;
earnedMoney += RoomData.myself.killCount * 3;
earnedMoney += parseInt(WordSpace.playerTypingRate / 10);
earnedMoney += parseInt(WordSpace.playerTyping / 10);
earnedMoney += Math.max(20, Math.pow(RoomData.myself.attackSucceed, 2));
earnedMoney += parseInt(20 * (1 - (RoomData.myself.rank - 1) / (RoomData.players.length - 1)));
earnedMoney = parseInt(earnedMoney / 40);
Input.inputField.text.destroy();
var temp = function(){
var endGame = function(){
socket.emit('exitFromRoom', RoomData.myself.id);
fbClient.updateUserData('killCount', RoomData.myself.killCount);
......@@ -429,25 +432,29 @@ var gameEndMenu = function(isWin)
ScenesData.changeScene('menuScene');
}
ScenesData.gameScene.backToMenuDialog = ScenesData.gameScene.rexUI.add.dialog({
x: game.config.width / 2,
y: game.config.height / 2,
background: ScenesData.gameScene.add.sprite(game.config.width / 2, game.config.height / 2, 'panel').setOrigin(0.5, 0.5),
background: ScenesData.gameScene.add.sprite(game.config.width / 2, game.config.height / 2, 'resultDialog').setOrigin(0.5, 0.5),
content: ScenesData.gameScene.rexUI.add.dialog({
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, 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, 10.2,
'button', 1, 'center', '킬 수 : ' + RoomData.myself.killCount + '', 30).layout(),
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, 10.2,
'button', 1, 'center', '획득 골드 : ' + earnedMoney + '', 30).layout()
ScenesData.gameScene.add.sprite(game.config.width / 2 - 200, game.config.height / 2 - 100, Enums.characterSkin[PlayerData.userData.skin] + 'Stand')
.setOrigin(0.5, 0.5).setDepth(10.2).setScale(0.7),
ScenesData.gameScene.add.text(game.config.width / 2 + 400, game.config.height / 2 - 220, RoomData.myself.rank + '')
.setOrigin(1, 0.5).setColor('#000000').setDepth(10.2).setPadding(5,5,5,5).setFont('50pt sejongFont'),
ScenesData.gameScene.add.text(game.config.width / 2 + 400, game.config.height / 2 - 80, RoomData.myself.killCount + '')
.setOrigin(1, 0.5).setColor('#000000').setDepth(10.2).setPadding(5,5,5,5).setFont('50pt sejongFont'),
ScenesData.gameScene.add.text(game.config.width / 2 + 400, game.config.height / 2 + 80, RoomData.myself.earnedStrongHopae + '')
.setOrigin(1, 0.5).setColor('#000000').setDepth(10.2).setPadding(5,5,5,5).setFont('50pt sejongFont'),
ScenesData.gameScene.add.text(game.config.width / 2 + 400, game.config.height / 2 + 220, '+' + earnedMoney + '')
.setOrigin(1, 0.5).setColor('#000000').setDepth(10.2).setPadding(5,5,5,5).setFont('50pt sejongFont'),
UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 - 250, game.config.height / 2 + 220, 10.2, 'nameBgr' + RoomData.myself.nickname.length, 2,
'center', RoomData.myself.nickname, 50, '#ffffff', 0.45, 0.5)
],
align: {
......@@ -455,31 +462,33 @@ var gameEndMenu = function(isWin)
}
}),
actions: [
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()
UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 - 200, game.config.height / 2 + 350, 10.2, 'exitBtn', 1, 'center', ' ').layout(),
UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 + 200, game.config.height / 2 + 350, 10.2, 'spectateBtn', 1, 'center', ' ').layout()
],
space: {
action: 10,
left: 20,
right: 20,
top: 20,
bottom: 20,
left: 50, right: 50, top: 50, bottom: 50,
},
align: {
actions: 'center' // 'center'|'left'|'right'
}
}).setDepth(10.2);
if(isWin) ScenesData.gameScene.winMark =
ScenesData.gameScene.add.sprite(game.config.width / 2 + 500, game.config.height / 2 + 400, 'resultStamp').setOrigin(0.5, 0.5).setDepth(10.2);
ScenesData.gameScene.backToMenuDialog
.on('button.click', function (button, groupName, index) {
if(index == 0) temp();
if(index == 0) endGame();
else
{
if(isWin) ScenesData.gameScene.winMark.destroy();
ScenesData.gameScene.backToMenuDialog.setVisible(false);
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.backToMenuBtn = UIObject.createButton(ScenesData.gameScene,
UIObject.createLabel(ScenesData.gameScene, 200, 900, 10.2, 'spectateBtn', 1, 'center'), -1, -1, -1, endGame);
}
}, ScenesData.gameScene)
.on('button.over', function (button, groupName, index) {
......
var Enums = Enums || {};
Enums.characterAnim = { sit: 0, write: 1, notBurning: 2, smallBurning: 3, bigBurning: 4, throw: 5, hit: 6, gameOver: 7 }
Enums.item = {invincible: "무적", nameList: "명단", charge: "충전", clean: "청소", heavy: "중량", dark: "암흑"}
\ No newline at end of file
Enums.item = {invincible: "무적", nameList: "명단", charge: "충전", clean: "청소", heavy: "중량", dark: "암흑"}
Enums.characterSkin = ["pyeongmin", "sunbi"]
\ No newline at end of file
......@@ -20,6 +20,17 @@ FirebaseClient.prototype.initEvent = function()
this.googleBtn.addEventListener('click', this.onGoogleBtnClick.bind(this));
this.emailBtn.addEventListener('click', this.onEmailBtnClick.bind(this));
this.joinBtn.addEventListener('click', this.createEmailUser.bind(this));
document.getElementById('joinOpenBtn').addEventListener('click', function()
{
document.getElementById('dvNewEmail').style.display = 'block';
document.getElementById('dvLogin').style.display = 'none';
});
document.getElementById('joinCancelBtn').addEventListener('click', function()
{
document.getElementById('dvNewEmail').style.display = 'none';
document.getElementById('dvLogin').style.display = 'block';
})
}
FirebaseClient.prototype.logOut = function()
......@@ -125,56 +136,76 @@ FirebaseClient.prototype.onEmailBtnClick = function()
FirebaseClient.prototype.createEmailUser = function()
{
var email = document.getElementById('userEmail').value.trim();
var password = document.getElementById('userPassword').value.trim();
var email = document.getElementById('newEmail').value.trim();
var password = document.getElementById('newPassword').value.trim();
var passCheck = document.getElementById('newPasswordCheck').value.trim();
var newUserName = document.getElementById('newName').value.trim();
// 유효성 검증
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)))
{
alert('잘못된 이메일입니다.');
return;
}
else if (password != passCheck)
{
alert('비밀번호와 비밀번호 확인이 다릅니다.')
return;
}
else if (newUserName.length === 0)
{
alert('닉네임을 작성해주세요.')
return;
}
else
{
var cbCreateUserWithEmail = function(user){
console.log('이메일 가입 성공 : ', JSON.stringify(user));
//프로필 업데이트 - 이메일 가입시 유저이름 파라미터를 보내지 않으므로 가입 성공 후 처리
firebase.auth().currentUser.updateProfile({
displayName: email,
displayName: newUserName,
}).then(function() {
console.log('userName 업데이트 성공')
}).catch(function(error) {
console.error('userName 업데이트 실패 : ', error );
});
/*
//인증 메일 발송
this.auth.useDeviceLanguage(); // 이메일 기기언어로 세팅
user.sendEmailVerification().then(function() {
console.log('인증메일 발송 성공')
}).catch(function(error) {
console.error('인증메일 발송 에러', error);
});*/
/*
//인증 메일 발송
this.auth.useDeviceLanguage(); // 이메일 기기언어로 세팅
user.sendEmailVerification().then(function() {
console.log('인증메일 발송 성공')
}).catch(function(error) {
console.error('인증메일 발송 에러', error);
});*/
}
document.getElementById('dvLogin').style.display = 'block';
document.getElementById('dvNewEmail').style.display = 'block';
var cbAfterPersistence = function(){
return this.auth.createUserWithEmailAndPassword(email, password)
.then(cbCreateUserWithEmail.bind(this))
.catch(function(error) {
console.error('이메일 가입시 에러 : ', error);
switch(error.code){
case "auth/email-already-in-use":
alert('이미 사용중인 이메일 입니다.');
break;
case "auth/invalid-email":
alert('유효하지 않은 메일입니다');
break;
case "auth/operation-not-allowed":
alert('이메일 가입이 중지되었습니다.');
break;
case "auth/weak-password":
alert("비밀번호를 6자리 이상 필요합니다");
break;
}
});
return this.auth.createUserWithEmailAndPassword(email, password)
.then(cbCreateUserWithEmail.bind(this))
.catch(function(error) {
console.error('이메일 가입시 에러 : ', error);
switch(error.code){
case "auth/email-already-in-use":
alert('이미 사용중인 이메일 입니다.');
break;
case "auth/invalid-email":
alert('유효하지 않은 메일입니다');
break;
case "auth/operation-not-allowed":
alert('이메일 가입이 중지되었습니다.');
break;
case "auth/weak-password":
alert("비밀번호를 6자리 이상 필요합니다");
break;
}
});
}
this.auth.setPersistence(firebase.auth.Auth.Persistence.SESSION)
.then(cbAfterPersistence.bind(this))
.catch(function(error) {
console.error('인증 상태 설정 중 에러 발생' , error);
});
});
}
}
......@@ -233,6 +264,8 @@ FirebaseClient.prototype.updateUserData = function(key, valueChanged, replace =
case 'killCount':
beforeData.killCount = replace ? (valueChanged) : (beforeData.killCount + valueChanged);
break;
case 'skin':
beforeData.skin = valueChanged;
default:
console.log('[ERROR] database has no key for ' + key);
break;
......@@ -243,34 +276,45 @@ FirebaseClient.prototype.updateUserData = function(key, valueChanged, replace =
document.addEventListener('DOMContentLoaded', function()
{
window.fbClient = new FirebaseClient();
document.onkeydown = function(e)
{
if (!fbClient.isGameStarted && e.keyCode === 13)
var filter = "win16|win32|win64|mac|macintel";
if ( navigator.platform ){
if ( filter.indexOf(navigator.platform.toLowerCase())<0 ){
document.getElementById('dvLogin').style.display = 'none';
document.getElementById('notSupport').style.display = 'block';
}
else
{
fbClient.onEmailBtnClick();
window.fbClient = new FirebaseClient();
document.onkeydown = function(e)
{
if (!fbClient.isGameStarted && e.keyCode === 13)
{
fbClient.onEmailBtnClick();
}
else if (fbClient.isGameStarted && e.keyCode === 27)
{
fbClient.logOut();
}
}
}
}
console.log('done load');
});
document.onkeydown = function(e)
{
if (fbClient.isGameStarted && e.keyCode === 27) fbClient.logOut();
}
class UserData
{
constructor()
{
this.userName = prompt("유저의 이름을 입력해주세요.");
this.userName = fbClient.auth.currentUser.displayName;
this.exp = 0;
this.rank = -1;
this.hopae = [];
this.recentHopae = null;
this.title = [];
this.money = 0;
this.item = [];
this.item = [0];
this.killCount = 0;
this.skin = 0;
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ Input.input = [];
Input.converted = '';
Input.convInput = ''; // converted input
Input.finalInput = '';
Input.lastSuccess = '';
Input.isShifted = false;
Input.isEntered = false;
......@@ -23,26 +24,16 @@ Input.gameSceneEnterReaction = function()
{
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);
Input.inputField.inputBackground.setFrame(4);
}
else WordSpace.findWord(Input.finalInput);
Input.reset();
Input.isEntered = true;
}
}
Input.menuSceneEnterReaction = function()
{
Input.finalInput = Input.removeConVow(Input.finalInput);
if (Input.finalInput.length > 1)
{
PlayerData.nickname = Input.finalInput;
Input.reset();
}
else
{
alert('정확한 가명을 입력해주세요.');
Input.reset();
}
}
Input.reset = function()
{
......@@ -209,7 +200,12 @@ Input.convert = function()
this.convInput = this.convInput.slice(1, 2);
}
Input.finalInput = Input.converted + Input.convInput;
return true;
if (Input.finalInput.length > 6) return false;
else
{
this.lastSuccess = this.finalInput;
return true;
}
//console.log('_____end_convert_____');
}
......@@ -318,17 +314,24 @@ Input.removeConVow = function(_wordText)
Input.inputField =
{
generate: function(scene, enterCallback, text, isHopaeScene = false)
generate: function(scene, enterCallback, text)
{
this.text = text;
this.text = text.getElement('text');
this.inputBackground = text.getElement('background');
if(ScenesData.currentScene == ScenesData.gameScene) Input.inputField.inputBackground.setFrame(4);
scene.input.keyboard.on('keyup', function() {Input.pressCount--; Input.justPressed = '';
if(isHopaeScene)
scene.input.keyboard.on('keydown', function() {
if(ScenesData.currentScene == ScenesData.hopaeScene && Input.finalInput.length > 1) Input.inputField.inputBackground.setFrame(Input.finalInput.length - 2);
})
scene.input.keyboard.on('keyup', function() {Input.pressCount--; Input.justPressed = '';
if(ScenesData.currentScene == ScenesData.hopaeScene)
{
ScenesData.hopaeScene.checkBtn.setEnable(Input.checkProperInput(Input.inputField.text.text) ? true : false);
if(Input.finalInput.length > 4) ScenesData.hopaeScene.warningText.setVisible(true);
else ScenesData.hopaeScene.warningText.setVisible(false);
}})
ScenesData.hopaeScene.checkBtn.setEnable(Input.checkProperInput(Input.inputField.text.text) && (Input.finalInput.length > 1) ? true : false);
ScenesData.hopaeScene.warningText.setVisible(WordReader.getWordTyping(Input.finalInput) > 9 ? true : false);
}
})
scene.input.keyboard.on('keydown-SHIFT', function() {Input.isShifted = true});
scene.input.keyboard.on('keyup-SHIFT', function() {Input.isShifted = false});
scene.input.keyboard.on('keydown-DELETE', function() {Input.reset()});
......@@ -403,11 +406,14 @@ Input.pushInput = function(inputKey)
}
}
else output = inputKey.charCodeAt(0);
this.input.push(output);
if (this.finalInput.length <= this.maxInput) this.input.push(output);
//console.log(Input.input);
if (!this.convert() || this.finalInput.length > this.maxInput)
{
this.input.pop();
this.converted = this.lastSuccess;
this.finalInput = this.lastSuccess;
this.convInput = '';
this.input = [];
this.convert();
}
this.inputField.text.setText(Input.finalInput);
......
......@@ -5,13 +5,12 @@ ResourceLoader.loadBackGround = function(scene)
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');
scene.load.image('menuBackground', 'assets/image/UI/main/mainBackground.png');
scene.load.image('roomBackground', 'assets/placeholder/roomBackground.png');
}
ResourceLoader.loadImage = function(scene)
{
scene.load.image('inputfield', 'assets/image/etc/wordspace.png');
for (let i = 0; i < 4; i++)
{
for (let j = 2; j < 7; j++)
......@@ -41,14 +40,48 @@ ResourceLoader.loadImage = function(scene)
scene.load.spritesheet('pyeongminGameOver', 'assets/image/character/pyeongmin/balladang/pyeong_balladang.png', { frameWidth: 720, frameHeight: 700 });
scene.load.image('pyeongminStand', 'assets/image/character/pyeongmin/pyeong_stand.png');
scene.load.spritesheet('sunbiSit', 'assets/image/character/sunbi/sunbi_sit.png', { frameWidth: 521, frameHeight: 610 });
scene.load.spritesheet('sunbiWrite', 'assets/image/character/sunbi/sunbi_write.png', { frameWidth: 521, frameHeight: 610 });
scene.load.spritesheet('sunbiThrow', 'assets/image/character/sunbi/sunbi_throw.png', { frameWidth: 521, frameHeight: 610 });
scene.load.spritesheet('sunbiBurningSmall', 'assets/image/character/sunbi/sunbi_burning_small.png', { frameWidth: 521, frameHeight: 610 });
scene.load.spritesheet('sunbiBurningBig', 'assets/image/character/sunbi/sunbi_burning_big.png', { frameWidth: 521, frameHeight: 610 });
scene.load.spritesheet('sunbiGameOver', 'assets/image/character/sunbi/sunbi_die.png', { frameWidth: 720, frameHeight: 700 });
scene.load.image('sunbiStand', 'assets/image/character/sunbi/sunbi_stand.png');
scene.load.spritesheet('wordBreak', 'assets/image/word/wordbreak.png', { frameWidth: 180, frameHeight: 180 });
scene.load.spritesheet('hopaeSceneInput', 'assets/image/word/hopaeSceneInput.png', { frameWidth: 239, frameHeight: 45 });
scene.load.spritesheet('gameSceneInput', 'assets/image/etc/wordSpace/wordspace.png', { frameWidth: 253, frameHeight: 67 });
scene.load.image('attackPaper', 'assets/image/etc/paper_crumbled.png');
scene.load.image('itemBag', 'assets/image/etc/itembag2.png');
scene.load.image('mat', 'assets/image/etc/mat.png');
scene.load.image('button', 'assets/placeholder/button.png');
scene.load.image('panel', 'assets/placeholder/panel.png');
scene.load.image('dialog1', 'assets/image/UI/dialog/dialog1.png');
scene.load.image('dialog2', 'assets/image/UI/dialog/dialog2.png');
scene.load.image('resultDialog', 'assets/image/UI/dialog/result_background.png');
scene.load.image('resultStamp', 'assets/image/UI/dialog/result_stamp.png');
scene.load.image('friendlyPlayBtn', 'assets/image/UI/main/friendlyPlay.png');
scene.load.image('rankPlayBtn', 'assets/image/UI/main/rankPlay.png');
scene.load.image('shopBtn', 'assets/image/UI/main/shop.png');
scene.load.image('hopaeManageBtn', 'assets/image/UI/main/hopaeManage.png');
scene.load.image('helpBtn', 'assets/image/UI/main/help.png');
scene.load.image('cancelBtn', 'assets/image/UI/decisionBtn/cancel.png');
scene.load.image('confirmBtn', 'assets/image/UI/decisionBtn/confirm.png');
scene.load.image('exitBtn', 'assets/image/UI/decisionBtn/exit.png');
scene.load.image('noBtn', 'assets/image/UI/decisionBtn/no.png');
scene.load.image('spectateBtn', 'assets/image/UI/decisionBtn/spectate.png');
scene.load.image('yesBtn', 'assets/image/UI/decisionBtn/yes.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');
scene.load.image('itemBag', 'assets/image/etc/itembag2.png');
scene.load.spritesheet('tutorialImage', 'assets/image/UI/tutorial/tutorialImages.png', { frameWidth: 1080, frameHeight: 615 });
}
ResourceLoader.loadAnimation = function(scene)
......@@ -77,46 +110,52 @@ ResourceLoader.loadAnimation = function(scene)
frameRate: 20,
repeat: 0
});
WordSpace.pyeongminAnims[Enums.characterAnim.sit] = scene.anims.create({
key: 'pyeongminSitAnim',
frames: scene.anims.generateFrameNumbers('pyeongminSit'),
frameRate: 10,
repeat: 0
});
WordSpace.pyeongminAnims[Enums.characterAnim.write] = scene.anims.create({
key: 'pyeongminWriteAnim',
frames: scene.anims.generateFrameNumbers('pyeongminWrite'),
frameRate: 10,
repeat: 0
});
WordSpace.pyeongminAnims[Enums.characterAnim.notBurning] = scene.anims.create({
key: 'pyeongminnotBurningAnim',
frames: scene.anims.generateFrameNumbers('pyeongminWrite'),
frameRate: 10,
repeat: -1
});
WordSpace.pyeongminAnims[Enums.characterAnim.smallBurning] = scene.anims.create({
key: 'pyeongminsmallBurningAnim',
frames: scene.anims.generateFrameNumbers('pyeongminBurningSmall'),
frameRate: 10,
repeat: -1
});
WordSpace.pyeongminAnims[Enums.characterAnim.bigBurning] = scene.anims.create({
key: 'pyeongminbigBurningAnim',
frames: scene.anims.generateFrameNumbers('pyeongminBurningBig'),
frameRate: 10,
repeat: -1
});
WordSpace.pyeongminAnims[Enums.characterAnim.throw] = scene.anims.create({
key: 'pyeongminThrowAnim',
frames: scene.anims.generateFrameNumbers('pyeongminThrow'),
frameRate: 10,
repeat: 0
});
WordSpace.pyeongminAnims[Enums.characterAnim.gameOver] = scene.anims.create({
key: 'pyeongminGameOverAnim',
frames: scene.anims.generateFrameNumbers('pyeongminGameOver'),
frameRate: 10,
repeat: 0
});
for(let i = 0; i < 2; i++)
{
WordSpace.characterAnims[i][Enums.characterAnim.sit] = scene.anims.create({
key: Enums.characterSkin[i] + 'SitAnim',
frames: scene.anims.generateFrameNumbers(Enums.characterSkin[i] + 'Sit'),
frameRate: 10,
repeat: 0
});
WordSpace.characterAnims[i][Enums.characterAnim.write] = scene.anims.create({
key: Enums.characterSkin[i] + 'WriteAnim',
frames: scene.anims.generateFrameNumbers(Enums.characterSkin[i] + 'Write'),
frameRate: 10,
repeat: 0
});
WordSpace.characterAnims[i][Enums.characterAnim.notBurning] = scene.anims.create({
key: Enums.characterSkin[i] + 'notBurningAnim',
frames: scene.anims.generateFrameNumbers(Enums.characterSkin[i] + 'Write'),
frameRate: 10,
repeat: -1
});
WordSpace.characterAnims[i][Enums.characterAnim.smallBurning] = scene.anims.create({
key: Enums.characterSkin[i] + 'smallBurningAnim',
frames: scene.anims.generateFrameNumbers(Enums.characterSkin[i] + 'BurningSmall'),
frameRate: 10,
repeat: -1
});
WordSpace.characterAnims[i][Enums.characterAnim.bigBurning] = scene.anims.create({
key: Enums.characterSkin[i] + 'bigBurningAnim',
frames: scene.anims.generateFrameNumbers(Enums.characterSkin[i] + 'BurningBig'),
frameRate: 10,
repeat: -1
});
WordSpace.characterAnims[i][Enums.characterAnim.throw] = scene.anims.create({
key: Enums.characterSkin[i] + 'ThrowAnim',
frames: scene.anims.generateFrameNumbers(Enums.characterSkin[i] + 'Throw'),
frameRate: 10,
repeat: 0
});
WordSpace.characterAnims[i][Enums.characterAnim.gameOver] = scene.anims.create({
key: Enums.characterSkin[i] + 'GameOverAnim',
frames: scene.anims.generateFrameNumbers(Enums.characterSkin[i] + 'GameOver'),
frameRate: 10,
repeat: 0
});
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -12,7 +12,7 @@ UIObject.createLabel = function (scene, x, y, depth, image, size, align, text =
text: scene.add.text(x, y, text, {
font: textSize + 'pt sejongFont',
align: 'center'
}).setDepth(depth).setOrigin(textOriginX, textOriginY).setColor(textColor),
}).setDepth(depth).setOrigin(textOriginX, textOriginY).setColor(textColor).setPadding(30, 30, 30, 30),
space: {
left: 10,
......@@ -52,33 +52,41 @@ UIObject.createButton = function(scene, buttonGameObject, overFrame, outFrame, d
clickInterval: 100
}
});
buttonGameObject = buttonGameObject.getElement('background');
let buttonGameObjectBackground = buttonGameObject.getElement('background');
temp.enabled = true;
buttonGameObject.setFrame(outFrame).setInteractive()
buttonGameObjectBackground.setFrame(outFrame > 0 ? outFrame : 0).setInteractive()
.on('pointerover', () => {
if(temp.enabled)
{
buttonGameObject.setFrame(overFrame);
if(overFrame > 0) buttonGameObjectBackground.setFrame(overFrame);
if(overFrame != -2) buttonGameObject.setScale(1.1);
}
})
.on('pointerdown', () => {
if(temp.enabled)
{
buttonGameObject.setFrame(downFrame);
if(downFrame > 0) buttonGameObjectBackground.setFrame(downFrame);
if(downFrame != -2) buttonGameObject.setScale(0.9);
clickCallback();
}
})
.on('pointerup', () => {
buttonGameObject.setFrame(overFrame);
if(temp.enabled)
{
if(overFrame > 0) buttonGameObjectBackground.setFrame(overFrame);
if(overFrame != -2) buttonGameObject.setScale(1.1);
}
})
.on('pointerout', () => {
buttonGameObject.setFrame(outFrame);
if(outFrame > 0) buttonGameObjectBackground.setFrame(outFrame);
if(outFrame != -2) buttonGameObject.setScale(1);
})
temp.setEnable = function(isEnable)
{
temp.enabled = isEnable;
return temp;
}
temp.getBackground = function() { return buttonGameObjectBackground; }
return temp;
}
\ No newline at end of file
......@@ -57,10 +57,6 @@ class WordObject
setTimeout(function() {
breakAnim.destroy();
}, 200);
RoomData.myself.playerImage.play(WordSpace.pyeongminAnims[Enums.characterAnim.write]);
RoomData.myself.playerImage.anims.chain(WordSpace.pyeongminAnims[Enums.characterAnim.sit]);
Audio.playSound(ScenesData.gameScene, 'killWord');
}
attract()
......@@ -112,6 +108,9 @@ class NormalWord extends WordObject
super.destroy();
if(isNormallyRemoved)
{
Audio.playSound(ScenesData.gameScene, 'killWord');
RoomData.myself.playerImage.play(WordSpace.characterAnims[PlayerData.userData.skin][Enums.characterAnim.write]);
RoomData.myself.playerImage.anims.chain(WordSpace.characterAnims[PlayerData.userData.skin][Enums.characterAnim.sit]);
switch(this.wordGrade)
{
case 0: WordSpace.attackGauge.add(2.5); break;
......@@ -150,8 +149,8 @@ class AttackWord extends WordObject
let textColor = '#000000'
super.instantiate(scene, spriteName, textColor, lenRate);
this.maskBackground = scene.physics.add.sprite(this.physicsObj.x, this.physicsObj.y, 'wordBgr' + this.wordGrade + '_' + Math.min(Math.max(2, this.wordText.length), 6))
.setTint(Phaser.Display.Color.GetColor(120, 120, 120)).setScale(this.scale);
this.maskBackground.alpha = this.isDark ? 1 : 0.5;
.setTint(Phaser.Display.Color.GetColor(40, 40, 40)).setScale(this.scale).setDepth(1.1);
this.maskBackground.alpha = this.isDark ? 1 : 0.7;
this.shape = scene.make.graphics();
var rect = new Phaser.Geom.Rectangle(0, 0, this.maskBackground.width * this.scale, this.maskBackground.height * this.scale);
this.shape.fillStyle(0xffffff).fillRectShape(rect);
......@@ -191,6 +190,9 @@ class AttackWord extends WordObject
super.destroy();
if(isNormallyRemoved)
{
Audio.playSound(ScenesData.gameScene, 'killWord');
RoomData.myself.playerImage.play(WordSpace.characterAnims[PlayerData.userData.skin][Enums.characterAnim.write]);
RoomData.myself.playerImage.anims.chain(WordSpace.characterAnims[PlayerData.userData.skin][Enums.characterAnim.sit]);
switch(this.wordGrade)
{
case 0: WordSpace.attackGauge.add(2.5); break;
......@@ -261,10 +263,7 @@ class NameWord extends WordObject
if(this.isStrong)
{
this.physicsObj.setScale(this.follower.t < 0.2 ? 0.2 : this.follower.t * this.scale);
this.wordObj.setFont({
font: (this.follower.t < 0.2 ? 0.05 : this.follower.t * this.scale * this.fontScale) +'pt sejongFont',
fontStyle: (this.wordWeight > 5 ? 'bold' : '')
});
this.wordObj.setScale((this.follower.t < 0.2 ? 0.2 : this.follower.t * this.scale) * 0.9);
}
}
}
......@@ -273,6 +272,9 @@ class NameWord extends WordObject
super.destroy();
if(isNormallyRemoved)
{
Audio.playSound(ScenesData.gameScene, 'killWord');
RoomData.myself.playerImage.play(WordSpace.characterAnims[PlayerData.userData.skin][Enums.characterAnim.write]);
RoomData.myself.playerImage.anims.chain(WordSpace.characterAnims[PlayerData.userData.skin][Enums.characterAnim.sit]);
ScenesData.gameScene.physics.world.removeCollider(this.physicsObj.wordCollider);
WordSpace.wordGroup.forEach(function(element)
{
......@@ -300,10 +302,6 @@ class NameWord extends WordObject
duration: 2000,
repeat: 0
});
//이동경로 디버그
/*var graphics = ScenesData.gameScene.add.graphics();
graphics.lineStyle(2, 0xffffff, 1);
this.path.draw(graphics);*/
}
}
}
......@@ -358,6 +356,9 @@ class ItemWord extends WordObject
super.destroy();
if(isNormallyRemoved)
{
Audio.playSound(ScenesData.gameScene, 'killWord');
RoomData.myself.playerImage.play(WordSpace.characterAnims[PlayerData.userData.skin][Enums.characterAnim.write]);
RoomData.myself.playerImage.anims.chain(WordSpace.characterAnims[PlayerData.userData.skin][Enums.characterAnim.sit]);
WordSpace.attackGauge.add(0.5);
switch(this.itemType)
{
......
......@@ -12,6 +12,9 @@ WordSpace.isTimerOn = false;
WordSpace.isInvincible = false;
WordSpace.pyeongminAnims = [];
WordSpace.characterAnims = Array(2).fill(null).map(() => Array());
WordSpace.wordGroup = [];
WordSpace.nameGroup = [];
WordSpace.attackPaperGroup = null;
......@@ -117,14 +120,12 @@ WordSpace.attackGauge =
if (this.value + plus > 11) this.value = 11;
else this.value += plus;
this.setRect();
this.text.setText('게이지: ' + this.value.toFixed(1));
},
sub: function(minus)
{
if (this.value - minus < 0) this.value = 0;
else this.value -= minus;
this.setRect();
this.text.setText('게이지: ' + this.value.toFixed(1));
},
resetValue: function() {this.value = 0;},
cutValue: function(cutOut) {this.value *= (1-cutOut);},
......@@ -141,7 +142,6 @@ WordSpace.attackGauge =
};
this.currentCycle = scene.time.addEvent(option);
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;},
......@@ -195,7 +195,6 @@ WordSpace.generateWord =
Item: function(scene, itemType, lenRate)
{
word = new ItemWord(itemType);
Audio.playSound(ScenesData.gameScene, 'getItem');
WordSpace.pushWord(scene, word, lenRate);
return word;
}
......@@ -266,7 +265,7 @@ WordSpace.findWord = function(wordText)
}
WordSpace.setPlayerTyping.add(wordText);
}
else if (wordText === '공격' && WordSpace.attackGauge.value >= 3 && WordSpace.nameGroup.length > 0) // 공격모드 진입.
else if (wordText === '공격' && WordSpace.attackGauge.value >= 2 && WordSpace.nameGroup.length > 0) // 공격모드 진입.
{
console.log('attack mode');
let tempAttackOption = this.attackGauge.getAttackOption();
......@@ -274,21 +273,22 @@ WordSpace.findWord = function(wordText)
Input.attackOption.wordGrade = tempAttackOption.wordGrade;
Input.maxInput = Input.attackOption.wordCount;
Input.attackMode = true;
Input.inputField.inputBackground.setFrame(Input.maxInput - 2);
WordSpace.attackGauge.pauseCycle(true);
WordSpace.setPlayerTyping.add(wordText);
switch(tempAttackOption.wordCount)
{
case 2:
RoomData.myself.playerImage.play(WordSpace.pyeongminAnims[Enums.characterAnim.notBurning]);
RoomData.myself.playerImage.play(WordSpace.characterAnims[PlayerData.userData.skin][Enums.characterAnim.notBurning]);
break;
case 3:
RoomData.myself.playerImage.play(WordSpace.pyeongminAnims[Enums.characterAnim.smallBurning]);
RoomData.myself.playerImage.play(WordSpace.characterAnims[PlayerData.userData.skin][Enums.characterAnim.smallBurning]);
break;
case 4:
RoomData.myself.playerImage.play(WordSpace.pyeongminAnims[Enums.characterAnim.smallBurning]);
RoomData.myself.playerImage.play(WordSpace.characterAnims[PlayerData.userData.skin][Enums.characterAnim.smallBurning]);
break;
case 5:
RoomData.myself.playerImage.play(WordSpace.pyeongminAnims[Enums.characterAnim.bigBurning]);
RoomData.myself.playerImage.play(WordSpace.characterAnims[PlayerData.userData.skin][Enums.characterAnim.bigBurning]);
break;
default:
console.log('Improper attack option.');
......@@ -337,13 +337,8 @@ WordSpace.setPlayerTyping =
{
this.totalTyping += wordText != null ? WordReader.getWordTyping(wordText) : 0;
WordSpace.playerTyping = this.totalTyping / WordSpace.gameTimer.now * 60 * 1000;
this.text.setText('현재 타수 : ' + WordSpace.playerTyping.toFixed(1));
this.writeWord = wordText != '' ? true : false;
},
initiate: function(scene)
{
this.text = scene.add.text(100,200,'현재 타수 : ' + WordSpace.playerTyping.toFixed(1)).setDepth(9.9).setColor('#000000');
},
reset: function()
{
this.totalTyping = 0;
......@@ -403,8 +398,8 @@ WordSpace.attack = function(wordText, grade)
WordSpace.attackGauge.resetValue();
WordSpace.setPlayerTyping.add(wordText);
RoomData.myself.playerImage.play(WordSpace.pyeongminAnims[Enums.characterAnim.throw]);
RoomData.myself.playerImage.anims.chain(WordSpace.pyeongminAnims[Enums.characterAnim.sit]);
RoomData.myself.playerImage.play(WordSpace.characterAnims[PlayerData.userData.skin][Enums.characterAnim.throw]);
RoomData.myself.playerImage.anims.chain(WordSpace.characterAnims[PlayerData.userData.skin][Enums.characterAnim.sit]);
Input.attackOption.isHeavy = false;
Input.attackOption.isDark = false;
}
......@@ -474,12 +469,8 @@ WordSpace.nameQueue =
getCount: function(player)
{
WordSpace.nameQueue.counter = 0;
WordSpace.nameGroup.forEach(function(element){
if(element.id == player.id) WordSpace.nameQueue.counter++;
})
WordSpace.wordGroup.forEach(function(element){
if(element instanceof NameWord && element.ownerId == player.id) WordSpace.nameQueue.counter++;
})
WordSpace.nameGroup.forEach(function(element){ if(element.ownerId == player.id) WordSpace.nameQueue.counter++; });
WordSpace.wordGroup.forEach(function(element){ if(element instanceof NameWord && element.ownerId == player.id) WordSpace.nameQueue.counter++; });
return WordSpace.nameQueue.counter;
},
counter: 0,
......@@ -503,7 +494,8 @@ WordSpace.changePhase = function(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');
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()
{
......@@ -526,7 +518,6 @@ WordSpace.resetGame = function()
WordSpace.isGameOver = false;
WordSpace.isTimerOn = false;
WordSpace.isInvincible = false;
WordSpace.pyeongminAnims = [];
WordSpace.wordGroup = [];
WordSpace.nameGroup = [];
......
......@@ -14,7 +14,7 @@ var config = {
}
},
backgroundColor: Phaser.Display.Color.HexStringToColor('#ffffff').color,//GetColor(245,208,138),
scene: [ menuScene, hopaeScene, roomScene, gameScene ]
scene: [ menuScene, hopaeScene, shopScene, roomScene, gameScene ]
};
var game = null;
......
......@@ -13,10 +13,10 @@ app.get('/', function(req, res) {
});
// http 기본 포트(80)에 서버 열기
server.listen(8080, function() {
console.log('[SERVER] Listening on port ' + server.address().port);
server.listen(80, function() {
console.log(new Date().toLocaleTimeString('ko-KR') + ' [SERVER] Listening on port ' + server.address().port);
GameServer.serverNumber = Math.floor(Math.random() * 1000 + 1);
console.log('[SERVER] server number is ' + GameServer.serverNumber);
console.log(new Date().toLocaleTimeString('ko-KR') + ' [SERVER] server number is ' + GameServer.serverNumber);
});
......@@ -29,12 +29,13 @@ io.on('connection', function(socket)
{
id: GameServer.getPlayerNumber(),
nickname: '게스트',
skin: 0,
currentRoom: null,
playingData: null,
isReceivable: false
};
GameServer.currentPlayer.push(socket);
console.log('['+socket.playerData.id+'] client request');
console.log(new Date().toLocaleTimeString('ko-KR') + ' ['+socket.playerData.id+'] client request');
socket.emit('setId',
{
str: 'your number is ' + socket.playerData.id,
......@@ -45,11 +46,12 @@ io.on('connection', function(socket)
socket.on('enterRoom', function(msg) // string new_nickname
{
if(msg.length < 1) socket.emit('alert' ,'errNicknameEmpty');
if(msg.nickname.length < 1) socket.emit('alert' ,'errNicknameEmpty');
else
{
socket.playerData.nickname = msg;
console.log('['+socket.playerData.id+'] nickname set to ' + msg);
socket.playerData.nickname = msg.nickname;
socket.playerData.skiin = msg.skin;
console.log(new Date().toLocaleTimeString('ko-KR') + ' ['+socket.playerData.id+'] nickname set to ' + msg.nickname);
GameServer.enterEmptyRoom(socket);
}
});
......@@ -100,7 +102,7 @@ io.on('connection', function(socket)
}, 1000);
}
catch (e) {
console.error('[ERR] error catched on setPlayerTyping (' + e + ')');
console.error(new Date().toLocaleTimeString('ko-KR') + ' [ERR] error catched on setPlayerTyping (' + e + ')');
socket.disconnect();
}
});
......@@ -110,6 +112,7 @@ io.on('connection', function(socket)
socket.playerData.currentRoom.aliveCount--;
//console.log('counted, ' + socket.playerData.currentRoom.aliveCount);
socket.playerData.playingData.isAlive = true;
if (socket.playerData.currentRoom.currentPhase != GameServer.Phase.COUNT) socket.disconnect();
if (socket.playerData.currentRoom.aliveCount === 0 && socket.playerData.currentRoom.currentPlayer.length >= socket.playerData.currentRoom.startCount)
{
socket.playerData.currentRoom.startRoom();
......@@ -121,25 +124,21 @@ io.on('connection', function(socket)
room.startTimer = setTimeout(function()
{
let deads = room.currentPlayer.filter(element => !element.isAlive);
if (room.aliveCount != 0 && room.currentPlayer.length - deads.length >= room.startCount)
{
console.error('[ROOM#'+room.roomId+'] FORCE START!!!');
room.startRoom();
deads.forEach(function(element)
deads.forEach(function(element)
{
element.defeat();
room.currentSocket[element.index].disconnect();
room.exitRoom(element.id);
});
clearTimeout(room.startTimer);
if (room.aliveCount != 0 && room.currentPlayer.length >= room.startCount)
{
console.error(new Date().toLocaleTimeString('ko-KR') + ' [ROOM#'+room.roomId+'] FORCE START!!!');
room.startRoom();
}
else if (deads.length > 0)
{
deads.forEach(function(element)
{
room.currentSocket[element.index].disconnect();
room.exitRoom(element.id);
});
room.refreshRoom();
}
clearTimeout(room.startTimer);
}, 2000);
}
});
......@@ -202,7 +201,7 @@ io.on('connection', function(socket)
let data = socket.playerData;
if (data === undefined)
{
console.error('[ERROR] data is undefined');
console.error(new Date().toLocaleTimeString('ko-KR') + ' [ERROR] data is undefined');
console.table(GameServer.currentPlayer);
GameServer.disconnectCount--;
}
......@@ -223,7 +222,7 @@ io.on('connection', function(socket)
var disconnectUser = function(data, reason)
{
console.log('['+ data.id +'] client disconnected, reason: ' + reason);
console.log(new Date().toLocaleTimeString('ko-KR') + ' ['+ data.id +'] client disconnected, reason: ' + reason);
let idxToDel = GameServer.currentPlayer.findIndex(function(element)
{
return element.playerData.id === data.id;
......@@ -245,5 +244,5 @@ var disconnectUser = function(data, reason)
}
GameServer.currentPlayer.splice(idxToDel, 1);
}
console.log('['+ data.id +'] disconnect complete');
//console.log('['+ data.id +'] disconnect complete');
}
\ No newline at end of file
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