triple proto

This commit is contained in:
Rapandrasmus 2023-12-27 17:56:49 +01:00
parent 9de59c357f
commit 80961f7137
16 changed files with 101 additions and 34 deletions

View file

@ -795,6 +795,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
_totemTransform: {fileID: 2892683027369623692}
_frogTransform: {fileID: 5749667637740173319}
_xDistance: 3.838
_yDistance: 1.45
_totemAmount: 12
@ -2213,6 +2214,8 @@ MonoBehaviour:
offset: {x: 0, y: 0, z: 0}
_jumpDistanceX: 3.838
_jumpDistanceY: 1.45
_jumpDistanceSmallX: 1.919
_jumpDistanceSmallY: 0.725
_jumpOffsetY: 0.1
_jumpHeight: 2
--- !u!95 &7450811870195608846

Binary file not shown.

View file

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: b5b7c591a7c8c1f4cb53eb5153b33033
guid: 02b778489dea902468a7c8d98f34ea78
AudioImporter:
externalObjects: {}
serializedVersion: 6

Binary file not shown.

View file

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 0e89e71edcbeb794083ce7ac4f217b27
guid: baeec70ef00e0bd418c62054725d7c2a
AudioImporter:
externalObjects: {}
serializedVersion: 6

View file

@ -1,22 +0,0 @@
fileFormatVersion: 2
guid: 4e6227f24ca07b74bbf00ec321a0967e
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 6e3f859a92751884abdd001657e7a3d5
guid: 2b1e0837efb91884d9c8ef57e4cf4266
AudioImporter:
externalObjects: {}
serializedVersion: 6

View file

@ -10,6 +10,8 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
{
[SerializeField] private float _jumpDistanceX;
[SerializeField] private float _jumpDistanceY;
[SerializeField] private float _jumpDistanceSmallX;
[SerializeField] private float _jumpDistanceSmallY;
[SerializeField] private float _jumpOffsetY;
[SerializeField] private float _jumpHeight = 2f;
@ -35,11 +37,20 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
};
}
public void StartJumping(double beat)
public void StartJumping(double beat, bool inTriple = false)
{
StartCoroutine(JumpCo(beat));
bool nextIsTriple = _game.IsTripleBeat(beat + 1);
StartCoroutine(JumpCo(beat, 1f, nextIsTriple && !inTriple));
if (beat + 1 >= _game.EndBeat) return;
_game.ScheduleInput(beat, 1, Minigame.InputAction_BasicPress, Just, Miss, Empty);
_game.ScheduleInput(beat, 1, Minigame.InputAction_BasicPress, nextIsTriple ? JustTripleEnter : Just, nextIsTriple ? MissTripleEnter : Miss, Empty);
}
public void StartTripleJumping(double beat, bool exit)
{
StartCoroutine(JumpCo(beat, 0.5f, true));
if (beat + 0.5 >= _game.EndBeat) return;
_game.ScheduleInput(beat, 0.5, Minigame.InputAction_BasicPress, exit ? Just : JustTripleExit, exit ? Miss : MissTripleExit, Empty);
}
public void Bop()
@ -47,15 +58,15 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
_anim.DoScaledAnimationAsync("Bop", 0.5f);
}
private IEnumerator JumpCo(double beat)
private IEnumerator JumpCo(double beat, float length = 1f, bool small = false)
{
_path.positions[0].duration = 1 - (float)Conductor.instance.SecsToBeats(Minigame.justEarlyTime, Conductor.instance.GetBpmAtBeat(beat + 1));
_path.positions[0].duration = length - (float)Conductor.instance.SecsToBeats(Minigame.justEarlyTime, Conductor.instance.GetBpmAtBeat(beat + length));
_anim.Play("Jump", 0, 0);
float normalizedBeat = Conductor.instance.GetPositionFromBeat(beat, _path.positions[0].duration);
bool playedFall = false;
while(normalizedBeat < 1)
while(normalizedBeat < 1f)
{
transform.localPosition = GetPathPositionFromBeat(_path, Math.Min(Conductor.instance.songPositionInBeatsAsDouble, beat + _path.positions[0].duration), beat);
@ -68,19 +79,40 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
normalizedBeat = Conductor.instance.GetPositionFromBeat(beat, _path.positions[0].duration);
yield return null;
}
_path.positions[0].pos += new Vector3(_jumpDistanceX, _jumpDistanceY);
_path.positions[1].pos += new Vector3(_jumpDistanceX, _jumpDistanceY);
_path.positions[0].pos += small ? new Vector3(_jumpDistanceSmallX, _jumpDistanceSmallY) : new Vector3(_jumpDistanceX, _jumpDistanceY);
_path.positions[1].pos += small ? new Vector3(_jumpDistanceSmallX, _jumpDistanceSmallY) : new Vector3(_jumpDistanceX, _jumpDistanceY);
_anim.Play("Idle", 0, 0);
}
private void Just(PlayerActionEvent caller, float state)
{
StartJumping(caller.startBeat + caller.timer);
bool isTriple = _game.IsTripleBeat(caller.startBeat + caller.timer);
StartJumping(caller.startBeat + caller.timer, isTriple);
_game.BopTotemAtBeat(caller.startBeat + caller.timer);
if (state >= 1f || state <= -1f)
{
return;
}
SoundByte.PlayOneShotGame(isTriple ? "totemClimb/totemlandb" : "totemClimb/totemland");
}
private void JustTripleEnter(PlayerActionEvent caller, float state)
{
StartTripleJumping(caller.startBeat + caller.timer, false);
if (state >= 1f || state <= -1f)
{
return;
}
SoundByte.PlayOneShotGame("totemClimb/totemland");
}
private void JustTripleExit(PlayerActionEvent caller, float state)
{
StartTripleJumping(caller.startBeat + caller.timer, true);
if (state >= 1f || state <= -1f)
{
return;
}
SoundByte.PlayOneShotGame("totemClimb/totemland");
}
@ -90,6 +122,16 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
_game.BopTotemAtBeat(caller.startBeat + caller.timer);
}
private void MissTripleEnter(PlayerActionEvent caller)
{
StartTripleJumping(caller.startBeat + caller.timer, false);
}
private void MissTripleExit(PlayerActionEvent caller)
{
StartTripleJumping(caller.startBeat + caller.timer, true);
}
private void Empty(PlayerActionEvent caller) { }
}
}

