Merge branch 'master' of ssh://cryps.gg:40022/~/cryps
This commit is contained in:
commit
0cec71e68e
@ -12,17 +12,17 @@ const teamHitBox = (scene, size, team, cback) => {
|
|||||||
.rectangle(TEAM_MARGIN * team, Y_PADDING, CRYP_WIDTH, height, 0x222222)
|
.rectangle(TEAM_MARGIN * team, Y_PADDING, CRYP_WIDTH, height, 0x222222)
|
||||||
.setInteractive()
|
.setInteractive()
|
||||||
.setOrigin(0)
|
.setOrigin(0)
|
||||||
.on('pointerdown', cback);
|
.on('pointerup', cback);
|
||||||
};
|
};
|
||||||
|
|
||||||
const crypHitBox = (scene, iter, team, cback) => {
|
class CrypHitBox extends Phaser.GameObjects.Rectangle {
|
||||||
const y = Y_PADDING + iter * (CRYP_HEIGHT + (Y_PADDING * 0.5));
|
constructor(scene, iter, team, cback) {
|
||||||
scene.add
|
const y = Y_PADDING + iter * (CRYP_HEIGHT + (Y_PADDING * 0.5));
|
||||||
.rectangle(TEAM_MARGIN * team, y, CRYP_WIDTH, CRYP_HEIGHT, 0x222222)
|
super(scene, TEAM_MARGIN * team, y, CRYP_WIDTH, CRYP_HEIGHT, 0x222222);
|
||||||
.setInteractive()
|
this.setOrigin(0);
|
||||||
.setOrigin(0)
|
this.clickHandler = () => cback();
|
||||||
.on('pointerdown', cback);
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
class CombatHitBox extends Phaser.Scene {
|
class CombatHitBox extends Phaser.Scene {
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -39,11 +39,10 @@ class CombatHitBox extends Phaser.Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateData(parent, key, data) {
|
updateData(parent, key, data) {
|
||||||
if (key === 'game' && data && !this.started && data.phase !== 'Start') {
|
if (key === 'game' && data) {
|
||||||
this.started = true;
|
// In the case that we hit skill phase but teams change we restart
|
||||||
this.selectHitBox(data.phase);
|
if (data.teams.length !== this.teams) this.scene.restart(data.phase);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key === 'gamePhase' && data) {
|
if (key === 'gamePhase' && data) {
|
||||||
const shouldUpdate = data !== this.phase;
|
const shouldUpdate = data !== this.phase;
|
||||||
if (shouldUpdate) this.scene.restart(data);
|
if (shouldUpdate) this.scene.restart(data);
|
||||||
@ -53,8 +52,8 @@ class CombatHitBox extends Phaser.Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
selectHitBox(phase) {
|
selectHitBox(phase) {
|
||||||
this.phase = phase;
|
|
||||||
const game = this.registry.get('game');
|
const game = this.registry.get('game');
|
||||||
|
this.teams = game.teams.length;
|
||||||
if (phase === 'Skill') return this.skillHitBox(game);
|
if (phase === 'Skill') return this.skillHitBox(game);
|
||||||
if (phase === 'Target') return this.targetHitBox(game);
|
if (phase === 'Target') return this.targetHitBox(game);
|
||||||
return false;
|
return false;
|
||||||
@ -84,7 +83,6 @@ class CombatHitBox extends Phaser.Scene {
|
|||||||
const account = this.registry.get('account');
|
const account = this.registry.get('account');
|
||||||
const group = this.scene.get('CombatCryps').cryps;
|
const group = this.scene.get('CombatCryps').cryps;
|
||||||
const skillScene = this.scene.get('CombatSkills');
|
const skillScene = this.scene.get('CombatSkills');
|
||||||
|
|
||||||
game.teams.forEach(t => t.cryps.forEach((c) => {
|
game.teams.forEach(t => t.cryps.forEach((c) => {
|
||||||
const cback = () => {
|
const cback = () => {
|
||||||
const { activeTarget } = skillScene;
|
const { activeTarget } = skillScene;
|
||||||
@ -97,7 +95,7 @@ class CombatHitBox extends Phaser.Scene {
|
|||||||
|
|
||||||
const crypSpawn = group.children.entries.find(s => s.cryp.id === c.id);
|
const crypSpawn = group.children.entries.find(s => s.cryp.id === c.id);
|
||||||
const team = c.account === account.id ? 0 : 1;
|
const team = c.account === account.id ? 0 : 1;
|
||||||
crypHitBox(this, crypSpawn.iter, team, cback);
|
this.add.existing(new CrypHitBox(this, crypSpawn.iter, team, cback));
|
||||||
}));
|
}));
|
||||||
this.scene.sendToBack();
|
this.scene.sendToBack();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,13 +41,14 @@ class CrypSkill extends Phaser.GameObjects.Text {
|
|||||||
const CD_TEXT = skill.cd ? `(${skill.cd}T)` : '';
|
const CD_TEXT = skill.cd ? `(${skill.cd}T)` : '';
|
||||||
const SKILL_TEXT = `${skill.skill} ${CD_TEXT}`;
|
const SKILL_TEXT = `${skill.skill} ${CD_TEXT}`;
|
||||||
super(scene, x, y, SKILL_TEXT, TEXT.NORMAL);
|
super(scene, x, y, SKILL_TEXT, TEXT.NORMAL);
|
||||||
|
this.origX = x;
|
||||||
|
this.origY = y;
|
||||||
|
|
||||||
this.cryp = cryp;
|
this.cryp = cryp;
|
||||||
this.skill = skill;
|
this.skill = skill;
|
||||||
this.scene = scene;
|
this.scene = scene;
|
||||||
|
|
||||||
this.activeSkill = null;
|
this.activeSkill = null;
|
||||||
this.activeTarget = null;
|
this.activeTarget = null;
|
||||||
|
|
||||||
this.setInteractive();
|
this.setInteractive();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,11 +82,23 @@ class CombatSkills extends Phaser.Scene {
|
|||||||
this.registry.events.on('changedata', this.updateData, this);
|
this.registry.events.on('changedata', this.updateData, this);
|
||||||
this.account = this.registry.get('account');
|
this.account = this.registry.get('account');
|
||||||
|
|
||||||
this.input.on('pointerup', (pointer, obj) => {
|
this.input.on('dragstart', (pointer, obj) => {
|
||||||
if (obj[0] instanceof CrypSkill) {
|
obj.clickHandler();
|
||||||
obj[0].clickHandler();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.input.on('drag', (pointer, obj, dragX, dragY) => {
|
||||||
|
obj.setPosition(dragX, dragY);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.input.on('dragend', (pointer, obj) => {
|
||||||
|
const hitBoxScene = this.scene.get('CombatHitBox');
|
||||||
|
hitBoxScene.children.list.forEach((hitBox) => {
|
||||||
|
if (Phaser.Geom.Rectangle
|
||||||
|
.ContainsPoint(hitBox.getBounds(), pointer.position)) hitBox.clickHandler();
|
||||||
|
});
|
||||||
|
obj.setPosition(obj.origX, obj.origY);
|
||||||
|
});
|
||||||
|
|
||||||
if (phase === 'animating') return true;
|
if (phase === 'animating') return true;
|
||||||
// can't set this.game cause of phaser class named the same
|
// can't set this.game cause of phaser class named the same
|
||||||
const game = this.registry.get('game');
|
const game = this.registry.get('game');
|
||||||
@ -215,6 +228,7 @@ class CombatSkills extends Phaser.Scene {
|
|||||||
const skillPos = targetTextPosition(sourceCryp.iter, sourceCryp.team);
|
const skillPos = targetTextPosition(sourceCryp.iter, sourceCryp.team);
|
||||||
const skillObj = new CrypSkill(this, skillPos[0], skillPos[1], skill, cryp);
|
const skillObj = new CrypSkill(this, skillPos[0], skillPos[1], skill, cryp);
|
||||||
this.add.existing(skillObj);
|
this.add.existing(skillObj);
|
||||||
|
this.input.setDraggable(skillObj);
|
||||||
|
|
||||||
keyboard.on(
|
keyboard.on(
|
||||||
TARGET_KEY_MAP[i],
|
TARGET_KEY_MAP[i],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user