Merge branch 'master' of ssh://cryps.gg:40022/~/cryps
This commit is contained in:
commit
26ab281fdb
@ -6,12 +6,12 @@ const randomColour = () => {
|
||||
return colours[Math.floor(Math.random() * 5)];
|
||||
};
|
||||
|
||||
const animationParams = (isAlly) => {
|
||||
const spawnLocation = isAlly ? COMBAT.width() * 0.35 : COMBAT.width() * 0.65;
|
||||
const speed = isAlly ? 250 : -250;
|
||||
const animationParams = (sourceAlly) => {
|
||||
const spawnLocation = sourceAlly ? COMBAT.width() * 0.35 : COMBAT.width() * 0.65;
|
||||
const speed = sourceAlly ? 250 : -250;
|
||||
const img = randomColour();
|
||||
const angleMin = isAlly ? 320 : 180;
|
||||
const angleMax = isAlly ? 360 : 220;
|
||||
const angleMin = sourceAlly ? 320 : 180;
|
||||
const angleMax = sourceAlly ? 360 : 220;
|
||||
return { spawnLocation, speed, img, angleMin, angleMax };
|
||||
};
|
||||
|
||||
@ -26,25 +26,25 @@ class CombatSkills extends Phaser.GameObjects.Group {
|
||||
this.scene = scene;
|
||||
}
|
||||
|
||||
getSkill(type, isAlly, castLocation) {
|
||||
getSkill(type, sourceAlly, targetAlly, castLocation) {
|
||||
const genericHeal = ['Heal', 'Triage', 'TriageTick', 'DecayTick'];
|
||||
const genericBlock = ['Block', 'Parry', 'Evasion', 'Shield'];
|
||||
|
||||
if (genericHeal.includes(type)) {
|
||||
this.genericHeal(isAlly, castLocation);
|
||||
this.genericHeal(targetAlly, castLocation);
|
||||
} else if (genericBlock.includes(type)) {
|
||||
this.genericBlock(isAlly);
|
||||
this.genericBlock(sourceAlly);
|
||||
} else {
|
||||
this[randomAttack()](isAlly);
|
||||
this[randomAttack()](sourceAlly);
|
||||
}
|
||||
}
|
||||
|
||||
genericHeal(isAlly, castLocation) {
|
||||
genericHeal(sourceAlly, castLocation) {
|
||||
// const { sourceX, sourceY } = getCrypPosition(sourcePos, 0);
|
||||
const lifespan = DELAYS.ANIMATION_DURATION;
|
||||
const colour = randomColour();
|
||||
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({
|
||||
x: castLocation.x,
|
||||
@ -81,10 +81,10 @@ class CombatSkills extends Phaser.GameObjects.Group {
|
||||
this.scene.time.delayedCall(lifespan, () => { emitter.stop(); }, [], this);
|
||||
}
|
||||
|
||||
genericBlock(isAlly) {
|
||||
genericBlock(sourceAlly) {
|
||||
const lifespan = DELAYS.ANIMATION_DURATION;
|
||||
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({
|
||||
x,
|
||||
y: COMBAT.height() * 0.4,
|
||||
@ -116,9 +116,9 @@ class CombatSkills extends Phaser.GameObjects.Group {
|
||||
this.scene.time.delayedCall(lifespan, () => { emitter2.stop(); }, [], this);
|
||||
}
|
||||
|
||||
wall(isAlly) {
|
||||
wall(sourceAlly) {
|
||||
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 emitter = particles.createEmitter({
|
||||
x: spawnLocation,
|
||||
@ -133,9 +133,9 @@ class CombatSkills extends Phaser.GameObjects.Group {
|
||||
this.scene.time.delayedCall(1000, () => { emitter.stop(); }, [], this.scene);
|
||||
}
|
||||
|
||||
spit(isAlly) {
|
||||
spit(sourceAlly) {
|
||||
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 emitter = particles.createEmitter({
|
||||
x: spawnLocation,
|
||||
@ -152,10 +152,10 @@ class CombatSkills extends Phaser.GameObjects.Group {
|
||||
this.scene.time.delayedCall(lifespan, () => { emitter.stop(); }, [], this);
|
||||
}
|
||||
|
||||
gravBomb(isAlly) {
|
||||
gravBomb(sourceAlly) {
|
||||
const lifespan = DELAYS.ANIMATION_DURATION;
|
||||
|
||||
const { spawnLocation, img } = animationParams(!isAlly);
|
||||
const { spawnLocation, img } = animationParams(!sourceAlly);
|
||||
const particles = this.scene.add.particles(img);
|
||||
const well = particles.createGravityWell({
|
||||
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);
|
||||
}
|
||||
|
||||
gravBlast(isAlly) {
|
||||
gravBlast(sourceAlly) {
|
||||
const lifespan = DELAYS.ANIMATION_DURATION;
|
||||
const WELL_END = lifespan / 2;
|
||||
|
||||
const img = randomColour();
|
||||
const spawnLocation = isAlly ? COMBAT.width() * 0.35 : COMBAT.width() * 0.65;
|
||||
const isEnemyLocation = isAlly ? COMBAT.width() * 0.7 : COMBAT.width() * 0.3;
|
||||
const spawnLocation = sourceAlly ? COMBAT.width() * 0.35 : COMBAT.width() * 0.65;
|
||||
const isEnemyLocation = sourceAlly ? COMBAT.width() * 0.7 : COMBAT.width() * 0.3;
|
||||
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: 0.2 * COMBAT.width(), y: COMBAT.height() * 0.2, w: COMBAT.width() * 0.5, h: COMBAT.height() * 0.2 };
|
||||
const well = particles.createGravityWell({
|
||||
@ -206,12 +206,12 @@ class CombatSkills extends Phaser.GameObjects.Group {
|
||||
this.scene.time.delayedCall(lifespan, () => { well.active = false; }, [], this.scene);
|
||||
}
|
||||
|
||||
chargeBall(isAlly) {
|
||||
chargeBall(sourceAlly) {
|
||||
const lifespan = DELAYS.ANIMATION_DURATION;
|
||||
const CHARGE_LIFESPAN = lifespan / 3;
|
||||
|
||||
const { img, spawnLocation } = animationParams(isAlly);
|
||||
const targetLocation = isAlly ? 0.7 * COMBAT.width() : 0.25 * COMBAT.width();
|
||||
const { img, spawnLocation } = animationParams(sourceAlly);
|
||||
const targetLocation = sourceAlly ? 0.7 * COMBAT.width() : 0.25 * COMBAT.width();
|
||||
const particles = this.scene.add.particles(img);
|
||||
const emitter = particles.createEmitter({
|
||||
x: 0,
|
||||
|
||||
@ -20,7 +20,7 @@ function findResolutionCryps(scene, group, resolution, game) {
|
||||
return { sourceSpawn, targetSpawn };
|
||||
}
|
||||
|
||||
function calculateTweenParams(sourceSpawn, targetSpawn, account) {
|
||||
function calculateTweenParams(sourceSpawn, targetSpawn, account, skill) {
|
||||
const tweenParams = (targets, centreSpot) => {
|
||||
const enemy = targets.cryp.account !== account.id;
|
||||
let x = centreSpot ? COMBAT.width() * 0.3 : targets.x;
|
||||
@ -32,10 +32,16 @@ function calculateTweenParams(sourceSpawn, targetSpawn, account) {
|
||||
targets, x, y, ease, duration,
|
||||
};
|
||||
};
|
||||
const moveSourceBattle = sourceSpawn.cryp.account !== targetSpawn.cryp.account
|
||||
? tweenParams(sourceSpawn, true) : null;
|
||||
const moveSourceOrig = sourceSpawn.cryp.account !== targetSpawn.cryp.account
|
||||
? tweenParams(sourceSpawn, false) : null;
|
||||
let moveSourceBattle = false;
|
||||
let moveSourceOrig = false;
|
||||
const targetOnlySkill = ['DecayTick'];
|
||||
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 moveTargetOrig = tweenParams(targetSpawn, false);
|
||||
|
||||
@ -59,7 +65,7 @@ function animatePhase(scene, game, resolution, cb) {
|
||||
const { sourceSpawn, targetSpawn } = findResolutionCryps(scene, group, resolution, game);
|
||||
const {
|
||||
moveSourceBattle, moveSourceOrig, moveTargetBattle, moveTargetOrig,
|
||||
} = calculateTweenParams(sourceSpawn, targetSpawn, account);
|
||||
} = calculateTweenParams(sourceSpawn, targetSpawn, account, resolution.event[1].skill);
|
||||
|
||||
const castParams = () => {
|
||||
const x = (sourceSpawn === targetSpawn) ? moveTargetBattle.x : sourceSpawn.x;
|
||||
@ -73,9 +79,10 @@ function animatePhase(scene, game, resolution, cb) {
|
||||
scene.tweens.add(moveTargetBattle);
|
||||
|
||||
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
|
||||
animations.getSkill(resolution.event[1].skill, isAlly, castLocation);
|
||||
animations.getSkill(resolution.event[1].skill, sourceAlly, targetAlly, castLocation);
|
||||
// Target cryp takes damage
|
||||
scene.time.delayedCall(ANIMATION_DURATION, () => {
|
||||
console.log(resolution);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user