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