Added cryp avatar hash and fixed some animations
This commit is contained in:
parent
9fa2a94ade
commit
2ae764a3a3
40
client/assets/aztec.atlas.json
Executable file → Normal file
40
client/assets/aztec.atlas.json
Executable file → Normal file
@ -9,7 +9,7 @@
|
|||||||
"scale": 1,
|
"scale": 1,
|
||||||
"frames":[
|
"frames":[
|
||||||
{
|
{
|
||||||
"filename":"sprite1",
|
"filename":"sprite0",
|
||||||
"frame":{
|
"frame":{
|
||||||
"x":655,
|
"x":655,
|
||||||
"y":100,
|
"y":100,
|
||||||
@ -30,7 +30,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename":"sprite2",
|
"filename":"sprite1",
|
||||||
"frame":{
|
"frame":{
|
||||||
"x":180,
|
"x":180,
|
||||||
"y":105,
|
"y":105,
|
||||||
@ -51,7 +51,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename":"sprite3",
|
"filename":"sprite2",
|
||||||
"frame":{
|
"frame":{
|
||||||
"x":20,
|
"x":20,
|
||||||
"y":106,
|
"y":106,
|
||||||
@ -72,7 +72,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename":"sprite4",
|
"filename":"sprite3",
|
||||||
"frame":{
|
"frame":{
|
||||||
"x":475,
|
"x":475,
|
||||||
"y":106,
|
"y":106,
|
||||||
@ -93,7 +93,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename":"sprite5",
|
"filename":"sprite4",
|
||||||
"frame":{
|
"frame":{
|
||||||
"x":330,
|
"x":330,
|
||||||
"y":112,
|
"y":112,
|
||||||
@ -114,7 +114,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename":"sprite6",
|
"filename":"sprite5",
|
||||||
"frame":{
|
"frame":{
|
||||||
"x":198,
|
"x":198,
|
||||||
"y":274,
|
"y":274,
|
||||||
@ -135,7 +135,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename":"sprite7",
|
"filename":"sprite6",
|
||||||
"frame":{
|
"frame":{
|
||||||
"x":342,
|
"x":342,
|
||||||
"y":279,
|
"y":279,
|
||||||
@ -156,7 +156,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename":"sprite8",
|
"filename":"sprite7",
|
||||||
"frame":{
|
"frame":{
|
||||||
"x":480,
|
"x":480,
|
||||||
"y":283,
|
"y":283,
|
||||||
@ -177,7 +177,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename":"sprite9",
|
"filename":"sprite8",
|
||||||
"frame":{
|
"frame":{
|
||||||
"x":24,
|
"x":24,
|
||||||
"y":284,
|
"y":284,
|
||||||
@ -198,7 +198,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename":"sprite10",
|
"filename":"sprite9",
|
||||||
"frame":{
|
"frame":{
|
||||||
"x":645,
|
"x":645,
|
||||||
"y":287,
|
"y":287,
|
||||||
@ -219,7 +219,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename":"sprite11",
|
"filename":"sprite10",
|
||||||
"frame":{
|
"frame":{
|
||||||
"x":514,
|
"x":514,
|
||||||
"y":434,
|
"y":434,
|
||||||
@ -240,7 +240,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename":"sprite12",
|
"filename":"sprite11",
|
||||||
"frame":{
|
"frame":{
|
||||||
"x":222,
|
"x":222,
|
||||||
"y":439,
|
"y":439,
|
||||||
@ -261,7 +261,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename":"sprite13",
|
"filename":"sprite12",
|
||||||
"frame":{
|
"frame":{
|
||||||
"x":667,
|
"x":667,
|
||||||
"y":439,
|
"y":439,
|
||||||
@ -282,7 +282,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename":"sprite14",
|
"filename":"sprite13",
|
||||||
"frame":{
|
"frame":{
|
||||||
"x":20,
|
"x":20,
|
||||||
"y":451,
|
"y":451,
|
||||||
@ -303,7 +303,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename":"sprite15",
|
"filename":"sprite14",
|
||||||
"frame":{
|
"frame":{
|
||||||
"x":335,
|
"x":335,
|
||||||
"y":453,
|
"y":453,
|
||||||
@ -324,7 +324,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename":"sprite16",
|
"filename":"sprite15",
|
||||||
"frame":{
|
"frame":{
|
||||||
"x":493,
|
"x":493,
|
||||||
"y":619,
|
"y":619,
|
||||||
@ -345,7 +345,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename":"sprite17",
|
"filename":"sprite16",
|
||||||
"frame":{
|
"frame":{
|
||||||
"x":180,
|
"x":180,
|
||||||
"y":626,
|
"y":626,
|
||||||
@ -366,7 +366,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename":"sprite18",
|
"filename":"sprite17",
|
||||||
"frame":{
|
"frame":{
|
||||||
"x":640,
|
"x":640,
|
||||||
"y":632,
|
"y":632,
|
||||||
@ -387,7 +387,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename":"sprite19",
|
"filename":"sprite18",
|
||||||
"frame":{
|
"frame":{
|
||||||
"x":329,
|
"x":329,
|
||||||
"y":635,
|
"y":635,
|
||||||
@ -408,7 +408,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename":"sprite20",
|
"filename":"sprite19",
|
||||||
"frame":{
|
"frame":{
|
||||||
"x":25,
|
"x":25,
|
||||||
"y":641,
|
"y":641,
|
||||||
|
|||||||
13
client/src/scenes/avatar.js
Normal file
13
client/src/scenes/avatar.js
Normal 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;
|
||||||
@ -35,11 +35,23 @@ class CombatSkills extends Phaser.GameObjects.Group {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Heal(isAlly, castLocation) {
|
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 { 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.7 : COMBAT.width() * 0.3;
|
const x = isAlly ? COMBAT.width() * 0.3 : COMBAT.width() * 0.7;
|
||||||
|
|
||||||
const emitter2 = particles.createEmitter({
|
const emitter2 = particles.createEmitter({
|
||||||
x: castLocation.x,
|
x: castLocation.x,
|
||||||
@ -79,7 +91,7 @@ class CombatSkills extends Phaser.GameObjects.Group {
|
|||||||
Block(isAlly) {
|
Block(isAlly) {
|
||||||
const lifespan = DELAYS.ANIMATION_DURATION;
|
const lifespan = DELAYS.ANIMATION_DURATION;
|
||||||
const colour = randomColour();
|
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({
|
const emitter1 = this.scene.add.particles(colour).createEmitter({
|
||||||
x,
|
x,
|
||||||
y: COMBAT.height() * 0.4,
|
y: COMBAT.height() * 0.4,
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
const Phaser = require('phaser');
|
const Phaser = require('phaser');
|
||||||
|
const genAvatar = require('./avatar');
|
||||||
|
|
||||||
const { DELAYS, TEXT, POSITIONS: { COMBAT }, COLOURS } = require('./constants');
|
const { DELAYS, TEXT, POSITIONS: { COMBAT }, COLOURS } = require('./constants');
|
||||||
|
|
||||||
@ -128,7 +129,7 @@ class CrypImage extends Phaser.GameObjects.Image {
|
|||||||
|
|
||||||
// Cryp display
|
// Cryp display
|
||||||
// const avatar = team ? 'magmar' : 'alk';
|
// 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);
|
this.setScale(0.5);
|
||||||
|
|
||||||
if (!team) this.flipX = true;
|
if (!team) this.flipX = true;
|
||||||
|
|||||||
@ -69,7 +69,7 @@ function animatePhase(scene, game, resolution, cb) {
|
|||||||
|
|
||||||
if (results.length === 0) return cb();
|
if (results.length === 0) return cb();
|
||||||
|
|
||||||
// Move cryps into posistion
|
// Move cryps into position
|
||||||
if (moveSourceBattle) scene.tweens.add(moveSourceBattle);
|
if (moveSourceBattle) scene.tweens.add(moveSourceBattle);
|
||||||
scene.tweens.add(moveTargetBattle);
|
scene.tweens.add(moveTargetBattle);
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ function animatePhase(scene, game, resolution, cb) {
|
|||||||
const isAlly = sourceSpawn.cryp.account === account.id;
|
const isAlly = sourceSpawn.cryp.account === account.id;
|
||||||
|
|
||||||
// animate animation
|
// animate animation
|
||||||
const workingSkills = ['Heal', 'Block'];
|
const workingSkills = ['Heal', 'Block', 'Triage', 'TriageTick'];
|
||||||
if (workingSkills.includes(resolution.skill)) animations.getSkill(resolution.skill, isAlly, castLocation);
|
if (workingSkills.includes(resolution.skill)) animations.getSkill(resolution.skill, isAlly, castLocation);
|
||||||
else animations.getSkill('attack', isAlly);
|
else animations.getSkill('attack', isAlly);
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
const Phaser = require('phaser');
|
const Phaser = require('phaser');
|
||||||
|
|
||||||
const { TEXT, COLOURS, POSITIONS: { CRYP_LIST } } = require('./constants');
|
const { TEXT, COLOURS, POSITIONS: { CRYP_LIST } } = require('./constants');
|
||||||
|
const genAvatar = require('./avatar');
|
||||||
|
|
||||||
const ROW_HEIGHT = CRYP_LIST.height() * 0.2;
|
const ROW_HEIGHT = CRYP_LIST.height() * 0.2;
|
||||||
const ROW_WIDTH = CRYP_LIST.width();
|
const ROW_WIDTH = CRYP_LIST.width();
|
||||||
@ -89,7 +90,7 @@ class MenuCrypList extends Phaser.Scene {
|
|||||||
crypInteract.getCenter().x,
|
crypInteract.getCenter().x,
|
||||||
crypInteract.getCenter().y,
|
crypInteract.getCenter().y,
|
||||||
'aztec',
|
'aztec',
|
||||||
`sprite${Math.floor(Math.random() * 19) + 1}`
|
genAvatar(cryp.name)
|
||||||
));
|
));
|
||||||
this.crypRows.add(crypInteract);
|
this.crypRows.add(crypInteract);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user