send cast in event, split up cast and hit

This commit is contained in:
Mashy
2019-12-06 18:09:11 +10:00
parent 7afb6e30bd
commit a6f654fac1
9 changed files with 144 additions and 119 deletions
+2 -4
View File
@@ -46,8 +46,8 @@ class Attack extends Component {
y: [400, 200],
height: [100, 10, 0],
width: [12, 5, 0],
delay: () => anime.random(TIMES.TARGET_DELAY_MS, TIMES.TARGET_DELAY_MS + TIMES.TARGET_DURATION_MS / 2),
duration: TIMES.TARGET_DURATION_MS,
delay: () => anime.random(0, TIMES.TARGET_DURATION_MS / 4),
duration: TIMES.TARGET_DURATION_MS * 5 / 4,
}));
}
@@ -59,9 +59,7 @@ class Attack extends Component {
for (let i = this.animations.length - 1; i >= 0; i--) {
this.animations[i].reset();
}
this.props.animCb && this.props.animCb();
}
}
module.exports = addState(Attack);
@@ -7,7 +7,7 @@ const shapes = require('./shapes');
const { removeTier } = require('../utils');
const { TIMES } = require('./../constants');
const addState = connect(({ animText, animSkill, itemInfo }) => ({ animText, animSkill, itemInfo }));
const addState = connect(({ animText, itemInfo }) => ({ animText, itemInfo }));
class AnimText extends preact.Component {
shouldComponentUpdate(newProps) {
@@ -17,7 +17,7 @@ class AnimText extends preact.Component {
componentDidUpdate(prevProps) {
const { animText, construct } = this.props;
if (animText && animText !== prevProps.animText && animText.target === construct.id) {
if (animText && animText !== prevProps.animText && animText.variant[1].target === construct.id) {
anime({
targets: '.combat-text',
top: '40%',
@@ -28,10 +28,10 @@ class AnimText extends preact.Component {
}
render() {
const { construct, animText, animSkill, itemInfo } = this.props;
if (animText && animText.target === construct.id) {
const { construct, animText, itemInfo } = this.props;
if (animText && animText.variant[1].target === construct.id) {
const itemSourceDescription = () => {
const itemSource = itemInfo.combos.filter(c => c.item === removeTier(animSkill));
const itemSource = itemInfo.combos.filter(c => c.item === removeTier(animText.cast.skill));
const itemSourceInfo = itemSource.length
? `${itemSource[0].components[0]} ${itemSource[0].components[1]} ${itemSource[0].components[2]}`
: false;
@@ -82,7 +82,7 @@ class AnimText extends preact.Component {
return (
<div class="combat-text">
<h2><span>{animSkill}</span></h2>
<h2><span>{animText.cast.skill}</span></h2>
<span>{itemSourceDescription()}</span>
{generateAnimText()}
</div>
@@ -21,11 +21,10 @@ const addState = connect(
class GameConstructEffects extends preact.Component {
shouldComponentUpdate(newProps) {
if (newProps.animText !== this.props.animText) {
if (newProps.animText && newProps.animText.constructId === this.props.construct.id) {
const [type] = newProps.animText.variant;
if (type === 'Effect' || type === 'Removal') return true;
}
if (newProps.animText && newProps.animText !== this.props.animText) {
const [type, info] = newProps.animText.variant;
if (info.target === this.props.construct.id
&& (type === 'Effect' || type === 'Removal')) return true;
}
if (newProps.construct !== this.props.construct) return true;
return false;
@@ -7,11 +7,10 @@ const addState = connect(({ animText }) => ({ animText }));
class GameConstructLife extends preact.Component {
shouldComponentUpdate(newProps) {
if (newProps.animText !== this.props.animText) {
if (newProps.animText && newProps.animText.target === this.props.construct.id) {
const [type] = newProps.animText.variant;
if (type === 'Damage' || type === 'Healing' || type === 'Recharge') return true;
}
if (newProps.animText && newProps.animText !== this.props.animText) {
const [type, info] = newProps.animText.variant;
if (info.target === this.props.construct.id
&& (type === 'Damage' || type === 'Healing' || type === 'Recharge')) return true;
}
if (newProps.construct !== this.props.construct) return true;
return false;