Added heals and removed enemy hitbox in target phase
This commit is contained in:
parent
b43fc44303
commit
aca21d267d
@ -15,12 +15,44 @@ const animationParams = (isAlly) => {
|
|||||||
return { spawnLocation, speed, img, angleMin, angleMax };
|
return { spawnLocation, speed, img, angleMin, angleMax };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const randomAnimation = () => {
|
||||||
|
const animations = ['wall', 'spit', 'gravBlast', 'gravBomb', 'chargeBall'];
|
||||||
|
return animations[Math.floor(Math.random() * 5)];
|
||||||
|
};
|
||||||
|
|
||||||
class CombatSkills extends Phaser.GameObjects.Group {
|
class CombatSkills extends Phaser.GameObjects.Group {
|
||||||
constructor(scene) {
|
constructor(scene) {
|
||||||
super(scene);
|
super(scene);
|
||||||
this.scene = scene;
|
this.scene = scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSkill(type, isAlly) {
|
||||||
|
if (type === 'attack') {
|
||||||
|
this[randomAnimation()](isAlly);
|
||||||
|
} else {
|
||||||
|
this.heal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
heal() {
|
||||||
|
const lifespan = DELAYS.ANIMATION_DURATION;
|
||||||
|
const particles = this.scene.add.particles(randomColour());
|
||||||
|
const emitter = particles.createEmitter({
|
||||||
|
x: COMBAT.width() * 0.3,
|
||||||
|
y: COMBAT.height() * 0.2,
|
||||||
|
angle: { min: 250, max: 290 },
|
||||||
|
speed: 250,
|
||||||
|
gravityY: 1000,
|
||||||
|
quantity: 4,
|
||||||
|
scale: { start: 0.1, end: 1 },
|
||||||
|
blendMode: 'ADD',
|
||||||
|
lifespan,
|
||||||
|
});
|
||||||
|
this.add(particles);
|
||||||
|
this.scene.time.delayedCall(lifespan, () => { emitter.stop(); }, [], this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
wall(isAlly) {
|
wall(isAlly) {
|
||||||
const lifespan = DELAYS.ANIMATION_DURATION;
|
const lifespan = DELAYS.ANIMATION_DURATION;
|
||||||
const { spawnLocation, speed, img } = animationParams(isAlly);
|
const { spawnLocation, speed, img } = animationParams(isAlly);
|
||||||
|
|||||||
@ -99,7 +99,7 @@ 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.find(t => t.id === account.id).cryps.forEach((c) => {
|
||||||
const cback = () => {
|
const cback = () => {
|
||||||
const { activeTarget } = skillScene;
|
const { activeTarget } = skillScene;
|
||||||
if (activeTarget) {
|
if (activeTarget) {
|
||||||
@ -112,7 +112,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;
|
||||||
this.add.existing(new CrypHitBox(this, crypSpawn.iter, team, cback));
|
this.add.existing(new CrypHitBox(this, crypSpawn.iter, team, cback));
|
||||||
}));
|
});
|
||||||
this.scene.sendToBack();
|
this.scene.sendToBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,11 +6,6 @@ const {
|
|||||||
POSITIONS: { COMBAT },
|
POSITIONS: { COMBAT },
|
||||||
} = require('./constants');
|
} = require('./constants');
|
||||||
|
|
||||||
const randomAnimation = () => {
|
|
||||||
const animations = ['wall', 'spit', 'gravBlast', 'gravBomb', 'chargeBall'];
|
|
||||||
return animations[Math.floor(Math.random() * 5)];
|
|
||||||
};
|
|
||||||
|
|
||||||
function findResolutionCryps(scene, group, resolution, game) {
|
function findResolutionCryps(scene, group, resolution, game) {
|
||||||
|
|
||||||
const sourceCryp = game.teams.find(t => t.cryps.find(c => c.id === resolution.source_cryp_id))
|
const sourceCryp = game.teams.find(t => t.cryps.find(c => c.id === resolution.source_cryp_id))
|
||||||
@ -55,7 +50,6 @@ function animatePhase(scene, game, resolution, cb) {
|
|||||||
const group = scene.scene.get('CombatCryps').cryps;
|
const group = scene.scene.get('CombatCryps').cryps;
|
||||||
const animations = new CombatAnimations(scene);
|
const animations = new CombatAnimations(scene);
|
||||||
const account = scene.registry.get('account');
|
const account = scene.registry.get('account');
|
||||||
const animation = randomAnimation();
|
|
||||||
|
|
||||||
// Find cryps, targets
|
// Find cryps, targets
|
||||||
const { sourceSpawn, targetSpawn } = findResolutionCryps(scene, group, resolution, game);
|
const { sourceSpawn, targetSpawn } = findResolutionCryps(scene, group, resolution, game);
|
||||||
@ -75,7 +69,8 @@ function animatePhase(scene, game, resolution, cb) {
|
|||||||
scene.time.delayedCall(MOVE_CREEP, () => {
|
scene.time.delayedCall(MOVE_CREEP, () => {
|
||||||
const isAlly = resolution.target_team_id !== account.id;
|
const isAlly = resolution.target_team_id !== account.id;
|
||||||
// animate animation
|
// animate animation
|
||||||
animations[animation](isAlly);
|
if (resolution.skill === 'Heal') animations.getSkill(resolution.skill, isAlly);
|
||||||
|
else animations.getSkill('attack', isAlly);
|
||||||
|
|
||||||
// Target cryp takes damage
|
// Target cryp takes damage
|
||||||
scene.time.delayedCall(ANIMATION_DURATION, () => {
|
scene.time.delayedCall(ANIMATION_DURATION, () => {
|
||||||
|
|||||||
@ -157,10 +157,12 @@ class CombatSkills extends Phaser.Scene {
|
|||||||
const enemyTeam = game.teams.find(t => t.id !== account.id);
|
const enemyTeam = game.teams.find(t => t.id !== account.id);
|
||||||
|
|
||||||
team.cryps.forEach((cryp) => {
|
team.cryps.forEach((cryp) => {
|
||||||
const { iter } = this.scene.get('CombatCryps').cryps.children.entries.find(c => c.cryp.id === cryp.id);
|
|
||||||
// return early if KOd
|
// return early if KOd
|
||||||
if (cryp.hp.base === 0) return true;
|
if (cryp.hp.base === 0) return true;
|
||||||
|
|
||||||
|
// find the cryp position
|
||||||
|
const { iter } = this.scene.get('CombatCryps').cryps.children.entries.find(c => c.cryp.id === cryp.id);
|
||||||
|
|
||||||
// draw the skills
|
// draw the skills
|
||||||
const skillButtons = cryp.skills.map((skill, j) => addSkill(iter, j, skill, cryp));
|
const skillButtons = cryp.skills.map((skill, j) => addSkill(iter, j, skill, cryp));
|
||||||
|
|
||||||
@ -221,22 +223,22 @@ class CombatSkills extends Phaser.Scene {
|
|||||||
const skills = game.stack.filter(skill => skill.target_team_id === account.id);
|
const skills = game.stack.filter(skill => skill.target_team_id === account.id);
|
||||||
const friendlyCryps = game.teams.find(t => t.id === account.id).cryps;
|
const friendlyCryps = game.teams.find(t => t.id === account.id).cryps;
|
||||||
|
|
||||||
skills.forEach((skill, i) => {
|
skills.forEach((skill) => {
|
||||||
const crypTeam = game.teams.find(t => t.cryps.find(c => c.id === skill.source_cryp_id));
|
const crypTeam = game.teams.find(t => t.cryps.find(c => c.id === skill.source_cryp_id));
|
||||||
const cryp = crypTeam.cryps.find(c => c.id === skill.source_cryp_id);
|
const cryp = crypTeam.cryps.find(c => c.id === skill.source_cryp_id);
|
||||||
|
|
||||||
// Draw the cryp name
|
// Draw the cryp name
|
||||||
const sourceCryp = this.scene.get('CombatCryps').cryps.children.entries
|
const { iter, team } = this.scene.get('CombatCryps').cryps.children.entries
|
||||||
.find(c => c.cryp.id === cryp.id);
|
.find(c => c.cryp.id === cryp.id);
|
||||||
|
|
||||||
const skillPos = targetTextPosition(sourceCryp.iter, sourceCryp.team);
|
const skillPos = targetTextPosition(iter, 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);
|
this.input.setDraggable(skillObj);
|
||||||
|
|
||||||
keyboard.on(
|
keyboard.on(
|
||||||
TARGET_KEY_MAP[i],
|
TARGET_KEY_MAP[iter],
|
||||||
() => this.mapTargetKeys(skillObj, game.id, friendlyCryps, i),
|
() => this.mapTargetKeys(skillObj, game.id, friendlyCryps, iter),
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user