Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
const preact = require('preact');
|
||||
const { Component } = require('preact');
|
||||
const { connect } = require('preact-redux');
|
||||
const anime = require('animejs').default;
|
||||
|
||||
const { TIMES, COLOURS } = require('../../constants');
|
||||
|
||||
const addState = connect(
|
||||
function receiveState(state) {
|
||||
const { animCb } = state;
|
||||
return { animCb };
|
||||
}
|
||||
);
|
||||
|
||||
class Attack extends Component {
|
||||
constructor(props) {
|
||||
super();
|
||||
this.props = props;
|
||||
this.animations = [];
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<svg
|
||||
class='attack-anim'
|
||||
version="1.1"
|
||||
id="attack"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 400 400">
|
||||
<g>
|
||||
<rect x="0" y="400" transform="skewX(45)"
|
||||
width="12" height="100" stroke-width="0" fill={COLOURS.RED}/>
|
||||
<rect x="200" y="400"
|
||||
width="12" height="100" stroke-width="0" fill={COLOURS.RED}/>
|
||||
<rect x="400" y="400" transform="skewX(-45)"
|
||||
width="12" height="100" stroke-width="0" fill={COLOURS.RED}/>
|
||||
</g>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.animations.push(anime({
|
||||
targets: ['#attack rect'],
|
||||
easing: 'easeOutExpo',
|
||||
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,
|
||||
}));
|
||||
}
|
||||
|
||||
// this is necessary because
|
||||
// skipping / timing / unmounting race conditions
|
||||
// can cause the animations to cut short, this will ensure the values are reset
|
||||
// because preact will recycle all these components
|
||||
componentWillUnmount() {
|
||||
for (let i = this.animations.length - 1; i >= 0; i--) {
|
||||
this.animations[i].reset();
|
||||
}
|
||||
this.props.animCb();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = addState(Attack);
|
||||
@@ -2,9 +2,9 @@ const preact = require('preact');
|
||||
const { Component } = require('preact');
|
||||
const { connect } = require('preact-redux');
|
||||
const anime = require('animejs').default;
|
||||
const times = require('lodash/times');
|
||||
|
||||
const { TIMES } = require('../../constants');
|
||||
const { randomPoints } = require('../../utils');
|
||||
const { TIMES, COLOURS } = require('../../constants');
|
||||
|
||||
const addState = connect(
|
||||
function receiveState(state) {
|
||||
@@ -30,76 +30,65 @@ function projectile(x, y, radius, colour) {
|
||||
class Blast 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 (
|
||||
<svg
|
||||
class={'skill-animation'}
|
||||
id='blast'
|
||||
class="skill-animation"
|
||||
version="1.1"
|
||||
id="blast"
|
||||
transform-box='fill-box'
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 300 400">
|
||||
// {this.charges}
|
||||
viewBox="0 0 300 300">
|
||||
<defs>
|
||||
<radialGradient id="grad1" cx="50%" cy="50%" r="70%" fx="50%" fy="50%">
|
||||
<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:0.6" />
|
||||
<stop offset="100%" style={'stop-color:#00aabb;stop-opacity:1'} />
|
||||
</radialGradient>
|
||||
<filter id="blastFilter">
|
||||
<feGaussianBlur in="SourceGraphic" stdDeviation="3" />
|
||||
<feMerge>
|
||||
<feMergeNode />
|
||||
<feMergeNode in="SourceGraphic" />
|
||||
</feMerge>
|
||||
</filter>
|
||||
</defs>
|
||||
<filter id="explosion">
|
||||
<feGaussianBlur stdDeviation="4"/>
|
||||
<feTurbulence type="turbulence" baseFrequency="0.05" numOctaves="3" result="turbulence"/>
|
||||
<feDisplacementMap in2="turbulence" in="SourceGraphic" scale="1" xChannelSelector="A" yChannelSelector="A"/>
|
||||
|
||||
</filter>
|
||||
{this.charges}
|
||||
<g>
|
||||
{times(50, () => (
|
||||
<g>
|
||||
<rect filter="url(#blastFilter)" class="blue" x="150" y="200" width="3" height="5" />
|
||||
<rect filter="url(#blastFilter)" class="white" x="150" y="200" width="1" height="3" />
|
||||
</g>
|
||||
))}
|
||||
</g>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
anime.set('#blast', {
|
||||
translateX: -200 * this.props.direction.x,
|
||||
translateY: -300 * this.props.direction.y,
|
||||
});
|
||||
|
||||
this.animations.push(anime({
|
||||
targets: '#blast',
|
||||
targets: ['#blast'],
|
||||
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 },
|
||||
{ value: 1, delay: TIMES.TARGET_DELAY_MS, duration: TIMES.TARGET_DURATION_MS * 0.2 },
|
||||
{ value: 0, delay: TIMES.TARGET_DURATION_MS * 0.5, duration: TIMES.TARGET_DURATION_MS * 0.2 },
|
||||
],
|
||||
easing: 'easeInOutSine',
|
||||
}));
|
||||
|
||||
anime.set('#explosion feDisplacementMap', {
|
||||
scale: 1,
|
||||
});
|
||||
|
||||
this.animations.push(anime({
|
||||
targets: '#blast',
|
||||
translateY: 0,
|
||||
translateX: 0,
|
||||
loop: false,
|
||||
targets: ['#blast g'],
|
||||
transform: () => `
|
||||
translate(${anime.random(-100, 100)} ${anime.random(-100, 100)})
|
||||
`,
|
||||
style: { rotate: anime.random(-180, 180) },
|
||||
easing: 'easeOutCubic',
|
||||
delay: TIMES.TARGET_DELAY_MS,
|
||||
duration: (TIMES.TARGET_DURATION_MS * 1 / 2),
|
||||
easing: 'easeInQuad',
|
||||
}));
|
||||
|
||||
this.animations.push(anime({
|
||||
targets: '#explosion feDisplacementMap',
|
||||
scale: 200,
|
||||
loop: false,
|
||||
delay: TIMES.TARGET_DELAY_MS + TIMES.TARGET_DURATION_MS * 1 / 2,
|
||||
duration: TIMES.TARGET_DURATION_MS * 1 / 2,
|
||||
easing: 'easeInQuad',
|
||||
duration: TIMES.TARGET_DURATION_MS,
|
||||
}));
|
||||
}
|
||||
|
||||
// this is necessary because
|
||||
// skipping / timing / unmounting race conditions
|
||||
// can cause the animations to cut short, this will ensure the values are reset
|
||||
// because preact will recycle all these components
|
||||
componentWillUnmount() {
|
||||
for (let i = this.animations.length - 1; i >= 0; i--) {
|
||||
this.animations[i].reset();
|
||||
|
||||
@@ -106,7 +106,8 @@ class Break extends Component {
|
||||
componentWillUnmount() {
|
||||
for (let i = this.animations.length - 1; i >= 0; i--) {
|
||||
this.animations[i].reset();
|
||||
} this.props.animCb();
|
||||
}
|
||||
this.props.animCb();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user