improved decay combat sequence

This commit is contained in:
Mashy 2019-03-26 17:04:06 +10:00
parent 514b9b0b53
commit 2c8ddcd186
2 changed files with 41 additions and 34 deletions

View File

@ -6,12 +6,12 @@ const randomColour = () => {
return colours[Math.floor(Math.random() * 5)]; return colours[Math.floor(Math.random() * 5)];
}; };
const animationParams = (isAlly) => { const animationParams = (sourceAlly) => {
const spawnLocation = isAlly ? COMBAT.width() * 0.35 : COMBAT.width() * 0.65; const spawnLocation = sourceAlly ? COMBAT.width() * 0.35 : COMBAT.width() * 0.65;
const speed = isAlly ? 250 : -250; const speed = sourceAlly ? 250 : -250;
const img = randomColour(); const img = randomColour();
const angleMin = isAlly ? 320 : 180; const angleMin = sourceAlly ? 320 : 180;
const angleMax = isAlly ? 360 : 220; const angleMax = sourceAlly ? 360 : 220;
return { spawnLocation, speed, img, angleMin, angleMax }; return { spawnLocation, speed, img, angleMin, angleMax };
}; };
@ -26,25 +26,25 @@ class CombatSkills extends Phaser.GameObjects.Group {
this.scene = scene; this.scene = scene;
} }
getSkill(type, isAlly, castLocation) { getSkill(type, sourceAlly, targetAlly, castLocation) {
const genericHeal = ['Heal', 'Triage', 'TriageTick', 'DecayTick']; const genericHeal = ['Heal', 'Triage', 'TriageTick', 'DecayTick'];
const genericBlock = ['Block', 'Parry', 'Evasion', 'Shield']; const genericBlock = ['Block', 'Parry', 'Evasion', 'Shield'];
if (genericHeal.includes(type)) { if (genericHeal.includes(type)) {
this.genericHeal(isAlly, castLocation); this.genericHeal(targetAlly, castLocation);
} else if (genericBlock.includes(type)) { } else if (genericBlock.includes(type)) {
this.genericBlock(isAlly); this.genericBlock(sourceAlly);
} else { } else {
this[randomAttack()](isAlly); this[randomAttack()](sourceAlly);
} }
} }
genericHeal(isAlly, castLocation) { genericHeal(sourceAlly, castLocation) {
// const { sourceX, sourceY } = getCrypPosition(sourcePos, 0); // const { sourceX, sourceY } = getCrypPosition(sourcePos, 0);
const lifespan = DELAYS.ANIMATION_DURATION; const lifespan = DELAYS.ANIMATION_DURATION;
const colour = randomColour(); const colour = randomColour();
const particles = this.scene.add.particles(colour); const particles = this.scene.add.particles(colour);
const x = isAlly ? COMBAT.width() * 0.3 : COMBAT.width() * 0.7; const x = sourceAlly ? COMBAT.width() * 0.3 : COMBAT.width() * 0.7;
const emitter2 = particles.createEmitter({ const emitter2 = particles.createEmitter({
x: castLocation.x, x: castLocation.x,
@ -81,10 +81,10 @@ class CombatSkills extends Phaser.GameObjects.Group {
this.scene.time.delayedCall(lifespan, () => { emitter.stop(); }, [], this); this.scene.time.delayedCall(lifespan, () => { emitter.stop(); }, [], this);
} }
genericBlock(isAlly) { genericBlock(sourceAlly) {
const lifespan = DELAYS.ANIMATION_DURATION; const lifespan = DELAYS.ANIMATION_DURATION;
const colour = randomColour(); const colour = randomColour();
const x = isAlly ? COMBAT.width() * 0.3 : COMBAT.width() * 0.7; const x = sourceAlly ? COMBAT.width() * 0.3 : COMBAT.width() * 0.7;
const emitter1 = this.scene.add.particles(colour).createEmitter({ const emitter1 = this.scene.add.particles(colour).createEmitter({
x, x,
y: COMBAT.height() * 0.4, y: COMBAT.height() * 0.4,
@ -116,9 +116,9 @@ class CombatSkills extends Phaser.GameObjects.Group {
this.scene.time.delayedCall(lifespan, () => { emitter2.stop(); }, [], this); this.scene.time.delayedCall(lifespan, () => { emitter2.stop(); }, [], this);
} }
wall(isAlly) { wall(sourceAlly) {
const lifespan = DELAYS.ANIMATION_DURATION; const lifespan = DELAYS.ANIMATION_DURATION;
const { spawnLocation, speed, img } = animationParams(isAlly); const { spawnLocation, speed, img } = animationParams(sourceAlly);
const particles = this.scene.add.particles(img); const particles = this.scene.add.particles(img);
const emitter = particles.createEmitter({ const emitter = particles.createEmitter({
x: spawnLocation, x: spawnLocation,
@ -133,9 +133,9 @@ class CombatSkills extends Phaser.GameObjects.Group {
this.scene.time.delayedCall(1000, () => { emitter.stop(); }, [], this.scene); this.scene.time.delayedCall(1000, () => { emitter.stop(); }, [], this.scene);
} }
spit(isAlly) { spit(sourceAlly) {
const lifespan = DELAYS.ANIMATION_DURATION; const lifespan = DELAYS.ANIMATION_DURATION;
const { spawnLocation, speed, img, angleMin, angleMax } = animationParams(isAlly); const { spawnLocation, speed, img, angleMin, angleMax } = animationParams(sourceAlly);
const particles = this.scene.add.particles(img); const particles = this.scene.add.particles(img);
const emitter = particles.createEmitter({ const emitter = particles.createEmitter({
x: spawnLocation, x: spawnLocation,
@ -152,10 +152,10 @@ class CombatSkills extends Phaser.GameObjects.Group {
this.scene.time.delayedCall(lifespan, () => { emitter.stop(); }, [], this); this.scene.time.delayedCall(lifespan, () => { emitter.stop(); }, [], this);
} }
gravBomb(isAlly) { gravBomb(sourceAlly) {
const lifespan = DELAYS.ANIMATION_DURATION; const lifespan = DELAYS.ANIMATION_DURATION;
const { spawnLocation, img } = animationParams(!isAlly); const { spawnLocation, img } = animationParams(!sourceAlly);
const particles = this.scene.add.particles(img); const particles = this.scene.add.particles(img);
const well = particles.createGravityWell({ const well = particles.createGravityWell({
x: spawnLocation, x: spawnLocation,
@ -175,15 +175,15 @@ class CombatSkills extends Phaser.GameObjects.Group {
this.scene.time.delayedCall(lifespan, () => { this.emitter.stop(); well.active = false; }, [], this.scene); this.scene.time.delayedCall(lifespan, () => { this.emitter.stop(); well.active = false; }, [], this.scene);
} }
gravBlast(isAlly) { gravBlast(sourceAlly) {
const lifespan = DELAYS.ANIMATION_DURATION; const lifespan = DELAYS.ANIMATION_DURATION;
const WELL_END = lifespan / 2; const WELL_END = lifespan / 2;
const img = randomColour(); const img = randomColour();
const spawnLocation = isAlly ? COMBAT.width() * 0.35 : COMBAT.width() * 0.65; const spawnLocation = sourceAlly ? COMBAT.width() * 0.35 : COMBAT.width() * 0.65;
const isEnemyLocation = isAlly ? COMBAT.width() * 0.7 : COMBAT.width() * 0.3; const isEnemyLocation = sourceAlly ? COMBAT.width() * 0.7 : COMBAT.width() * 0.3;
const particles = this.scene.add.particles(img); const particles = this.scene.add.particles(img);
const bounds = isAlly const bounds = sourceAlly
? { x: COMBAT.width() * 0.3, y: COMBAT.height() * 0.2, w: COMBAT.width() * 0.5, h: COMBAT.height() * 0.2 } ? { x: COMBAT.width() * 0.3, y: COMBAT.height() * 0.2, w: COMBAT.width() * 0.5, h: COMBAT.height() * 0.2 }
: { x: 0.2 * COMBAT.width(), y: COMBAT.height() * 0.2, w: COMBAT.width() * 0.5, h: COMBAT.height() * 0.2 }; : { x: 0.2 * COMBAT.width(), y: COMBAT.height() * 0.2, w: COMBAT.width() * 0.5, h: COMBAT.height() * 0.2 };
const well = particles.createGravityWell({ const well = particles.createGravityWell({
@ -206,12 +206,12 @@ class CombatSkills extends Phaser.GameObjects.Group {
this.scene.time.delayedCall(lifespan, () => { well.active = false; }, [], this.scene); this.scene.time.delayedCall(lifespan, () => { well.active = false; }, [], this.scene);
} }
chargeBall(isAlly) { chargeBall(sourceAlly) {
const lifespan = DELAYS.ANIMATION_DURATION; const lifespan = DELAYS.ANIMATION_DURATION;
const CHARGE_LIFESPAN = lifespan / 3; const CHARGE_LIFESPAN = lifespan / 3;
const { img, spawnLocation } = animationParams(isAlly); const { img, spawnLocation } = animationParams(sourceAlly);
const targetLocation = isAlly ? 0.7 * COMBAT.width() : 0.25 * COMBAT.width(); const targetLocation = sourceAlly ? 0.7 * COMBAT.width() : 0.25 * COMBAT.width();
const particles = this.scene.add.particles(img); const particles = this.scene.add.particles(img);
const emitter = particles.createEmitter({ const emitter = particles.createEmitter({
x: 0, x: 0,

View File

@ -20,7 +20,7 @@ function findResolutionCryps(scene, group, resolution, game) {
return { sourceSpawn, targetSpawn }; return { sourceSpawn, targetSpawn };
} }
function calculateTweenParams(sourceSpawn, targetSpawn, account) { function calculateTweenParams(sourceSpawn, targetSpawn, account, skill) {
const tweenParams = (targets, centreSpot) => { const tweenParams = (targets, centreSpot) => {
const enemy = targets.cryp.account !== account.id; const enemy = targets.cryp.account !== account.id;
let x = centreSpot ? COMBAT.width() * 0.3 : targets.x; let x = centreSpot ? COMBAT.width() * 0.3 : targets.x;
@ -32,10 +32,16 @@ function calculateTweenParams(sourceSpawn, targetSpawn, account) {
targets, x, y, ease, duration, targets, x, y, ease, duration,
}; };
}; };
const moveSourceBattle = sourceSpawn.cryp.account !== targetSpawn.cryp.account let moveSourceBattle = false;
? tweenParams(sourceSpawn, true) : null; let moveSourceOrig = false;
const moveSourceOrig = sourceSpawn.cryp.account !== targetSpawn.cryp.account const targetOnlySkill = ['DecayTick'];
? tweenParams(sourceSpawn, false) : null; if (!(targetOnlySkill.includes(skill))) {
if (sourceSpawn.cryp.account !== targetSpawn.cryp.account) {
moveSourceBattle = tweenParams(sourceSpawn, true);
moveSourceOrig = tweenParams(sourceSpawn, false);
}
}
const moveTargetBattle = tweenParams(targetSpawn, true); const moveTargetBattle = tweenParams(targetSpawn, true);
const moveTargetOrig = tweenParams(targetSpawn, false); const moveTargetOrig = tweenParams(targetSpawn, false);
@ -59,7 +65,7 @@ function animatePhase(scene, game, resolution, cb) {
const { sourceSpawn, targetSpawn } = findResolutionCryps(scene, group, resolution, game); const { sourceSpawn, targetSpawn } = findResolutionCryps(scene, group, resolution, game);
const { const {
moveSourceBattle, moveSourceOrig, moveTargetBattle, moveTargetOrig, moveSourceBattle, moveSourceOrig, moveTargetBattle, moveTargetOrig,
} = calculateTweenParams(sourceSpawn, targetSpawn, account); } = calculateTweenParams(sourceSpawn, targetSpawn, account, resolution.event[1].skill);
const castParams = () => { const castParams = () => {
const x = (sourceSpawn === targetSpawn) ? moveTargetBattle.x : sourceSpawn.x; const x = (sourceSpawn === targetSpawn) ? moveTargetBattle.x : sourceSpawn.x;
@ -73,9 +79,10 @@ function animatePhase(scene, game, resolution, cb) {
scene.tweens.add(moveTargetBattle); scene.tweens.add(moveTargetBattle);
return scene.time.delayedCall(MOVE_CREEP, () => { return scene.time.delayedCall(MOVE_CREEP, () => {
const isAlly = sourceSpawn.cryp.account === account.id; const sourceAlly = sourceSpawn.cryp.account === account.id;
const targetAlly = targetSpawn.cryp.account === account.id;
// animate animation // animate animation
animations.getSkill(resolution.event[1].skill, isAlly, castLocation); animations.getSkill(resolution.event[1].skill, sourceAlly, targetAlly, castLocation);
// Target cryp takes damage // Target cryp takes damage
scene.time.delayedCall(ANIMATION_DURATION, () => { scene.time.delayedCall(ANIMATION_DURATION, () => {
console.log(resolution); console.log(resolution);