direct action
This commit is contained in:
@@ -6,23 +6,6 @@ const CRYP_WIDTH = COMBAT.width() * 0.2;
|
||||
const TEAM_MARGIN = COMBAT.width() * 0.775;
|
||||
const Y_PADDING = COMBAT.height() * 0.1;
|
||||
|
||||
class TeamHitBox extends Phaser.GameObjects.Rectangle {
|
||||
constructor(scene, size, team, cback) {
|
||||
const height = CRYP_HEIGHT * (size) + (Y_PADDING * 0.5) * (size - 1);
|
||||
super(scene, TEAM_MARGIN * team, Y_PADDING, CRYP_WIDTH, height, 0x222222);
|
||||
this.setOrigin(0);
|
||||
this.clickHandler = () => cback();
|
||||
}
|
||||
|
||||
select() {
|
||||
this.setFillStyle(0x003300);
|
||||
}
|
||||
|
||||
deselect() {
|
||||
this.setFillStyle(0x222222);
|
||||
}
|
||||
}
|
||||
|
||||
class CrypHitBox extends Phaser.GameObjects.Rectangle {
|
||||
constructor(scene, iter, team, cback) {
|
||||
const y = Y_PADDING + iter * (CRYP_HEIGHT + (Y_PADDING * 0.5));
|
||||
@@ -71,47 +54,30 @@ class CombatHitBox extends Phaser.Scene {
|
||||
const game = this.registry.get('game');
|
||||
this.teams = game.teams.length;
|
||||
if (phase === 'Skill') return this.skillHitBox(game);
|
||||
if (phase === 'Target') return this.targetHitBox(game);
|
||||
return false;
|
||||
}
|
||||
|
||||
skillHitBox(game) {
|
||||
const account = this.registry.get('account');
|
||||
game.teams.forEach((t) => {
|
||||
const cback = () => {
|
||||
const skillScene = this.scene.get('CombatSkills');
|
||||
const { activeSkill } = skillScene;
|
||||
if (activeSkill) {
|
||||
activeSkill.activate();
|
||||
skillScene.activeSkill = null;
|
||||
this.game.events.emit('SEND_SKILL', game.id, activeSkill.cryp.id,
|
||||
t.id, activeSkill.skill.skill);
|
||||
}
|
||||
};
|
||||
const team = t.id === account.id ? 0 : 1;
|
||||
const size = t.cryps.length;
|
||||
this.add.existing(new TeamHitBox(this, size, team, cback));
|
||||
});
|
||||
this.scene.sendToBack();
|
||||
}
|
||||
|
||||
targetHitBox(game) {
|
||||
const account = this.registry.get('account');
|
||||
const group = this.scene.get('CombatCryps').cryps;
|
||||
const skillScene = this.scene.get('CombatSkills');
|
||||
game.teams.find(t => t.id === account.id).cryps.forEach((c) => {
|
||||
const cback = () => {
|
||||
const { activeTarget } = skillScene;
|
||||
if (activeTarget) {
|
||||
activeTarget.activate();
|
||||
skillScene.activeTarget = null;
|
||||
this.game.events.emit('SEND_TARGET', game.id, c.id, activeTarget.skill);
|
||||
}
|
||||
};
|
||||
game.teams.forEach((t) => {
|
||||
t.cryps.forEach((c) => {
|
||||
const cback = () => {
|
||||
const { activeSkill } = skillScene;
|
||||
console.log(activeSkill);
|
||||
if (activeSkill) {
|
||||
activeSkill.activate();
|
||||
skillScene.activeSkill = null;
|
||||
this.game.events.emit('SEND_SKILL', game.id, activeSkill.cryp.id, c.id, activeSkill.skill.skill);
|
||||
}
|
||||
};
|
||||
|
||||
const crypSpawn = group.children.entries.find(s => s.cryp.id === c.id);
|
||||
const team = c.account === account.id ? 0 : 1;
|
||||
this.add.existing(new CrypHitBox(this, crypSpawn.iter, team, cback));
|
||||
const crypSpawn = group.children.entries.find(s => s.cryp.id === c.id);
|
||||
const team = c.account === account.id ? 0 : 1;
|
||||
console.log(crypSpawn);
|
||||
this.add.existing(new CrypHitBox(this, crypSpawn.iter, team, cback));
|
||||
});
|
||||
});
|
||||
this.scene.sendToBack();
|
||||
}
|
||||
|
||||
@@ -59,7 +59,6 @@ class CrypSkill extends Phaser.GameObjects.Container {
|
||||
|
||||
clickHandler() {
|
||||
if (this.scene.phase === 'Skill') this.scene.activeSkill = this;
|
||||
if (this.scene.phase === 'Target') this.scene.activeTarget = this;
|
||||
this.select();
|
||||
}
|
||||
|
||||
@@ -135,8 +134,6 @@ class CombatSkills extends Phaser.Scene {
|
||||
|
||||
renderSkills(game, phase) {
|
||||
if (phase === 'Skill') return this.renderSkillPhase(game);
|
||||
if (phase === 'Target') return this.renderTargetPhase(game);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -183,6 +180,8 @@ class CombatSkills extends Phaser.Scene {
|
||||
return true;
|
||||
}
|
||||
|
||||
// FIXME
|
||||
// needs to send crypId not team
|
||||
mapSkillKeys(skillButtons, gameId, crypId, alliesId, enemyId, i) {
|
||||
const { keyboard } = this.input;
|
||||
|
||||
|
||||
@@ -24,7 +24,8 @@ function renderCryps() {
|
||||
scene: [
|
||||
Background,
|
||||
Header,
|
||||
], };
|
||||
],
|
||||
};
|
||||
|
||||
const game = new Phaser.Game(config);
|
||||
|
||||
|
||||
@@ -85,11 +85,11 @@ function createSocket(events) {
|
||||
}
|
||||
|
||||
|
||||
function sendGameSkill(gameId, crypId, targetTeamId, skill) {
|
||||
function sendGameSkill(gameId, crypId, targetCrypId, skill) {
|
||||
send({
|
||||
method: 'game_skill',
|
||||
params: {
|
||||
game_id: gameId, cryp_id: crypId, target_team_id: targetTeamId, skill,
|
||||
game_id: gameId, cryp_id: crypId, target_cryp_id: targetCrypId, skill,
|
||||
},
|
||||
});
|
||||
events.setActiveSkill(null);
|
||||
|
||||
Reference in New Issue
Block a user