anims nearly back
This commit is contained in:
parent
168bf81f3e
commit
64a9d8f51f
@ -2,17 +2,20 @@ const actions = require('./actions');
|
||||
const { TIMES } = require('./constants');
|
||||
|
||||
function setAnimations(r, store, account) {
|
||||
const { cast, focus, event, delay } = r;
|
||||
const { source, target, player, skill } = cast;
|
||||
|
||||
store.dispatch(actions.setAnimFocus(r.focus));
|
||||
|
||||
if (r.variant[0] === 'Cast') {
|
||||
if (r.event[0] === 'Cast') {
|
||||
store.dispatch(actions.setAnimText(null));
|
||||
|
||||
const { player } = r.cast;
|
||||
const { x, y, target } = r.variant[1];
|
||||
debugger
|
||||
const { construct, direction: [x, y] } = r.event[1];
|
||||
const animY = y && player === account.id ? -1 : y;
|
||||
const animSource = {
|
||||
animation: 'sourceCast',
|
||||
constructId: target,
|
||||
constructId: construct,
|
||||
direction: { x, y: animY },
|
||||
};
|
||||
store.dispatch(actions.setAnimSource(animSource));
|
||||
@ -20,15 +23,14 @@ function setAnimations(r, store, account) {
|
||||
return setTimeout(() => store.dispatch(actions.setAnimSource(null)), TIMES.SOURCE_DURATION_MS);
|
||||
}
|
||||
|
||||
if (r.variant[0].includes('Hit')) {
|
||||
if (r.event[0].includes('Hit')) {
|
||||
store.dispatch(actions.setAnimText(null));
|
||||
|
||||
const { player, skill } = r.cast;
|
||||
const { x, y, target } = r.variant[1];
|
||||
const { construct, direction: [x, y] } = r.event[1];
|
||||
const animY = y && player === account.id ? -1 : y;
|
||||
const isPlayer = player === account.id;
|
||||
const animTarget = {
|
||||
constructId: target,
|
||||
constructId: construct,
|
||||
player: isPlayer,
|
||||
skill,
|
||||
direction: { x, y: animY },
|
||||
|
||||
@ -17,7 +17,7 @@ class AnimText extends preact.Component {
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
const { animText, construct } = this.props;
|
||||
if (animText && animText !== prevProps.animText && animText.variant[1].target === construct.id) {
|
||||
if (animText && animText !== prevProps.animText && animText.event[1].construct === construct.id) {
|
||||
anime({
|
||||
targets: '.combat-text',
|
||||
top: '40%',
|
||||
@ -29,7 +29,7 @@ class AnimText extends preact.Component {
|
||||
|
||||
render() {
|
||||
const { construct, animText, itemInfo } = this.props;
|
||||
if (animText && animText.variant[1].target === construct.id) {
|
||||
if (animText && animText.event[1].construct === construct.id) {
|
||||
const itemSourceDescription = () => {
|
||||
const itemSource = itemInfo.combos.filter(c => c.item === removeTier(animText.cast.skill));
|
||||
const itemSourceInfo = itemSource.length
|
||||
@ -40,7 +40,7 @@ class AnimText extends preact.Component {
|
||||
};
|
||||
|
||||
const generateAnimText = () => {
|
||||
const [type, event] = animText.variant;
|
||||
const [type, event] = animText.event;
|
||||
if (type === 'Ko') return <h1><span>KO!</span></h1>;
|
||||
if (type === 'Disable') {
|
||||
const { disable } = event;
|
||||
|
||||
@ -22,7 +22,7 @@ const addState = connect(
|
||||
class GameConstructEffects extends preact.Component {
|
||||
shouldComponentUpdate(newProps) {
|
||||
if (newProps.animText && newProps.animText !== this.props.animText) {
|
||||
const [type, info] = newProps.animText.variant;
|
||||
const [type, info] = newProps.animText.event;
|
||||
if (info.target === this.props.construct.id
|
||||
&& (type === 'Effect' || type === 'Removal')) return true;
|
||||
}
|
||||
@ -56,7 +56,7 @@ class GameConstructEffects extends preact.Component {
|
||||
</div>);
|
||||
}
|
||||
|
||||
const effects = animText ? animText.variant[1].display.effects : construct.effects;
|
||||
const effects = animText ? animText.event[1].display.effects : construct.effects;
|
||||
|
||||
const renderEffects = effects.length
|
||||
? effects.map(c =>
|
||||
|
||||
@ -8,7 +8,7 @@ const addState = connect(({ animText }) => ({ animText }));
|
||||
class GameConstructLife extends preact.Component {
|
||||
shouldComponentUpdate(newProps) {
|
||||
if (newProps.animText && newProps.animText !== this.props.animText) {
|
||||
const [type, info] = newProps.animText.variant;
|
||||
const [type, info] = newProps.animText.event;
|
||||
if (info.target === this.props.construct.id
|
||||
&& (type === 'Damage' || type === 'Healing' || type === 'Recharge')) return true;
|
||||
}
|
||||
@ -38,7 +38,7 @@ class GameConstructLife extends preact.Component {
|
||||
};
|
||||
|
||||
if (animText) {
|
||||
const { red, blue, green } = animText.variant[1].display;
|
||||
const { red, blue, green } = animText.event[1].display;
|
||||
return lifeBars(red, green, blue);
|
||||
}
|
||||
|
||||
|
||||
@ -82,11 +82,12 @@ function registerEvents(store) {
|
||||
if (animating) return false;
|
||||
|
||||
if (game && currentGame) {
|
||||
if (game.events.length !== currentGame.events.length) {
|
||||
if (game.resolutions.length !== currentGame.resolutions.length) {
|
||||
store.dispatch(actions.setAnimating(true));
|
||||
store.dispatch(actions.setGameSkillInfo(null));
|
||||
// stop fetching the game state til animations are done
|
||||
const newRes = game.events[game.events.length - 1];
|
||||
const newRes = game.resolutions[game.resolutions.length - 2];
|
||||
console.log(newRes);
|
||||
return eachSeries(newRes, (r, cb) => {
|
||||
const timeout = r.delay;
|
||||
setAnimations(r, store, account);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user