Commit 9b37f144 authored by 18손재민's avatar 18손재민

아이템 단어 중 명단 단어 구현, 이제 강호패는 한바퀴를 더 돌며 들어옴 아이템 단어 생성 구현

parent 406cf127
......@@ -27,7 +27,7 @@ BackGround.drawCharacter = function(scene)
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.45).setDepth(1);
element.playerImage = scene.add.sprite(element.position.x, element.position.y, 'pyeongminWrite').setScale(0.315).setDepth(1);
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);
......
......@@ -59,7 +59,7 @@ socket.on('setRoomCount', function(msg)
ScenesData.roomScene.endTime = msg.endTime;
ScenesData.roomScene.peopleCount = msg.playerCount;
if (msg.isEnter) // generate charactor
if (msg.isEnter) // generate character
{
let randX = Math.random() * 1120 + 80;
let randY = Math.random() * 380 + 100;
......@@ -71,7 +71,7 @@ socket.on('setRoomCount', function(msg)
}
ScenesData.roomScene.players.push(playerSet);
}
else // remove charactor
else // remove character
{
let idx = ScenesData.roomScene.players.findIndex(function(element)
{
......@@ -140,12 +140,12 @@ socket.on('attackMode', function(msg) // number playerId
console.log(msg + ' is on attack Mode');
// msg의 id를 가진 사람이 attack Mode이다.
});
socket.on('someoneAttacked', function(msg) // {number attackerId, number targetId}
socket.on('someoneAttacked', function(msg) // {Player attacker, Player victim}
{
// 이때 위의 attack Mode인 사람(msg.attackerId)을 해제해주자.
console.log(msg.attackerId + ' attacked ' + msg.targetId);
let attackerPos = RoomData.players.find(function(element){ return element.id == msg.attackerId; });
let victimPos = RoomData.players.find(function(element){ return element.id == msg.victimId; });
console.log(msg.attacker.id + ' attacked ' + msg.victim.id);
let attackerPos = RoomData.findPlayer(msg.victim).position;
let victimPos = RoomData.findPlayer(msg.victim).position;
WordSpace.makeAttackPaper(ScenesData.gameScene, attackerPos.position, victimPos.position);
});
socket.on('attacked', function(msg) // object attackData
......@@ -155,8 +155,7 @@ socket.on('attacked', function(msg) // object attackData
{
for (let i = 0; i < msg.multiple; i++) WordSpace.generateWord.Attack(ScenesData.gameScene, msg.text, msg.grade, msg.attacker, msg.isStrong, msg.isCountable);
attackedEvent.currentCycle.destroy();
WordSpace.attackedEvents.splice(WordSpace.attackedEvents.findIndex(function(element)
{
WordSpace.attackedEvents.splice(WordSpace.attackedEvents.findIndex(function(element) {
return element.cert === (msg.text + msg.attacker);
}), 1);
});
......@@ -189,6 +188,9 @@ socket.on('attackSucceed', function(msg)
{
//console.log('client');
let tempWord = WordSpace.generateWord.Name(ScenesData.gameScene, true, msg.victim);
let victimPos = RoomData.findPlayer(msg.victim).position;
tempWord.physicsObj.setPosition(victimPos.x, victimPos.y);
tempWord.wordObj.setPosition(tempWord.physicsObj.x, tempWord.physicsObj.y);
tempWord.destroy();
});
......
var Enums = Enums || {};
Enums.characterAnim = { write: 0, attackWrite: 1, throw: 2, hit: 3 }
\ No newline at end of file
Enums.characterAnim = { write: 0, attackWrite: 1, throw: 2, hit: 3 }
Enums.item = {invincible: "무적", nameList: "명단", charge: "충전", clean: "청소", heavy: "중량", dark: "암흑"}
\ No newline at end of file
......@@ -150,10 +150,11 @@ var gameScene = new Phaser.Class(
WordSpace.nameWordTextForTest = ScenesData.gameScene.add.text(50,400,'현재 가진 호패들 : 없음').setDepth(10).setColor('#000000');
WordSpace.nameQueue.initiate();
WordSpace.generateWord.Item(ScenesData.gameScene, Enums.item.nameList);
WordSpace.generateWord.Item(ScenesData.gameScene, Enums.item.nameList);
// for test
WordSpace.attackGauge.add(11);
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
/*WordSpace.attackGauge.add(11);
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
......@@ -164,6 +165,7 @@ var gameScene = new Phaser.Class(
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);*/
},
update: function()
......
......@@ -233,7 +233,7 @@ class NameWord extends WordObject
this.path.getPoint(this.follower.t, this.follower.vec);
this.physicsObj.setPosition(this.follower.vec.x, this.follower.vec.y);
this.wordObj.setPosition(this.physicsObj.x, this.physicsObj.y);
this.physicsObj.angle = 90 * this.follower.t;
this.physicsObj.angle = (this.isStrong ? 450 : 90) * this.follower.t
this.wordObj.angle = this.physicsObj.angle;
if(this.isStrong)
{
......@@ -276,10 +276,56 @@ class NameWord extends WordObject
duration: 2000,
repeat: 0
});
//이동경로 디버그
/*var graphics = ScenesData.gameScene.add.graphics();
graphics.lineStyle(2, 0xffffff, 1);
this.path.draw(graphics);*/
}
}
class ItemWord extends WordObject
{
constructor(_itemType)
{
super(_itemType, false);
this.wordWeight = 2;
this.itemType = _itemType
//console.log('Name : ' + player.nickname + ', Strong : ' + this.isStrong + ', Weight : ' + this.wordWeight);
}
destroy()
{
WordSpace.attackGauge.add(0.5);
switch(this.itemType)
{
case Enums.item.invincible:
break;
case Enums.item.nameList:
let tempNames = [];
RoomData.players.forEach(function(element){
if(element.id != RoomData.myself.id && element.isAlive) tempNames.push(element.index)
});
let length = Math.min(tempNames.length, 8);
tempNames = Phaser.Utils.Array.Shuffle(tempNames);
for(let i = 0; i < length; i++)
{
let tempWord = WordSpace.generateWord.Name(ScenesData.gameScene, true, RoomData.players[tempNames[i]]);
tempWord.physicsObj.setPosition(this.physicsObj.x, this.physicsObj.y);
tempWord.wordObj.setPosition(tempWord.physicsObj.x, tempWord.physicsObj.y);
tempWord.destroy();
}
break;
case Enums.item.charge:
break;
case Enums.item.clean:
break;
case Enums.item.heavy:
break;
case Enums.item.dark:
break;
default:
console.log("Item type is inappropriate. Item type : " + this.itemType);
break;
}
super.destroy();
}
}
\ No newline at end of file
......@@ -250,6 +250,12 @@ WordSpace.generateWord =
else word = new NameWord(newPlayerData, isStrong);
WordSpace.pushWord(scene, word, lenRate);
return word;
},
Item: function(scene, itemType, lenRate)
{
word = new ItemWord(itemType);
WordSpace.pushWord(scene, word, lenRate);
return word;
}
}
......@@ -478,9 +484,9 @@ WordSpace.nameQueue =
{
let tempQueue = [];
RoomData.players.forEach(function(element){
tempQueue.push(element.index)
tempQueue.push(element.index);
})
tempQueue.sort(function(){return 0.5-Math.random()});
Phaser.Utils.Array.Shuffle(tempQueue);
tempQueue.forEach(function(element)
{
if(RoomData.players[element].id != PlayerData.id && RoomData.players[element].isAlive && WordSpace.nameQueue.getCount(element) < 3)
......
......@@ -32,4 +32,8 @@ var RoomData = RoomData || {};
RoomData.roomId = -1;
RoomData.myself = null;
RoomData.players = null;
RoomData.aliveCount = -1;
\ No newline at end of file
RoomData.aliveCount = -1;
RoomData.findPlayer = function(player)
{
return RoomData.players.find(function(element){ return element.id == player.id; });
}
\ No newline at end of file
......@@ -95,7 +95,7 @@ io.on('connection', function(socket)
socket.on('attack', function(msg)
{
socket.playerData.currentRoom.announceToTarget(msg.victim.id, 'attacked', msg);
socket.playerData.currentRoom.announceToRoom('someoneAttacked', {attackerId: msg.attacker.id, victimId: msg.victim.id});
socket.playerData.currentRoom.announceToRoom('someoneAttacked', {attacker: msg.attacker, victim: msg.victim});
//console.log('attack ' + msg.target + ' by ' + msg.attacker.id + ' with ' + msg.text);
setTimeout(function()
{
......
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