in out circ

This commit is contained in:
Rapandrasmus 2023-10-08 11:31:19 +02:00
parent 0ac28ede0e
commit ac59780559
5 changed files with 25 additions and 14 deletions

View file

@ -562,9 +562,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
_fullRotRange: 160 _fullRotRange: 160
_spawnOffset: -2
_holdLength: 2 _holdLength: 2
_ease: 4 _ease: 22
_rotateRoot: {fileID: 2616646720197201304} _rotateRoot: {fileID: 2616646720197201304}
_gripPoint: {fileID: 2131794628642567477} _gripPoint: {fileID: 2131794628642567477}
--- !u!114 &-4645702950898394595 --- !u!114 &-4645702950898394595

View file

@ -163,7 +163,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
_fullRotRange: 160 _fullRotRange: 160
_holdLength: 1 _holdLength: 1
_ease: 4 _ease: 22
_rotateRoot: {fileID: 2068126119450832752} _rotateRoot: {fileID: 2068126119450832752}
_gripPoint: {fileID: 8286548847234487440} _gripPoint: {fileID: 8286548847234487440}
--- !u!114 &3772265357728581139 --- !u!114 &3772265357728581139

View file

@ -1934,7 +1934,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
_fullRotRange: 160 _fullRotRange: 160
_holdLength: 3 _holdLength: 3
_ease: 4 _ease: 22
_rotateRoot: {fileID: 3903953954711634507} _rotateRoot: {fileID: 3903953954711634507}
_gripPoint: {fileID: 3800820123473635694} _gripPoint: {fileID: 3800820123473635694}
--- !u!114 &3068772248330600904 --- !u!114 &3068772248330600904
@ -1964,9 +1964,9 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
_anim: {fileID: 8483464683545527156} _anim: {fileID: 8483464683545527156}
_animLength: 0.6 _animLength: 0.6785714
_beatLength: 2.5 _beatLength: 3
_ease: 4 _ease: 22
--- !u!1 &8302616130811808557 --- !u!1 &8302616130811808557
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View file

@ -21,6 +21,8 @@ namespace HeavenStudio.Games.Scripts_AnimalAcrobat
private float _halfRotRange; private float _halfRotRange;
private EasingFunction.Function _func; private EasingFunction.Function _func;
public EasingFunction.Ease Ease => _ease;
[Header("Components")] [Header("Components")]
[SerializeField] private Transform _rotateRoot; [SerializeField] private Transform _rotateRoot;
[SerializeField] private Transform _gripPoint; [SerializeField] private Transform _gripPoint;

View file

@ -88,6 +88,7 @@ namespace HeavenStudio.Games
public double length; public double length;
public float rotationDistance; public float rotationDistance;
public float rotationHeight; public float rotationHeight;
public Util.EasingFunction.Ease ease;
public double GetHoldLengthFromType() public double GetHoldLengthFromType()
{ {
@ -106,8 +107,6 @@ namespace HeavenStudio.Games
private int _animalPoolIndex = 0; private int _animalPoolIndex = 0;
private float _animalSummatedDistance = 0; private float _animalSummatedDistance = 0;
private bool _lastAnimalWasGiraffe = false; private bool _lastAnimalWasGiraffe = false;
private Util.EasingFunction.Function _funcEaseInOut;
private Util.EasingFunction.Function _funcEaseOut; private Util.EasingFunction.Function _funcEaseOut;
private double _jumpBeat = double.MaxValue; private double _jumpBeat = double.MaxValue;
@ -119,7 +118,6 @@ namespace HeavenStudio.Games
private void Awake() private void Awake()
{ {
instance = this; instance = this;
_funcEaseInOut = Util.EasingFunction.GetEasingFunction(Util.EasingFunction.Ease.EaseInOutQuad);
_funcEaseOut = Util.EasingFunction.GetEasingFunction(Util.EasingFunction.Ease.EaseOutQuad); _funcEaseOut = Util.EasingFunction.GetEasingFunction(Util.EasingFunction.Ease.EaseOutQuad);
} }
@ -214,9 +212,11 @@ namespace HeavenStudio.Games
} }
if (normalizedHold >= 0 && normalizedHold <= 1) if (normalizedHold >= 0 && normalizedHold <= 1)
{ {
float newX = _funcEaseInOut(_lastCameraX + distance, _lastCameraX + distance + currentAnimal.rotationDistance, normalizedHold); var func = Util.EasingFunction.GetEasingFunction(currentAnimal.ease);
float angle = _funcEaseInOut(0, 180, normalizedHold); float newX = func(_lastCameraX + distance, _lastCameraX + distance + currentAnimal.rotationDistance, normalizedHold);
float angle = func(0, 180, normalizedHold);
float newY = Mathf.Sin(angle * Mathf.Deg2Rad) * currentAnimal.rotationHeight; float newY = Mathf.Sin(angle * Mathf.Deg2Rad) * currentAnimal.rotationHeight;
_scroll.localPosition = new Vector3(-newX, -newY, 0); _scroll.localPosition = new Vector3(-newX, -newY, 0);
@ -328,7 +328,8 @@ namespace HeavenStudio.Games
length = 5, length = 5,
type = AnimalType.MonkeysLong, type = AnimalType.MonkeysLong,
rotationDistance = _monkeysLong.GetRotationDistance(), rotationDistance = _monkeysLong.GetRotationDistance(),
rotationHeight = _monkeysLong.GetRotationHeight() rotationHeight = _monkeysLong.GetRotationHeight(),
ease = _monkeysLong.Ease
}); });
_queuedAnimals.Add(new QueuedAnimal() _queuedAnimals.Add(new QueuedAnimal()
{ {
@ -336,7 +337,8 @@ namespace HeavenStudio.Games
length = 3, length = 3,
type = AnimalType.MonkeysShort, type = AnimalType.MonkeysShort,
rotationDistance = _monkeysShort.GetRotationDistance(), rotationDistance = _monkeysShort.GetRotationDistance(),
rotationHeight = _monkeysShort.GetRotationHeight() rotationHeight = _monkeysShort.GetRotationHeight(),
ease = _monkeysShort.Ease
}); });
continue; continue;
} }
@ -374,6 +376,14 @@ namespace HeavenStudio.Games
"animalAcrobat/monkeyLong" => _monkeysLong.GetRotationHeight(), "animalAcrobat/monkeyLong" => _monkeysLong.GetRotationHeight(),
"animalAcrobat/monkeyShort" => _monkeysShort.GetRotationHeight(), "animalAcrobat/monkeyShort" => _monkeysShort.GetRotationHeight(),
_ => throw new System.NotImplementedException() _ => throw new System.NotImplementedException()
},
ease = animal.datamodel switch
{
"animalAcrobat/elephant" => _elephant.Ease,
"animalAcrobat/giraffe" => _giraffe.Ease,
"animalAcrobat/monkeyLong" => _monkeysLong.Ease,
"animalAcrobat/monkeyShort" => _monkeysShort.Ease,
_ => throw new System.NotImplementedException()
} }
}); });
} }