const preact = require('preact'); const { Component } = require('preact'); const anime = require('animejs').default; const { TIMES } = require('../../constants'); const { randomPoints } = require('../../utils'); const duration = TIMES.TARGET_DURATION_MS; function projectile(x, y, radius, colour) { return ( ); } class AttackCharge extends Component { constructor(props) { super(); this.team = props.team; this.animations = []; const points = randomPoints(8, 60, { x: 0, y: 0, width: 300, height: 400 }); this.charges = points.map(coord => projectile(coord[0], coord[1], 20, '#00aabb')); } render() { return ( // {this.charges} {this.charges} ); } componentDidMount() { if (!this.props.team) { anime.set('.skill-anim', { rotate: Math.random() * 180 + 90, }); } else { anime.set('.skill-anim', { rotate: Math.random() * 180 + 270, }); } anime.set('.skill-anim', { translateY: -200, opacity: 0, }); this.animations.push(anime({ targets: '.skill-anim', opacity: [ { value: 1, delay: TIMES.TARGET_DELAY_MS, duration: TIMES.TARGET_DURATION_MS * 0.3 }, { value: 0, delay: TIMES.TARGET_DURATION_MS * 0.7, duration: TIMES.POST_SKILL_DURATION_MS }, ], })); anime.set('#explosion feDisplacementMap', { scale: 1, }); anime({ targets: '.skill-anim', translateY: 0, loop: false, delay: TIMES.TARGET_DELAY_MS, duration: (duration * 1 / 2), easing: 'easeInQuad', }); anime({ targets: '#explosion feDisplacementMap', scale: 100, loop: false, delay: TIMES.TARGET_DELAY_MS, duration, easing: 'easeInQuad', }); } componentWillUnmount() { for (let i = this.animations.length - 1; i >= 0; i--) { this.animations[i].reset(); } } } module.exports = AttackCharge;