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 ( ); } function sword(colour) { return ( ); } class AttackCharge extends Component { constructor(props) { super(); this.team = props.team; // this.colour = props.colour; this.colour = '#a52a2a'; const points = new Array(30).fill(0); this.charges = points.map(() => projectile(150, 420, 7, '#1FF01F')); } render() { return ( {sword(this.colour)} {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: -400, translateX: 0, }); anime.set('#explosion feDisplacementMap', { scale: 100, }); anime.set('#sword', { fill: this.colour, stroke: this.colour, }); anime.set('#projectile', { cx: 150, cy: 420, }); anime({ targets: '.skill-anim', translateY: 0, translateX: 0, loop: false, duration: (duration * 1 / 2), easing: 'easeInQuad', }); anime({ targets: '#explosion feDisplacementMap', scale: 10000, loop: false, delay: (duration * 1 / 2), duration: (duration * 1 / 2), easing: 'easeInQuad', }); anime({ targets: '#sword', fill: '#1FF01F', stroke: '#1FF01F', delay: (duration * 3 / 4), }); const projectiles = document.querySelectorAll('#projectile'); projectiles.forEach(proj => { anime({ targets: proj, cx: Math.random() * 250 + 25, cy: Math.random() * 200 - 100, delay: (duration * 2 / 3), duration: (duration * 1 / 3), easing: 'easeInQuad', }); }); } } module.exports = AttackCharge;