Пофиксить анимацию панелей режима в меню
This commit is contained in:
parent
1e22f83b06
commit
188018fe13
@ -24627,7 +24627,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!224 &1637412870
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using DG.Tweening;
|
||||
using DG.Tweening;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@ -31,7 +29,7 @@ public class GamemodePanel : MenuPanel
|
||||
[SerializeField] private GameMode gameMode;
|
||||
|
||||
private Vector2 signStart;
|
||||
private CancellationTokenSource cts;
|
||||
private Sequence _animation;
|
||||
|
||||
private float totalTime => frameDuration + characterDelay + characterDuration;
|
||||
|
||||
@ -43,71 +41,61 @@ public class GamemodePanel : MenuPanel
|
||||
public override void Enable(int _, float delay)
|
||||
{
|
||||
StopAnimation();
|
||||
cts = new();
|
||||
|
||||
_animation = DOTween.Sequence();
|
||||
|
||||
foreach (var frame in frames)
|
||||
{
|
||||
frame
|
||||
.DOSizeDelta(enabledFrameWH, frameDuration)
|
||||
.SetEase(Ease.OutQuad)
|
||||
.WithCancellation(cts.Token);
|
||||
Tween tween = frame.DOSizeDelta(enabledFrameWH, frameDuration).SetEase(Ease.OutQuad);
|
||||
_animation.Join(tween);
|
||||
}
|
||||
|
||||
characterRect
|
||||
.DOSizeDelta(enabledCharacterWH,characterDuration)
|
||||
.SetDelay(characterDelay)
|
||||
.SetEase(Ease.OutQuad)
|
||||
.WithCancellation(cts.Token);
|
||||
_animation.Insert(characterDelay,
|
||||
characterRect.DOSizeDelta(enabledCharacterWH, characterDuration).SetEase(Ease.OutQuad));
|
||||
|
||||
characterImage.DOColor(enabledCharacterColor, characterDuration)
|
||||
.SetDelay(characterDelay)
|
||||
.SetEase(Ease.OutQuad)
|
||||
.WithCancellation(cts.Token);
|
||||
_animation.Insert(characterDelay,
|
||||
characterImage.DOColor(enabledCharacterColor, characterDuration).SetEase(Ease.OutQuad));
|
||||
|
||||
Sequence sequence = DOTween.Sequence();
|
||||
|
||||
sequence.Append(
|
||||
_animation.Append(
|
||||
modeSign.DOAnchorPos(signStart - signOffset, totalTime * 0.15f)
|
||||
.SetEase(Ease.Linear)
|
||||
);
|
||||
sequence.Append(
|
||||
_animation.Append(
|
||||
modeSign.DOAnchorPos(signStart, totalTime * 0.85f)
|
||||
.SetEase(Ease.OutBounce)
|
||||
);
|
||||
sequence.WithCancellation(cts.Token);
|
||||
sequence.Play();
|
||||
|
||||
|
||||
_animation.PlayForward();
|
||||
}
|
||||
|
||||
public override void Disable(int _)
|
||||
{
|
||||
StopAnimation();
|
||||
cts = new();
|
||||
|
||||
_animation = DOTween.Sequence();
|
||||
|
||||
foreach (var frame in frames)
|
||||
{
|
||||
frame.DOSizeDelta(disabledFrameWH, frameDuration).SetEase(Ease.InCirc).WithCancellation(cts.Token);
|
||||
_animation.Join(frame.DOSizeDelta(disabledFrameWH, frameDuration).SetEase(Ease.InCirc));
|
||||
}
|
||||
|
||||
characterRect
|
||||
.DOSizeDelta(disabledCharacterWH, characterDuration)
|
||||
//.SetDelay(characterDelay)
|
||||
.SetEase(Ease.OutQuad)
|
||||
.WithCancellation(cts.Token);
|
||||
_animation.Join(
|
||||
characterRect.DOSizeDelta(disabledCharacterWH, characterDuration).SetEase(Ease.OutQuad));
|
||||
|
||||
characterImage.DOColor(disabledCharacterColor, characterDuration)
|
||||
.SetDelay(characterDelay)
|
||||
.SetEase(Ease.OutQuad)
|
||||
.WithCancellation(cts.Token);
|
||||
_animation.Insert(characterDelay,
|
||||
characterImage.DOColor(disabledCharacterColor, characterDuration).SetEase(Ease.OutQuad));
|
||||
|
||||
_animation.PlayForward();
|
||||
}
|
||||
|
||||
public override void Interact() => GameManager.Instance.TryEnterGame(gameMode);
|
||||
|
||||
private void StopAnimation()
|
||||
{
|
||||
cts?.Cancel();
|
||||
cts?.Dispose();
|
||||
if (_animation != null)
|
||||
{
|
||||
_animation.Kill();
|
||||
_animation = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user