View file

@ -8,6 +8,7 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
public class TCTotemManager : MonoBehaviour
{
[SerializeField] private Transform _totemTransform;
[SerializeField] private Transform _frogTransform;
[SerializeField] private float _xDistance;
[SerializeField] private float _yDistance;
[SerializeField] private int _totemAmount = 12;
@ -16,6 +17,7 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
private float _totemStartX;
private float _totemStartY;
private List<Totem> _totems = new();
private List<Frog> _frogs = new();
private int _totemIndex = 0;
private TotemClimb _game;
@ -34,6 +36,22 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
}
}
private class Frog
{
public double beat;
public Transform transform;
public Animator anim, anim1, anim2;
public Frog(Transform mTransform, Animator mAnim, Animator mAnim1, Animator mAnim2, double mBeat)
{
transform = mTransform;
anim = mAnim;
anim1 = mAnim1;
anim2 = mAnim2;
beat = mBeat;
}
}
private void Awake()
{
_game = TotemClimb.instance;
@ -58,6 +76,18 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
_totems[i].beat = startBeat + i;
_totems[i].transform.gameObject.SetActive(_totems[i].beat - 1 < _game.EndBeat && !_game.IsTripleBeat(_totems[i].beat));
}
foreach (var e in _game._tripleEvents)
{
for (int i = 0; i < e.length; i += 2)
{
double beat = e.beat + i;
Transform spawnedFrog = Instantiate(_frogTransform, transform);
spawnedFrog.transform.localPosition += new Vector3(_xDistance * (float)(beat - startBeat), _yDistance * (float)(beat - startBeat));
spawnedFrog.gameObject.SetActive(true);
_frogs.Add(new Frog(spawnedFrog, null, null, null, beat));
}
}
}
public void BopTotemAtBeat(double beat)

View file

@ -22,6 +22,7 @@ namespace HeavenStudio.Games.Loaders
},
new("triple", "Triple Jumping")
{
preFunction = delegate { TotemClimb.TripleJumpSound(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); },
defaultLength = 2f,
resizable = true
},
@ -196,6 +197,19 @@ namespace HeavenStudio.Games
if (_tripleEvents.Count == 0) return false;
return _tripleEvents.Find(x => beat >= x.beat && beat < x.beat + x.length) != null;
}
public static void TripleJumpSound(double beat, float length)
{
length = Mathf.Max(length, 2f);
MultiSound.Play(new MultiSound.Sound[]
{
new("totemClimb/beatchange", beat - 2),
new("totemClimb/beatchange", beat - 1.5f),
new("totemClimb/beatchange", beat - 1f),
new("totemClimb/beatchange", beat + length - 2),
new("totemClimb/beatchange", beat + length - 1),
}, true);
}
}
}