Added cryp avatar hash and fixed some animations

This commit is contained in:
Mashy 2019-01-04 18:24:01 +10:00
parent 9fa2a94ade
commit 2ae764a3a3
6 changed files with 53 additions and 26 deletions

40
client/assets/aztec.atlas.json Executable file → Normal file
View File

@ -9,7 +9,7 @@
"scale": 1,
"frames":[
{
"filename":"sprite1",
"filename":"sprite0",
"frame":{
"x":655,
"y":100,
@ -30,7 +30,7 @@
}
},
{
"filename":"sprite2",
"filename":"sprite1",
"frame":{
"x":180,
"y":105,
@ -51,7 +51,7 @@
}
},
{
"filename":"sprite3",
"filename":"sprite2",
"frame":{
"x":20,
"y":106,
@ -72,7 +72,7 @@
}
},
{
"filename":"sprite4",
"filename":"sprite3",
"frame":{
"x":475,
"y":106,
@ -93,7 +93,7 @@
}
},
{
"filename":"sprite5",
"filename":"sprite4",
"frame":{
"x":330,
"y":112,
@ -114,7 +114,7 @@
}
},
{
"filename":"sprite6",
"filename":"sprite5",
"frame":{
"x":198,
"y":274,
@ -135,7 +135,7 @@
}
},
{
"filename":"sprite7",
"filename":"sprite6",
"frame":{
"x":342,
"y":279,
@ -156,7 +156,7 @@
}
},
{
"filename":"sprite8",
"filename":"sprite7",
"frame":{
"x":480,
"y":283,
@ -177,7 +177,7 @@
}
},
{
"filename":"sprite9",
"filename":"sprite8",
"frame":{
"x":24,
"y":284,
@ -198,7 +198,7 @@
}
},
{
"filename":"sprite10",
"filename":"sprite9",
"frame":{
"x":645,
"y":287,
@ -219,7 +219,7 @@
}
},
{
"filename":"sprite11",
"filename":"sprite10",
"frame":{
"x":514,
"y":434,
@ -240,7 +240,7 @@
}
},
{
"filename":"sprite12",
"filename":"sprite11",
"frame":{
"x":222,
"y":439,
@ -261,7 +261,7 @@
}
},
{
"filename":"sprite13",
"filename":"sprite12",
"frame":{
"x":667,
"y":439,
@ -282,7 +282,7 @@
}
},
{
"filename":"sprite14",
"filename":"sprite13",
"frame":{
"x":20,
"y":451,
@ -303,7 +303,7 @@
}
},
{
"filename":"sprite15",
"filename":"sprite14",
"frame":{
"x":335,
"y":453,
@ -324,7 +324,7 @@
}
},
{
"filename":"sprite16",
"filename":"sprite15",
"frame":{
"x":493,
"y":619,
@ -345,7 +345,7 @@
}
},
{
"filename":"sprite17",
"filename":"sprite16",
"frame":{
"x":180,
"y":626,
@ -366,7 +366,7 @@
}
},
{
"filename":"sprite18",
"filename":"sprite17",
"frame":{
"x":640,
"y":632,
@ -387,7 +387,7 @@
}
},
{
"filename":"sprite19",
"filename":"sprite18",
"frame":{
"x":329,
"y":635,
@ -408,7 +408,7 @@
}
},
{
"filename":"sprite20",
"filename":"sprite19",
"frame":{
"x":25,
"y":641,

View File

@ -0,0 +1,13 @@
const genAvatar = (name) => {
let hash = 0;
if (name.length === 0) return hash;
// Probs don't need to hash using the whole string
for (let i = 0; i < name.length; i += 1) {
const chr = name.charCodeAt(i);
hash = ((hash << 5) - hash) + chr;
hash = hash & 19; // We have avatars named 0-19
}
return `sprite${hash}`;
};
module.exports = genAvatar;

View File

@ -35,11 +35,23 @@ class CombatSkills extends Phaser.GameObjects.Group {
}
Heal(isAlly, castLocation) {
this.genericHeal(isAlly, castLocation);
}
Triage(isAlly, castLocation) {
this.genericHeal(isAlly, castLocation);
}
TriageTick(isAlly, castLocation) {
this.genericHeal(isAlly, castLocation);
}
genericHeal(isAlly, 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.7 : COMBAT.width() * 0.3;
const x = isAlly ? COMBAT.width() * 0.3 : COMBAT.width() * 0.7;
const emitter2 = particles.createEmitter({
x: castLocation.x,
@ -79,7 +91,7 @@ class CombatSkills extends Phaser.GameObjects.Group {
Block(isAlly) {
const lifespan = DELAYS.ANIMATION_DURATION;
const colour = randomColour();
const x = isAlly ? COMBAT.width() * 0.7 : COMBAT.width() * 0.3;
const x = isAlly ? COMBAT.width() * 0.3 : COMBAT.width() * 0.7;
const emitter1 = this.scene.add.particles(colour).createEmitter({
x,
y: COMBAT.height() * 0.4,

View File

@ -1,4 +1,5 @@
const Phaser = require('phaser');
const genAvatar = require('./avatar');
const { DELAYS, TEXT, POSITIONS: { COMBAT }, COLOURS } = require('./constants');
@ -128,7 +129,7 @@ class CrypImage extends Phaser.GameObjects.Image {
// Cryp display
// const avatar = team ? 'magmar' : 'alk';
super(scene, crypAvatarX, crypAvatarY, 'aztec', `sprite${Math.floor(Math.random() * 19) + 1}`);
super(scene, crypAvatarX, crypAvatarY, 'aztec', genAvatar(cryp.name));
this.setScale(0.5);
if (!team) this.flipX = true;

View File

@ -69,7 +69,7 @@ function animatePhase(scene, game, resolution, cb) {
if (results.length === 0) return cb();
// Move cryps into posistion
// Move cryps into position
if (moveSourceBattle) scene.tweens.add(moveSourceBattle);
scene.tweens.add(moveTargetBattle);
@ -77,7 +77,7 @@ function animatePhase(scene, game, resolution, cb) {
const isAlly = sourceSpawn.cryp.account === account.id;
// animate animation
const workingSkills = ['Heal', 'Block'];
const workingSkills = ['Heal', 'Block', 'Triage', 'TriageTick'];
if (workingSkills.includes(resolution.skill)) animations.getSkill(resolution.skill, isAlly, castLocation);
else animations.getSkill('attack', isAlly);

View File

@ -1,6 +1,7 @@
const Phaser = require('phaser');
const { TEXT, COLOURS, POSITIONS: { CRYP_LIST } } = require('./constants');
const genAvatar = require('./avatar');
const ROW_HEIGHT = CRYP_LIST.height() * 0.2;
const ROW_WIDTH = CRYP_LIST.width();
@ -89,7 +90,7 @@ class MenuCrypList extends Phaser.Scene {
crypInteract.getCenter().x,
crypInteract.getCenter().y,
'aztec',
`sprite${Math.floor(Math.random() * 19) + 1}`
genAvatar(cryp.name)
));
this.crypRows.add(crypInteract);