laser anim for attack and strike
This commit is contained in:
parent
bd750be110
commit
d9184dea0a
@ -44,9 +44,9 @@ function animations(props) {
|
|||||||
} else if (stage === 'END_SKILL') {
|
} else if (stage === 'END_SKILL') {
|
||||||
const skill = removeTier(text);
|
const skill = removeTier(text);
|
||||||
switch (skill) {
|
switch (skill) {
|
||||||
case 'Attack': return <Attack id={construct.id} stage={stage} team={player}/>;
|
case 'Attack': return <Strike id={construct.id} stage={stage} team={player} colour={colours.white}/>;
|
||||||
case 'Blast': return <Blast id={construct.id} stage={stage} team={player}/>;
|
case 'Blast': return <Blast id={construct.id} stage={stage} team={player}/>;
|
||||||
case 'StrikeI': return <Strike id={construct.id} stage={stage} team={player}/>;
|
case 'Strike': return <Strike id={construct.id} stage={stage} team={player} colour={colours.red}/>;
|
||||||
default: return text;
|
default: return text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,13 +60,11 @@ function animations(props) {
|
|||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*return (
|
||||||
/* return (
|
|
||||||
<div class={combatTextClass}>
|
<div class={combatTextClass}>
|
||||||
<Test id={construct.id} stage={stage} team={player}/>
|
<Test id={construct.id} stage={stage} team={player}/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);*/
|
||||||
*/
|
|
||||||
return (<div> </div>);
|
return (<div> </div>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,17 +6,37 @@ const { TIMES } = require('../../constants');
|
|||||||
|
|
||||||
const duration = TIMES.START_SKILL;
|
const duration = TIMES.START_SKILL;
|
||||||
|
|
||||||
|
|
||||||
|
function laser(dimensions, colour) {
|
||||||
|
const { x, y, length } = dimensions;
|
||||||
|
return (
|
||||||
|
<rect
|
||||||
|
width="18"
|
||||||
|
height={length}
|
||||||
|
x={x}
|
||||||
|
y={y}
|
||||||
|
fill="url(#grad1)"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke={colour}
|
||||||
|
filter="url(#explosion)"
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
class Strike extends Component {
|
class Strike extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super();
|
super();
|
||||||
this.props = props;
|
this.team = props.team;
|
||||||
const points = [];
|
// this.colour = props.colour;
|
||||||
for (let i = 0; i <= 70; i += 1) {
|
this.colour = props.colour;
|
||||||
const x = Math.floor(300 * Math.random());
|
|
||||||
const y = Math.floor(400 * Math.random());
|
const coord = [0, 100, 200];
|
||||||
points.push([x, y]);
|
const points = coord.map(pos => ({
|
||||||
this.circles = points.map((coord, j) => <circle key={j} cx={coord[0]} cy={coord[1]} r="7" stroke="#a52a2a" fill="#a52a2a" />);
|
x: pos + Math.random() * 80,
|
||||||
}
|
y: 50 + Math.random() * 100,
|
||||||
|
length: 150 + Math.random() * 100,
|
||||||
|
}));
|
||||||
|
this.charges = points.map(pos => laser(pos, this.colour));
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@ -27,42 +47,57 @@ class Strike extends Component {
|
|||||||
id="Layer_1"
|
id="Layer_1"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
viewBox="0 0 300 400">
|
viewBox="0 0 300 400">
|
||||||
{this.circles}
|
// {this.charges}
|
||||||
|
<defs>
|
||||||
|
<radialGradient id="grad1" cx="50%" cy="0%" r="85%" fx="50%" fy="50%">
|
||||||
|
<stop offset="0%" style="stop-color:#dba9a9;stop-opacity:0.6" />
|
||||||
|
<stop offset="100%" style={`stop-color:${this.colour};stop-opacity:1`} />
|
||||||
|
</radialGradient>
|
||||||
|
</defs>
|
||||||
|
<filter id="explosion">
|
||||||
|
<feGaussianBlur stdDeviation="4"/>
|
||||||
|
<feTurbulence type="turbulence" baseFrequency="0.01" numOctaves="3" result="turbulence"/>
|
||||||
|
<feDisplacementMap in2="turbulence" in="SourceGraphic" scale="1" xChannelSelector="A" yChannelSelector="A"/>
|
||||||
|
|
||||||
|
</filter>
|
||||||
|
{this.charges}
|
||||||
</svg>
|
</svg>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
let y = -100;
|
if (!this.props.team) {
|
||||||
const daggers = document.querySelectorAll('.skill-anim circle');
|
anime.set('.skill-anim', {
|
||||||
if (this.props.stage === 'START_SKILL') {
|
rotate: Math.random() * 180 + 90,
|
||||||
if (!this.props.team) {
|
});
|
||||||
anime.set('.skill-anim', {
|
} else {
|
||||||
rotate: 180,
|
anime.set('.skill-anim', {
|
||||||
});
|
rotate: Math.random() * 180 + 270,
|
||||||
} else {
|
});
|
||||||
anime.set('.skill-anim', {
|
|
||||||
rotate: 0,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
anime.set('.skill-anim', {
|
||||||
|
translateY: -200,
|
||||||
|
translateX: 0,
|
||||||
|
});
|
||||||
|
anime.set('#explosion feDisplacementMap', {
|
||||||
|
scale: 1,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
if (this.props.stage === 'END_SKILL') {
|
|
||||||
if (!this.props.team) {
|
|
||||||
anime.set('.skill-anim', {
|
|
||||||
rotate: 0,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
anime.set('.skill-anim', {
|
|
||||||
rotate: 180,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
anime({
|
anime({
|
||||||
targets: daggers,
|
targets: '.skill-anim',
|
||||||
cx: 150,
|
translateY: 0,
|
||||||
cy: y,
|
translateX: 0,
|
||||||
|
loop: false,
|
||||||
|
duration: (duration * 1 / 2),
|
||||||
|
easing: 'easeInQuad',
|
||||||
|
});
|
||||||
|
anime({
|
||||||
|
targets: '#explosion feDisplacementMap',
|
||||||
|
scale: 200,
|
||||||
|
loop: false,
|
||||||
|
delay: (duration * 1 / 4),
|
||||||
duration,
|
duration,
|
||||||
easing: 'easeInQuad',
|
easing: 'easeInQuad',
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,21 +3,21 @@ const { Component } = require('preact');
|
|||||||
const anime = require('animejs').default;
|
const anime = require('animejs').default;
|
||||||
|
|
||||||
const { TIMES } = require('../../constants');
|
const { TIMES } = require('../../constants');
|
||||||
const { randomPoints } = require('../../utils');
|
|
||||||
|
|
||||||
const duration = TIMES.START_SKILL;
|
const duration = TIMES.START_SKILL;
|
||||||
|
|
||||||
|
|
||||||
function projectile(x, y, radius, colour) {
|
function laser(dimensions, colour) {
|
||||||
|
const { x, y, length } = dimensions;
|
||||||
return (
|
return (
|
||||||
<circle
|
<rect
|
||||||
cx={x}
|
width="18"
|
||||||
cy={y}
|
height={length}
|
||||||
r={radius}
|
x={x}
|
||||||
|
y={y}
|
||||||
fill="url(#grad1)"
|
fill="url(#grad1)"
|
||||||
stroke-width="2"
|
stroke-width="2"
|
||||||
stroke={colour}
|
stroke={colour}
|
||||||
id="projectile"
|
|
||||||
filter="url(#explosion)"
|
filter="url(#explosion)"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@ -28,9 +28,15 @@ class AttackCharge extends Component {
|
|||||||
super();
|
super();
|
||||||
this.team = props.team;
|
this.team = props.team;
|
||||||
// this.colour = props.colour;
|
// this.colour = props.colour;
|
||||||
this.colour = '#00aabb';
|
this.colour = '#a52a2a';
|
||||||
const points = randomPoints(8, 60, { x: 0, y: 0, width: 300, height: 400 });
|
|
||||||
this.charges = points.map(coord => projectile(coord[0], coord[1], 20, this.colour));
|
const coord = [0, 100, 200];
|
||||||
|
const points = coord.map(pos => ({
|
||||||
|
x: pos + Math.random() * 80,
|
||||||
|
y: 50 + Math.random() * 100,
|
||||||
|
length: 150 + Math.random() * 100,
|
||||||
|
}));
|
||||||
|
this.charges = points.map(pos => laser(pos, this.colour));
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@ -43,14 +49,14 @@ class AttackCharge extends Component {
|
|||||||
viewBox="0 0 300 400">
|
viewBox="0 0 300 400">
|
||||||
// {this.charges}
|
// {this.charges}
|
||||||
<defs>
|
<defs>
|
||||||
<radialGradient id="grad1" cx="50%" cy="50%" r="70%" fx="50%" fy="50%">
|
<radialGradient id="grad1" cx="50%" cy="0%" r="85%" fx="50%" fy="50%">
|
||||||
<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:0.6" />
|
<stop offset="0%" style="stop-color:#dba9a9;stop-opacity:0.6" />
|
||||||
<stop offset="100%" style={`stop-color:${this.colour};stop-opacity:1`} />
|
<stop offset="100%" style={`stop-color:${this.colour};stop-opacity:1`} />
|
||||||
</radialGradient>
|
</radialGradient>
|
||||||
</defs>
|
</defs>
|
||||||
<filter id="explosion">
|
<filter id="explosion">
|
||||||
<feGaussianBlur stdDeviation="4"/>
|
<feGaussianBlur stdDeviation="4"/>
|
||||||
<feTurbulence type="turbulence" baseFrequency="0.05" numOctaves="3" result="turbulence"/>
|
<feTurbulence type="turbulence" baseFrequency="0.01" numOctaves="3" result="turbulence"/>
|
||||||
<feDisplacementMap in2="turbulence" in="SourceGraphic" scale="1" xChannelSelector="A" yChannelSelector="A"/>
|
<feDisplacementMap in2="turbulence" in="SourceGraphic" scale="1" xChannelSelector="A" yChannelSelector="A"/>
|
||||||
|
|
||||||
</filter>
|
</filter>
|
||||||
@ -60,20 +66,14 @@ class AttackCharge extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const charges = document.querySelectorAll('#projectile');
|
anime.set('.skill-anim', {
|
||||||
if (!this.team) {
|
rotate: 90,
|
||||||
anime.set('.skill-anim', {
|
translateY: -200,
|
||||||
rotate: 90,
|
translateX: 0,
|
||||||
translateY: -200,
|
});
|
||||||
translateX: 0,
|
anime.set('#explosion feDisplacementMap', {
|
||||||
});
|
scale: 1,
|
||||||
} else {
|
});
|
||||||
anime.set('.skill-anim', {
|
|
||||||
rotate: 90,
|
|
||||||
translateY: -200,
|
|
||||||
translateX: 0,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
anime({
|
anime({
|
||||||
targets: '.skill-anim',
|
targets: '.skill-anim',
|
||||||
@ -85,8 +85,9 @@ class AttackCharge extends Component {
|
|||||||
});
|
});
|
||||||
anime({
|
anime({
|
||||||
targets: '#explosion feDisplacementMap',
|
targets: '#explosion feDisplacementMap',
|
||||||
scale: 100,
|
scale: 200,
|
||||||
loop: false,
|
loop: false,
|
||||||
|
delay: (duration * 1 / 4),
|
||||||
duration,
|
duration,
|
||||||
easing: 'easeInQuad',
|
easing: 'easeInQuad',
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user