Begun doing camera stuff
This commit is contained in:
parent
03249ddbcc
commit
d454ea31df
|
|
@ -931,7 +931,7 @@ Transform:
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 8794133928851332470}
|
- {fileID: 8794133928851332470}
|
||||||
m_Father: {fileID: 5840730152797502065}
|
m_Father: {fileID: 5840730152797502065}
|
||||||
m_RootOrder: 3
|
m_RootOrder: 4
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!212 &8577280407175396528
|
--- !u!212 &8577280407175396528
|
||||||
SpriteRenderer:
|
SpriteRenderer:
|
||||||
|
|
@ -1017,6 +1017,7 @@ Transform:
|
||||||
- {fileID: 2661844662320053337}
|
- {fileID: 2661844662320053337}
|
||||||
- {fileID: 4037202497222682790}
|
- {fileID: 4037202497222682790}
|
||||||
- {fileID: 4618914047223908314}
|
- {fileID: 4618914047223908314}
|
||||||
|
- {fileID: 6038557817912069913}
|
||||||
- {fileID: 4131922717252530528}
|
- {fileID: 4131922717252530528}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
|
|
@ -1040,3 +1041,37 @@ MonoBehaviour:
|
||||||
_giraffe: {fileID: 5248028064811562821, guid: 72e69b6337a6bc04f86ffcf5bcedab92, type: 3}
|
_giraffe: {fileID: 5248028064811562821, guid: 72e69b6337a6bc04f86ffcf5bcedab92, type: 3}
|
||||||
_monkeysLong: {fileID: -3114631264593203074, guid: f52ef60e472be3047bb77f54d5a3229d, type: 3}
|
_monkeysLong: {fileID: -3114631264593203074, guid: f52ef60e472be3047bb77f54d5a3229d, type: 3}
|
||||||
_monkeysShort: {fileID: 7370747047491091311, guid: 0dfca7cb5fedf0d40aa26ffd9b4595ae, type: 3}
|
_monkeysShort: {fileID: 7370747047491091311, guid: 0dfca7cb5fedf0d40aa26ffd9b4595ae, type: 3}
|
||||||
|
_scroll: {fileID: 6038557817912069913}
|
||||||
|
_jumpDistance: 8
|
||||||
|
_jumpDistanceGiraffe: 32
|
||||||
|
--- !u!1 &9154566379104488428
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 6038557817912069913}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Scroll
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &6038557817912069913
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 9154566379104488428}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 5840730152797502065}
|
||||||
|
m_RootOrder: 3
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
|
|
||||||
|
|
@ -559,23 +559,7 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 2f9ee457016acdc4eb5dbfdc03be0d6f, type: 3}
|
m_Script: {fileID: 11500000, guid: 2f9ee457016acdc4eb5dbfdc03be0d6f, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
_onInit:
|
_fullRotRange: 160
|
||||||
m_PersistentCalls:
|
|
||||||
m_Calls:
|
|
||||||
- m_Target: {fileID: -4645702950898394595}
|
|
||||||
m_TargetAssemblyTypeName: HeavenStudio.Games.Scripts_AnimalAcrobat.ObstacleInput,
|
|
||||||
Assembly-CSharp
|
|
||||||
m_MethodName: Init
|
|
||||||
m_Mode: 0
|
|
||||||
m_Arguments:
|
|
||||||
m_ObjectArgument: {fileID: 0}
|
|
||||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
|
||||||
m_IntArgument: 0
|
|
||||||
m_FloatArgument: 0
|
|
||||||
m_StringArgument:
|
|
||||||
m_BoolArgument: 0
|
|
||||||
m_CallState: 2
|
|
||||||
_fullRotRange: 120
|
|
||||||
_spawnOffset: 0
|
_spawnOffset: 0
|
||||||
_holdLength: 2
|
_holdLength: 2
|
||||||
_ease: 4
|
_ease: 4
|
||||||
|
|
|
||||||
|
|
@ -44,10 +44,15 @@ namespace HeavenStudio.Games.Scripts_AnimalAcrobat
|
||||||
|
|
||||||
public float GetRotationDistance()
|
public float GetRotationDistance()
|
||||||
{
|
{
|
||||||
float result = Mathf.Cos((_fullRotRange + 180) * Mathf.Deg2Rad) * _gripPoint.localPosition.y;
|
float result = Mathf.Cos((_fullRotRange + 180) * Mathf.Deg2Rad) * GetRotationHeight();
|
||||||
return Mathf.Abs(result * 2);
|
return Mathf.Abs(result * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float GetRotationHeight()
|
||||||
|
{
|
||||||
|
return _gripPoint.localPosition.y;
|
||||||
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
var cond = Conductor.instance;
|
var cond = Conductor.instance;
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,13 @@ namespace HeavenStudio.Games
|
||||||
[SerializeField] private AcrobatObstacle _elephant;
|
[SerializeField] private AcrobatObstacle _elephant;
|
||||||
[SerializeField] private AcrobatObstacle _giraffe, _monkeysLong, _monkeysShort;
|
[SerializeField] private AcrobatObstacle _giraffe, _monkeysLong, _monkeysShort;
|
||||||
|
|
||||||
|
[Header("Components")]
|
||||||
|
[SerializeField] private Transform _scroll;
|
||||||
|
|
||||||
[Header("Values")]
|
[Header("Values")]
|
||||||
[SerializeField] private float _jumpDistance = 8;
|
[SerializeField] private float _jumpDistance = 8;
|
||||||
|
[SerializeField] private float _jumpDistanceGiraffe = 16;
|
||||||
|
[SerializeField] private float _jumpStartCameraDistance = 4;
|
||||||
|
|
||||||
private List<AcrobatObstacle> _pooledElephants = new(), _pooledGiraffes = new(), _pooledMonkeysLong = new(), _pooledMonkeysShort = new();
|
private List<AcrobatObstacle> _pooledElephants = new(), _pooledGiraffes = new(), _pooledMonkeysLong = new(), _pooledMonkeysShort = new();
|
||||||
|
|
||||||
|
|
@ -69,6 +74,20 @@ namespace HeavenStudio.Games
|
||||||
public AnimalType type;
|
public AnimalType type;
|
||||||
public double startBeat;
|
public double startBeat;
|
||||||
public double length;
|
public double length;
|
||||||
|
public float rotationDistance;
|
||||||
|
public float rotationHeight;
|
||||||
|
|
||||||
|
public double GetHoldLengthFromType()
|
||||||
|
{
|
||||||
|
return type switch
|
||||||
|
{
|
||||||
|
AnimalType.Elephant => 2,
|
||||||
|
AnimalType.Giraffe => 4,
|
||||||
|
AnimalType.MonkeysLong => 3,
|
||||||
|
AnimalType.MonkeysShort => 1,
|
||||||
|
_ => throw new System.NotImplementedException(),
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<QueuedAnimal> _queuedAnimals = new();
|
private List<QueuedAnimal> _queuedAnimals = new();
|
||||||
|
|
@ -76,11 +95,18 @@ namespace HeavenStudio.Games
|
||||||
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 _funcEaseIn;
|
||||||
|
private Util.EasingFunction.Function _funcEaseOut;
|
||||||
|
|
||||||
public static AnimalAcrobat instance;
|
public static AnimalAcrobat instance;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
instance = this;
|
instance = this;
|
||||||
|
_funcEaseInOut = Util.EasingFunction.GetEasingFunction(Util.EasingFunction.Ease.EaseInOutQuad);
|
||||||
|
_funcEaseIn = Util.EasingFunction.GetEasingFunction(Util.EasingFunction.Ease.EaseInQuad);
|
||||||
|
_funcEaseOut = Util.EasingFunction.GetEasingFunction(Util.EasingFunction.Ease.EaseOutQuad);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
|
|
@ -88,6 +114,53 @@ namespace HeavenStudio.Games
|
||||||
var cond = Conductor.instance;
|
var cond = Conductor.instance;
|
||||||
if (!cond.isPlaying) return;
|
if (!cond.isPlaying) return;
|
||||||
AnimalPoolUpdate(cond);
|
AnimalPoolUpdate(cond);
|
||||||
|
CameraUpdate(cond);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int _animalCameraIndex = 0;
|
||||||
|
private float _lastCameraX = 0;
|
||||||
|
private double _cameraHoldTime = 1;
|
||||||
|
|
||||||
|
private void CameraUpdate(Conductor cond)
|
||||||
|
{
|
||||||
|
if (_animalCameraIndex >= _queuedAnimals.Count || cond.songPositionInBeatsAsDouble < _queuedAnimals[0].startBeat - 1) return;
|
||||||
|
|
||||||
|
var currentAnimal = _queuedAnimals[_animalCameraIndex];
|
||||||
|
|
||||||
|
float distance = (_animalCameraIndex == 0) ? _jumpStartCameraDistance : _jumpDistance;
|
||||||
|
|
||||||
|
float normalizedHold = cond.GetPositionFromBeat(currentAnimal.startBeat, currentAnimal.GetHoldLengthFromType());
|
||||||
|
|
||||||
|
if (normalizedHold < 0)
|
||||||
|
{
|
||||||
|
float normalizedTravel = cond.GetPositionFromBeat(currentAnimal.startBeat - _cameraHoldTime, _cameraHoldTime);
|
||||||
|
|
||||||
|
float newX = Mathf.Lerp(_lastCameraX, _lastCameraX + distance, normalizedTravel);
|
||||||
|
_scroll.localPosition = new Vector3(-newX, 0, 0);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (normalizedHold >= 0 && normalizedHold <= 1)
|
||||||
|
{
|
||||||
|
float newX = _funcEaseInOut(_lastCameraX + distance, _lastCameraX + distance + currentAnimal.rotationDistance, normalizedHold);
|
||||||
|
float newY = 0;
|
||||||
|
if (normalizedHold <= 0.5)
|
||||||
|
{
|
||||||
|
float normalizedHoldIn = cond.GetPositionFromBeat(currentAnimal.startBeat, currentAnimal.GetHoldLengthFromType() * 0.5);
|
||||||
|
newY = _funcEaseIn(0, -currentAnimal.rotationHeight, Mathf.Clamp01(normalizedHoldIn));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float normalizedHoldOut = cond.GetPositionFromBeat(currentAnimal.startBeat + (currentAnimal.GetHoldLengthFromType() * 0.5), currentAnimal.GetHoldLengthFromType() * 0.5);
|
||||||
|
newY = _funcEaseOut(-currentAnimal.rotationHeight, 0, Mathf.Clamp01(normalizedHoldOut));
|
||||||
|
}
|
||||||
|
|
||||||
|
_scroll.localPosition = new Vector3(-newX, newY, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_cameraHoldTime = (currentAnimal.type == AnimalType.Giraffe) ? 4 : 2;
|
||||||
|
_lastCameraX += distance + currentAnimal.rotationDistance;
|
||||||
|
_animalCameraIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AnimalPoolUpdate(Conductor cond)
|
private void AnimalPoolUpdate(Conductor cond)
|
||||||
|
|
@ -135,7 +208,8 @@ namespace HeavenStudio.Games
|
||||||
animal.Init(currentAnimal.startBeat, expBeat, _lastAnimalWasGiraffe);
|
animal.Init(currentAnimal.startBeat, expBeat, _lastAnimalWasGiraffe);
|
||||||
|
|
||||||
animal.transform.localPosition = new Vector3(_animalSummatedDistance, 0, 0);
|
animal.transform.localPosition = new Vector3(_animalSummatedDistance, 0, 0);
|
||||||
_animalSummatedDistance += animal.GetRotationDistance() + _jumpDistance;
|
|
||||||
|
_animalSummatedDistance += animal.GetRotationDistance() + ((currentAnimal.type == AnimalType.Giraffe) ? _jumpDistanceGiraffe : _jumpDistance);
|
||||||
_lastAnimalWasGiraffe = currentAnimal.type == AnimalType.Giraffe;
|
_lastAnimalWasGiraffe = currentAnimal.type == AnimalType.Giraffe;
|
||||||
|
|
||||||
_animalPoolIndex++;
|
_animalPoolIndex++;
|
||||||
|
|
@ -155,10 +229,10 @@ namespace HeavenStudio.Games
|
||||||
{
|
{
|
||||||
for (int i = 0; i < POOL_NUMBER; i++)
|
for (int i = 0; i < POOL_NUMBER; i++)
|
||||||
{
|
{
|
||||||
_pooledElephants.Add(Instantiate(_elephant, transform));
|
_pooledElephants.Add(Instantiate(_elephant, _scroll));
|
||||||
_pooledGiraffes.Add(Instantiate(_giraffe, transform));
|
_pooledGiraffes.Add(Instantiate(_giraffe, _scroll));
|
||||||
_pooledMonkeysLong.Add(Instantiate(_monkeysLong, transform));
|
_pooledMonkeysLong.Add(Instantiate(_monkeysLong, _scroll));
|
||||||
_pooledMonkeysShort.Add(Instantiate(_monkeysShort, transform));
|
_pooledMonkeysShort.Add(Instantiate(_monkeysShort, _scroll));
|
||||||
}
|
}
|
||||||
|
|
||||||
var allGameSwitches = EventCaller.GetAllInGameManagerList("gameManager", new string[] { "switchGame" }).FindAll(x => x.beat > beat);
|
var allGameSwitches = EventCaller.GetAllInGameManagerList("gameManager", new string[] { "switchGame" }).FindAll(x => x.beat > beat);
|
||||||
|
|
@ -170,6 +244,7 @@ namespace HeavenStudio.Games
|
||||||
"elephant", "giraffe", "monkeys", "monkeyLong", "monkeyShort"
|
"elephant", "giraffe", "monkeys", "monkeyLong", "monkeyShort"
|
||||||
}).FindAll(x => x.beat >= beat && x.beat < nextGameSwitchBeat);
|
}).FindAll(x => x.beat >= beat && x.beat < nextGameSwitchBeat);
|
||||||
if (allAnimals.Count == 0) return;
|
if (allAnimals.Count == 0) return;
|
||||||
|
allAnimals.Sort((x, y) => x.beat.CompareTo(y.beat));
|
||||||
|
|
||||||
double goodBeat = allAnimals[0].beat;
|
double goodBeat = allAnimals[0].beat;
|
||||||
for (int i = 0; i < allAnimals.Count; i++)
|
for (int i = 0; i < allAnimals.Count; i++)
|
||||||
|
|
@ -185,12 +260,16 @@ namespace HeavenStudio.Games
|
||||||
startBeat = animal.beat,
|
startBeat = animal.beat,
|
||||||
length = 5,
|
length = 5,
|
||||||
type = AnimalType.MonkeysLong,
|
type = AnimalType.MonkeysLong,
|
||||||
|
rotationDistance = _monkeysLong.GetRotationDistance(),
|
||||||
|
rotationHeight = _monkeysLong.GetRotationHeight()
|
||||||
});
|
});
|
||||||
_queuedAnimals.Add(new QueuedAnimal()
|
_queuedAnimals.Add(new QueuedAnimal()
|
||||||
{
|
{
|
||||||
startBeat = animal.beat + 5,
|
startBeat = animal.beat + 5,
|
||||||
length = 3,
|
length = 3,
|
||||||
type = AnimalType.MonkeysShort,
|
type = AnimalType.MonkeysShort,
|
||||||
|
rotationDistance = _monkeysShort.GetRotationDistance(),
|
||||||
|
rotationHeight = _monkeysShort.GetRotationHeight()
|
||||||
});
|
});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -213,16 +292,33 @@ namespace HeavenStudio.Games
|
||||||
"animalAcrobat/monkeyShort" => AnimalType.MonkeysShort,
|
"animalAcrobat/monkeyShort" => AnimalType.MonkeysShort,
|
||||||
_ => throw new System.NotImplementedException()
|
_ => throw new System.NotImplementedException()
|
||||||
},
|
},
|
||||||
|
rotationDistance = animal.datamodel switch
|
||||||
|
{
|
||||||
|
"animalAcrobat/elephant" => _elephant.GetRotationDistance(),
|
||||||
|
"animalAcrobat/giraffe" => _giraffe.GetRotationDistance(),
|
||||||
|
"animalAcrobat/monkeyLong" => _monkeysLong.GetRotationDistance(),
|
||||||
|
"animalAcrobat/monkeyShort" => _monkeysShort.GetRotationDistance(),
|
||||||
|
_ => throw new System.NotImplementedException()
|
||||||
|
},
|
||||||
|
rotationHeight = animal.datamodel switch
|
||||||
|
{
|
||||||
|
"animalAcrobat/elephant" => _elephant.GetRotationHeight(),
|
||||||
|
"animalAcrobat/giraffe" => _giraffe.GetRotationHeight(),
|
||||||
|
"animalAcrobat/monkeyLong" => _monkeysLong.GetRotationHeight(),
|
||||||
|
"animalAcrobat/monkeyShort" => _monkeysShort.GetRotationHeight(),
|
||||||
|
_ => throw new System.NotImplementedException()
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_queuedAnimals.Count > 0)
|
if (_queuedAnimals.Count > 0)
|
||||||
{
|
{
|
||||||
_queuedAnimals.Sort((x, y) => x.startBeat.CompareTo(y.startBeat));
|
|
||||||
for (int i = 0; i < POOL_NUMBER; i++)
|
for (int i = 0; i < POOL_NUMBER; i++)
|
||||||
{
|
{
|
||||||
BakeNextAvailableAnimal();
|
BakeNextAvailableAnimal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SoundByte.PlayOneShotGame("animalAcrobat/start", _queuedAnimals[0].startBeat - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ namespace HeavenStudio.Games.Scripts_AnimalAcrobat
|
||||||
|
|
||||||
private void OnDestroy()
|
private void OnDestroy()
|
||||||
{
|
{
|
||||||
if (_drumRollSound != null) _drumRollSound.Stop();
|
if (_drumRollSound != null) _drumRollSound.KillLoop(0.587);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Init(double beat, bool beforeGiraffe)
|
public void Init(double beat, bool beforeGiraffe)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue