balloon fixed
This commit is contained in:
parent
04c655f633
commit
3466b2fa8d
|
|
@ -17688,6 +17688,16 @@ MonoBehaviour:
|
|||
anchor: {fileID: 5973755251599500745}
|
||||
target: {fileID: 4339140097867587715}
|
||||
balloonTrans: {fileID: 5836723102826521910}
|
||||
srs:
|
||||
- {fileID: 9182958110959949118}
|
||||
- {fileID: 8501495778278024990}
|
||||
- {fileID: 6606279674685812598}
|
||||
- {fileID: 8504151232427483742}
|
||||
- {fileID: 1269034092386606761}
|
||||
- {fileID: 3200788305752962139}
|
||||
- {fileID: 2829749095567035486}
|
||||
- {fileID: 5083661034436039098}
|
||||
shadow: {fileID: 3790953526902078340}
|
||||
xOffset: -2.962
|
||||
yOffset: -14.204
|
||||
--- !u!1 &4183335457383268975
|
||||
|
|
|
|||
|
|
@ -10,12 +10,17 @@ namespace HeavenStudio.Games.Scripts_MonkeyWatch
|
|||
[SerializeField] private Transform anchor;
|
||||
[SerializeField] private Transform target;
|
||||
[SerializeField] private Transform balloonTrans;
|
||||
[SerializeField] private SpriteRenderer[] srs;
|
||||
[SerializeField] private SpriteRenderer shadow;
|
||||
[Header("Properties")]
|
||||
[SerializeField] private float xOffset;
|
||||
[SerializeField] private float yOffset;
|
||||
|
||||
private float shadowOpacity;
|
||||
private float additionalXOffset;
|
||||
private float additionalYOffset;
|
||||
private double movementFirstBeat = -2;
|
||||
private double movementLastBeat = -1;
|
||||
|
||||
private List<Movement> movements = new();
|
||||
private int movementIndex = 0;
|
||||
|
|
@ -34,10 +39,20 @@ namespace HeavenStudio.Games.Scripts_MonkeyWatch
|
|||
public Util.EasingFunction.Ease ease;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
shadowOpacity = shadow.color.a;
|
||||
}
|
||||
|
||||
public void Init(double beat)
|
||||
{
|
||||
var allEvents = EventCaller.GetAllInGameManagerList("monkeyWatch", new string[] { "balloon" });
|
||||
allEvents.Sort((x, y) => x.beat.CompareTo(y.beat));
|
||||
if (allEvents.Count > 0)
|
||||
{
|
||||
movementFirstBeat = allEvents[0].beat;
|
||||
movementLastBeat = allEvents[^1].beat + allEvents[^1].length - 0.25;
|
||||
}
|
||||
foreach (var e in allEvents)
|
||||
{
|
||||
movements.Add(new Movement
|
||||
|
|
@ -59,7 +74,8 @@ namespace HeavenStudio.Games.Scripts_MonkeyWatch
|
|||
private void UpdateIndex()
|
||||
{
|
||||
movementIndex++;
|
||||
if (movementIndex + 1 < movements.Count && Conductor.instance.songPositionAsDouble > movements[movementIndex].beat + movements[movementIndex].length)
|
||||
if (movementIndex >= movements.Count) return;
|
||||
if (Conductor.instance.songPositionInBeatsAsDouble > movements[movementIndex].beat + movements[movementIndex].length)
|
||||
{
|
||||
UpdateIndex();
|
||||
}
|
||||
|
|
@ -68,12 +84,30 @@ namespace HeavenStudio.Games.Scripts_MonkeyWatch
|
|||
private void Update()
|
||||
{
|
||||
var cond = Conductor.instance;
|
||||
balloonTrans.gameObject.SetActive(movements.Count > 0);
|
||||
if (movements.Count > 0)
|
||||
float normalizedFirst = Mathf.Clamp01(cond.GetPositionFromBeat(movementFirstBeat, 0.25f));
|
||||
float normalizedLast = Mathf.Clamp01(cond.GetPositionFromBeat(movementLastBeat, 0.25f));
|
||||
if (normalizedFirst >= 1)
|
||||
{
|
||||
if (movementIndex + 1 < movements.Count && cond.songPositionAsDouble > movements[movementIndex].beat + movements[movementIndex].length)
|
||||
foreach (var sr in srs)
|
||||
{
|
||||
sr.color = new Color(sr.color.r, sr.color.g, sr.color.b, 1 - normalizedLast);
|
||||
}
|
||||
shadow.color = new Color(shadow.color.r, shadow.color.g, shadow.color.b, Mathf.Lerp(shadowOpacity, 0, normalizedLast));
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var sr in srs)
|
||||
{
|
||||
sr.color = new Color(sr.color.r, sr.color.g, sr.color.b, normalizedFirst);
|
||||
}
|
||||
shadow.color = new Color(shadow.color.r, shadow.color.g, shadow.color.b, Mathf.Lerp(0, shadowOpacity, normalizedFirst));
|
||||
}
|
||||
if (movements.Count > 0 && movementIndex < movements.Count)
|
||||
{
|
||||
if (cond.songPositionInBeatsAsDouble > movements[movementIndex].beat + movements[movementIndex].length)
|
||||
{
|
||||
UpdateIndex();
|
||||
if (movementIndex >= movements.Count) return;
|
||||
}
|
||||
|
||||
var e = movements[movementIndex];
|
||||
|
|
|
|||
|
|
@ -126,12 +126,12 @@ namespace HeavenStudio.Games.Loaders
|
|||
defaultLength = 4f,
|
||||
parameters = new List<Param>()
|
||||
{
|
||||
new Param("angleStart", new EntityTypes.Float(0, 360, 0), "Start Angle"),
|
||||
new Param("angleEnd", new EntityTypes.Float(0, 360, 0), "End Angle"),
|
||||
new Param("yStart", new EntityTypes.Float(0, 200, 15), "Y Start"),
|
||||
new Param("yEnd", new EntityTypes.Float(0, 200, 15), "Y End"),
|
||||
new Param("xStart", new EntityTypes.Float(0, 200, 15), "X Start"),
|
||||
new Param("xEnd", new EntityTypes.Float(0, 200, 15), "X End"),
|
||||
new Param("angleStart", new EntityTypes.Float(-360, 360, 0), "Start Angle"),
|
||||
new Param("angleEnd", new EntityTypes.Float(-360, 360, 0), "End Angle"),
|
||||
new Param("yStart", new EntityTypes.Float(-200, 200, 0), "Y Start"),
|
||||
new Param("yEnd", new EntityTypes.Float(-200, 200, 0), "Y End"),
|
||||
new Param("xStart", new EntityTypes.Float(-200, 200, 0), "X Start"),
|
||||
new Param("xEnd", new EntityTypes.Float(-200, 200, 0), "X End"),
|
||||
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue