This commit is contained in:
Mashy 2019-07-04 11:49:58 +10:00
parent 2e19170689
commit d455c68415
2 changed files with 66 additions and 25 deletions

View File

@ -143,14 +143,14 @@ function animations(props) {
// Block Base // Block Base
case 'Block': return <Block />; case 'Block': return <Block />;
case 'Clutch': return false;
case 'Electrify': return <Electrify />; case 'Electrify': return <Electrify />;
case 'Electrocute': return <Electrocute />; case 'Electrocute': return <Electrocute />;
case 'ElectrocuteTick': return false; case 'ElectrocuteTick': return false;
case 'Parry': return <Parry team={player} />; case 'Parry': return <Parry team={player} />;
case 'Purify': return <Purify team={player} />;
case 'Recharge': return <Recharge team={player} />; case 'Recharge': return <Recharge team={player} />;
case 'Reflect': return <Reflect team={player} />; case 'Reflect': return <Reflect team={player} />;
case 'Purify': return <Purify team={player} />;
case 'Clutch': return false;
default: return false; default: return false;
} }

View File

@ -2,27 +2,56 @@ const preact = require('preact');
const { Component } = require('preact'); const { Component } = require('preact');
const anime = require('animejs').default; const anime = require('animejs').default;
const { TIMES } = require('../../constants'); const { TIMES, COLOURS } = require('../../constants');
function projectile(x, y, radius, colour) {
return (
<circle
cx={x}
cy={y}
r={radius}
fill={colour}
stroke="none"
id="charges"
opacity="0"
/>
);
}
class Purify extends Component { class Purify extends Component {
constructor() { constructor() {
super(); super();
this.animations = []; this.animations = [];
const points = [
[128, 168],
[80, 240],
[176, 240],
[212, 216],
[128, 96],
[44, 216],
[80, 240],
[248, 192],
[128, 24],
[8, 192],
];
this.charges = points.map(coord => projectile(coord[0], coord[1], 12, COLOURS.GREEN));
} }
render({ team }) { render({ team }) {
return ( return (
<svg <svg
class='skill-animation red' class='skill-animation green'
version="1.1" version="1.1"
id="purify" id="purify"
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
style={{ transform: team ? 'rotate3d(1, 0, 0, 180deg)' : '' }} style={{ transform: team ? 'rotate3d(1, 0, 0, 180deg)' : '' }}
viewBox="0 0 256 256"> viewBox="0 0 256 256">
<filter id='purifyFilter'> <filter id='purifyFilter'>
<feTurbulence type="turbulence" baseFrequency="0" numOctaves="1" result="turbulence"></feTurbulence> <feGaussianBlur stdDeviation="3"/>
<feDisplacementMap in2="turbulence" in="SourceGraphic" scale="1" xChannelSelector="R" yChannelSelector="G"></feDisplacementMap> <feColorMatrix mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 19 -9" result="cutoff"/>
<feComposite operator="atop" in="SourceGraphic" in2="cutoff"/>
</filter> </filter>
<g id="block">
<polyline <polyline
points='128,168 80,240 176,240 128,168' points='128,168 80,240 176,240 128,168'
style={{ filter: 'url("#purifyFilter")' }} style={{ filter: 'url("#purifyFilter")' }}
@ -35,6 +64,10 @@ class Purify extends Component {
points='212,216 248,192 128,24 8,192 44,216' points='212,216 248,192 128,24 8,192 44,216'
style={{ filter: 'url("#purifyFilter")' }} style={{ filter: 'url("#purifyFilter")' }}
/> />
</g>
<g filter="url(#purifyFilter)">
{this.charges}
</g>
</svg> </svg>
); );
} }
@ -44,19 +77,27 @@ class Purify extends Component {
targets: ['#purify'], targets: ['#purify'],
opacity: [ opacity: [
{ value: 1, delay: TIMES.TARGET_DELAY_MS, duration: TIMES.TARGET_DURATION_MS * 0.2 }, { value: 1, delay: TIMES.TARGET_DELAY_MS, duration: TIMES.TARGET_DURATION_MS * 0.2 },
{ value: 0, delay: TIMES.TARGET_DURATION_MS * 0.6, duration: TIMES.TARGET_DURATION_MS * 0.3 }, { value: 0, delay: TIMES.TARGET_DURATION_MS * 0.6, duration: TIMES.TARGET_DURATION_MS * 0.2 },
], ],
easing: 'easeInOutSine', easing: 'easeInOutSine',
})); }));
this.animations.push(anime({
targets: ['#block'],
opacity: [
{ value: 0, delay: TIMES.TARGET_DELAY_MS, duration: TIMES.TARGET_DURATION_MS },
],
easing: 'easeInOutSine',
}));
this.animations.push(anime({ this.animations.push(anime({
targets: ['#purifyFilter feTurbulence', ' #purifyFilter feDisplacementMap'], targets: ['#charges'],
baseFrequency: 2, opacity: [
scale: 10, { value: 1, duration: TIMES.TARGET_DELAY_MS + TIMES.TARGET_DURATION_MS * 0.2 },
numOctaves: 5, ],
easing: 'easeOutSine', easing: 'easeInOutSine',
cx: 128,
cy: 24,
delay: TIMES.TARGET_DELAY_MS, delay: TIMES.TARGET_DELAY_MS,
duration: TIMES.TARGET_DURATION_MS, duration: TIMES.TARGET_DURATION_MS,
})); }));