diff --git a/client/src/components/animations.jsx b/client/src/components/animations.jsx index bee94eae..7512e5f2 100644 --- a/client/src/components/animations.jsx +++ b/client/src/components/animations.jsx @@ -1,6 +1,8 @@ const preact = require('preact'); const Attack = require('./anims/attack'); +const Strike = require('./anims/strike'); +const Test = require('./anims/test'); function animations(props) { const { combatTextClass, combatText, stage, player, construct } = props; @@ -8,6 +10,8 @@ function animations(props) { const anim = text => { switch (text) { case 'Attack': return ; + case 'StrikeI': return ; + default: return text; } }; @@ -18,7 +22,11 @@ function animations(props) { {combatAnim} ; } - + return ( +
+ +
+ ); return (
 
); } diff --git a/client/src/components/anims/strike.jsx b/client/src/components/anims/strike.jsx new file mode 100644 index 00000000..92b59662 --- /dev/null +++ b/client/src/components/anims/strike.jsx @@ -0,0 +1,72 @@ +const preact = require('preact'); +const { Component } = require('preact'); +const anime = require('animejs').default; + +const { TIMES } = require('../../constants'); + +const duration = TIMES.START_SKILL; + +class Strike extends Component { + constructor(props) { + super(); + this.props = props; + const points = []; + for (let i = 0; i <= 70; i += 1) { + const x = Math.floor(300 * Math.random()); + const y = Math.floor(400 * Math.random()); + points.push([x, y]); + this.circles = points.map((coord, j) => ); + } + } + + render() { + return ( + + {this.circles} + + ); + } + + componentDidMount() { + let y = -100; + const daggers = document.querySelectorAll('.skill-anim circle'); + if (this.props.stage === 'START_SKILL') { + if (!this.props.team) { + anime.set('.skill-anim', { + rotate: 180, + }); + } else { + anime.set('.skill-anim', { + rotate: 0, + }); + } + } + + if (this.props.stage === 'END_SKILL') { + if (!this.props.team) { + anime.set('.skill-anim', { + rotate: 0, + }); + } else { + anime.set('.skill-anim', { + rotate: 180, + }); + } + } + + anime({ + targets: daggers, + cx: 150, + cy: y, + duration, + easing: 'easeInQuad', + }); + } +} + +module.exports = Strike; diff --git a/client/src/components/anims/test.jsx b/client/src/components/anims/test.jsx new file mode 100644 index 00000000..fdbd846f --- /dev/null +++ b/client/src/components/anims/test.jsx @@ -0,0 +1,116 @@ +const preact = require('preact'); +const { Component } = require('preact'); +const anime = require('animejs').default; + +const { TIMES } = require('../../constants'); + +const duration = TIMES.START_SKILL; + +class Attack extends Component { + constructor(props) { + super(); + this.props = props; + const points = []; + + + for (let i = 0; i <= 2; i += 1) { + const x = Math.floor(Math.random() * 200 + 50); + const y = Math.floor(Math.random() * 300 + 50); + points.push([x, y]); + this.circles = points.map((coord, j) => ( + + + + + + )); + } + } + + render() { + return ( + + + + + {this.circles} + + ); + } + + componentDidMount() { + if (this.props.stage === 'START_SKILL') { + if (!this.props.team) { + anime.set('.skill-anim', { + rotate: 180, + }); + } else { + anime.set('.skill-anim', { + rotate: 0, + }); + } + } + + if (this.props.stage === 'END_SKILL') { + if (!this.props.team) { + anime.set('.skill-anim', { + rotate: 0, + }); + } else { + anime.set('.skill-anim', { + rotate: 180, + }); + } + } + const stageone = document.querySelectorAll('#charge'); + anime({ + targets: stageone, + fill: '#a52a2a', + delay: anime.stagger(100), + loop: true, + duration: 1000, + easing: 'easeInQuad', + }); + + + } +} + +module.exports = Attack;