update anims test

This commit is contained in:
ntr
2019-07-19 14:47:48 +10:00
parent 028606e804
commit 47b9d496dc
4 changed files with 55 additions and 41 deletions
+18 -8
View File
@@ -36,28 +36,38 @@ class ConstructAvatar extends Component {
}
componentDidMount() {
this.idle = idleAnimation(this.props.construct.id);
this.animations.push(this.idle);
}
const { animSource, animTarget, construct } = this.props;
const isSource = animSource && animSource.constructId === construct.id;
const isTarget = animTarget && animTarget.constructId === construct.id;
console.log(isSource, isTarget);
if (!isSource || !isTarget) {
return this.animations.push(idleAnimation(construct.id));
}
componentWillReceiveProps({ animSource, animTarget }) {
const avatarAnim = () => {
if (animSource && animSource.constructId === this.props.construct.id) {
console.log(isSource);
if (isSource) {
return sourceCast(animSource.constructId, animSource.direction);
}
// if (!animTarget) return false;
// match(animTarget.skill, [
// ['banish', () => banish(this.props.construct.id)],
// ['banish', () => banish(construct.id)],
// ['invert', () => invert(this.props.construct.id)],
// ]);
};
const anim = avatarAnim();
if (anim) {
this.idle.pause();
console.log(anim);
this.animations.push(anim);
anim.finished.then(this.idle.play);
anim.finished.then(() => {
console.log('anim finished');
return this.animations.push(idleAnimation(construct.id));
});
}
return true;