60 lines
1.1 KiB
C#
60 lines
1.1 KiB
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Text.RegularExpressions;
|
||
|
using System.Text;
|
||
|
using Godot;
|
||
|
|
||
|
namespace Rokojori
|
||
|
{
|
||
|
[Tool]
|
||
|
[GlobalClass]
|
||
|
public partial class Shake:RJSequenceAction
|
||
|
{
|
||
|
[Export]
|
||
|
public ShakeEffect shakeEffect;
|
||
|
|
||
|
[Export]
|
||
|
public Node3D[] targets;
|
||
|
|
||
|
List<Transform3D> _targetValues;
|
||
|
|
||
|
int actionID = -1;
|
||
|
int animationID = -1;
|
||
|
|
||
|
public override void _OnTrigger()
|
||
|
{
|
||
|
if ( actionID != -1 )
|
||
|
{
|
||
|
CancelAction( actionID );
|
||
|
}
|
||
|
|
||
|
actionID = DispatchStart();
|
||
|
|
||
|
var random = shakeEffect.shakeCurve.Randomize();
|
||
|
var timeline = shakeEffect.timeline;
|
||
|
|
||
|
var duration = shakeEffect.shakeCurve.GetRandomizedEndTime( random );
|
||
|
|
||
|
var start = TimeLineManager.GetPosition( shakeEffect.timeline );
|
||
|
var end = start + duration;
|
||
|
|
||
|
|
||
|
|
||
|
animationID = TimeLineScheduler.ScheduleSpanIn( timeline, 0, duration,
|
||
|
( int id, int type )=>
|
||
|
{
|
||
|
if ( animationID != id )
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
);
|
||
|
|
||
|
}
|
||
|
|
||
|
public override void CancelAction( int id )
|
||
|
{
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|