initial jump
This commit is contained in:
parent
e26406b72d
commit
188533a05e
|
|
@ -524,7 +524,7 @@ MonoBehaviour:
|
|||
_monkeysLong: {fileID: -3114631264593203074, guid: f52ef60e472be3047bb77f54d5a3229d, type: 3}
|
||||
_monkeysShort: {fileID: 7370747047491091311, guid: 0dfca7cb5fedf0d40aa26ffd9b4595ae, type: 3}
|
||||
_scroll: {fileID: 6038557817912069913}
|
||||
_playerMonkeyAnim: {fileID: 1240570777207442752}
|
||||
_playerMonkey: {fileID: 1075392245553999283}
|
||||
_jumpDistance: 8
|
||||
_jumpDistanceGiraffe: 32
|
||||
_jumpStartCameraDistance: 3
|
||||
|
|
@ -620,13 +620,29 @@ PrefabInstance:
|
|||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 8c681a700cd16784580f97e7f10a53e6, type: 3}
|
||||
--- !u!95 &1240570777207442752 stripped
|
||||
Animator:
|
||||
m_CorrespondingSourceObject: {fileID: 6945261984245565766, guid: 8c681a700cd16784580f97e7f10a53e6, type: 3}
|
||||
m_PrefabInstance: {fileID: 8166682498639938566}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!4 &2661844662320053337 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 6171382744519440479, guid: 8c681a700cd16784580f97e7f10a53e6, type: 3}
|
||||
m_PrefabInstance: {fileID: 8166682498639938566}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &5719573208726547716 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 4482739629151873282, guid: 8c681a700cd16784580f97e7f10a53e6, type: 3}
|
||||
m_PrefabInstance: {fileID: 8166682498639938566}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &1075392245553999283
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5719573208726547716}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 9018ffa2d40d7b841a140a5eb406d5e6, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_jumpDistance: 8
|
||||
_jumpHeight: 2
|
||||
_jumpDistanceGiraffe: 32
|
||||
_jumpHeightGiraffe: 8
|
||||
|
|
|
|||
76
Assets/Scripts/Games/AnimalAcrobat/AcrobatPlayer.cs
Normal file
76
Assets/Scripts/Games/AnimalAcrobat/AcrobatPlayer.cs
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
using HeavenStudio.Util;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_AnimalAcrobat
|
||||
{
|
||||
public class AcrobatPlayer : SuperCurveObject
|
||||
{
|
||||
[Header("Values")]
|
||||
[SerializeField] private float _jumpDistance = 8f;
|
||||
[SerializeField] private float _jumpHeight = 4f;
|
||||
[SerializeField] private float _jumpDistanceGiraffe = 32f;
|
||||
[SerializeField] private float _jumpHeightGiraffe = 8f;
|
||||
private Animator _anim;
|
||||
private Path _path;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_anim = GetComponent<Animator>();
|
||||
_path = new Path()
|
||||
{
|
||||
positions = new PathPos[2]
|
||||
};
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
StopAllCoroutines();
|
||||
}
|
||||
|
||||
public void Bop()
|
||||
{
|
||||
_anim.DoScaledAnimationAsync("PlayerBop", 0.5f);
|
||||
}
|
||||
|
||||
public void InitialJump(double beat)
|
||||
{
|
||||
StartCoroutine(InitialJumpCo(beat));
|
||||
}
|
||||
|
||||
private IEnumerator InitialJumpCo(double beat)
|
||||
{
|
||||
var cond = Conductor.instance;
|
||||
yield return new WaitUntil(() => cond.songPositionInBeatsAsDouble >= beat);
|
||||
_anim.DoScaledAnimationAsync("PlayerJump", 0.5f);
|
||||
Jump(beat, 1, transform.localPosition.x, _jumpDistance, _jumpHeight, transform.localPosition.y);
|
||||
}
|
||||
|
||||
private void Jump(double beat, float length, float startPoint, float distance, float height, float restY)
|
||||
{
|
||||
StartCoroutine(JumpCo(beat, length, startPoint, distance, height, restY));
|
||||
}
|
||||
|
||||
private IEnumerator JumpCo(double beat, float length, float startPoint, float distance, float height, float restY)
|
||||
{
|
||||
var cond = Conductor.instance;
|
||||
_path.positions[0] = new PathPos()
|
||||
{
|
||||
pos = new Vector3(startPoint, restY),
|
||||
height = height,
|
||||
duration = length
|
||||
};
|
||||
_path.positions[1] = new PathPos()
|
||||
{
|
||||
pos = new Vector3(startPoint + distance, restY),
|
||||
};
|
||||
while (true)
|
||||
{
|
||||
transform.localPosition = GetPathPositionFromBeat(_path, cond.songPositionInBeatsAsDouble, beat);
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Scripts/Games/AnimalAcrobat/AcrobatPlayer.cs.meta
Normal file
11
Assets/Scripts/Games/AnimalAcrobat/AcrobatPlayer.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9018ffa2d40d7b841a140a5eb406d5e6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -62,7 +62,7 @@ namespace HeavenStudio.Games
|
|||
|
||||
[Header("Components")]
|
||||
[SerializeField] private Transform _scroll;
|
||||
[SerializeField] private Animator _playerMonkeyAnim;
|
||||
[SerializeField] private AcrobatPlayer _playerMonkey;
|
||||
|
||||
[Header("Values")]
|
||||
[SerializeField] private float _jumpDistance = 8;
|
||||
|
|
@ -110,6 +110,8 @@ namespace HeavenStudio.Games
|
|||
private Util.EasingFunction.Function _funcEaseOut;
|
||||
private Util.EasingFunction.Function _funcSharp;
|
||||
|
||||
private double _jumpBeat = double.MaxValue;
|
||||
|
||||
public static AnimalAcrobat instance;
|
||||
|
||||
private void Awake()
|
||||
|
|
@ -128,20 +130,24 @@ namespace HeavenStudio.Games
|
|||
CameraUpdate(cond);
|
||||
}
|
||||
|
||||
public void PlayerSetActive(bool active)
|
||||
{
|
||||
_playerMonkey.gameObject.SetActive(active);
|
||||
}
|
||||
|
||||
public void Bop(double beat, float length)
|
||||
{
|
||||
if (!_playerMonkeyAnim.gameObject.activeSelf) return;
|
||||
|
||||
List<BeatAction.Action> actions = new();
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
if (beat + i >= _jumpBeat) break;
|
||||
actions.Add(new BeatAction.Action(beat + i, delegate
|
||||
{
|
||||
_playerMonkeyAnim.DoScaledAnimationAsync("PlayerBop", 0.5f);
|
||||
_playerMonkey.Bop();
|
||||
}));
|
||||
}
|
||||
|
||||
BeatAction.New(this, actions);
|
||||
if (actions.Count > 0) BeatAction.New(this, actions);
|
||||
}
|
||||
|
||||
private int _animalCameraIndex = 0;
|
||||
|
|
@ -356,7 +362,9 @@ namespace HeavenStudio.Games
|
|||
BakeNextAvailableAnimal();
|
||||
}
|
||||
|
||||
if (_queuedAnimals[0].startBeat - 1 > beat) SoundByte.PlayOneShotGame("animalAcrobat/start", _queuedAnimals[0].startBeat - 1);
|
||||
_jumpBeat = _queuedAnimals[0].startBeat - 1;
|
||||
if (_queuedAnimals[0].startBeat - 1 > beat) SoundByte.PlayOneShotGame("animalAcrobat/start", _jumpBeat);
|
||||
_playerMonkey.InitialJump(_jumpBeat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,9 +43,11 @@ namespace HeavenStudio.Games.Scripts_AnimalAcrobat
|
|||
{
|
||||
SoundByte.PlayOneShotGame("animalAcrobat/catch");
|
||||
_monkey.gameObject.SetActive(true);
|
||||
_monkey.DoScaledAnimationAsync("PlayerHang", 0.5f);
|
||||
_monkey.DoScaledAnimationAsync("PlayerHang", 0.75f);
|
||||
_game.PlayerSetActive(false);
|
||||
BeatAction.New(this, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(0, delegate {}),
|
||||
new BeatAction.Action(caller.startBeat + caller.timer + 2, delegate
|
||||
{
|
||||
_monkey.DoScaledAnimationAsync("PlayerHanging", 0.5f);
|
||||
|
|
@ -57,9 +59,11 @@ namespace HeavenStudio.Games.Scripts_AnimalAcrobat
|
|||
{
|
||||
SoundByte.PlayOneShotGame("animalAcrobat/giraffeCatch");
|
||||
_monkey.gameObject.SetActive(true);
|
||||
_monkey.DoScaledAnimationAsync("PlayerHang", 0.5f);
|
||||
_monkey.DoScaledAnimationAsync("PlayerHang", 0.75f);
|
||||
_game.PlayerSetActive(false);
|
||||
BeatAction.New(this, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(0, delegate {}),
|
||||
new BeatAction.Action(caller.startBeat + caller.timer + 2, delegate
|
||||
{
|
||||
_monkey.DoScaledAnimationAsync("PlayerHanging", 0.5f);
|
||||
|
|
|
|||
|
|
@ -38,9 +38,11 @@ namespace HeavenStudio.Games.Scripts_AnimalAcrobat
|
|||
{
|
||||
SoundByte.PlayOneShotGame("animalAcrobat/catch");
|
||||
_monkey.gameObject.SetActive(true);
|
||||
_monkey.DoScaledAnimationAsync("PlayerHang", 0.5f);
|
||||
_monkey.DoScaledAnimationAsync("PlayerHang", 0.75f);
|
||||
_game.PlayerSetActive(false);
|
||||
BeatAction.New(this, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(0, delegate {}),
|
||||
new BeatAction.Action(caller.startBeat + caller.timer + (_holdLength * 0.5), delegate
|
||||
{
|
||||
_monkey.DoScaledAnimationAsync("PlayerHanging", 0.5f);
|
||||
|
|
@ -52,9 +54,11 @@ namespace HeavenStudio.Games.Scripts_AnimalAcrobat
|
|||
{
|
||||
SoundByte.PlayOneShotGame("animalAcrobat/giraffeCatch");
|
||||
_monkey.gameObject.SetActive(true);
|
||||
_monkey.DoScaledAnimationAsync("PlayerHang", 0.5f);
|
||||
_monkey.DoScaledAnimationAsync("PlayerHang", 0.75f);
|
||||
_game.PlayerSetActive(false);
|
||||
BeatAction.New(this, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(0, delegate {}),
|
||||
new BeatAction.Action(caller.startBeat + caller.timer + (_holdLength * 0.5), delegate
|
||||
{
|
||||
_monkey.DoScaledAnimationAsync("PlayerHanging", 0.5f);
|
||||
|
|
|
|||
Loading…
Reference in a new issue