TRIPLE JUMP

This commit is contained in:
Rapandrasmus 2023-12-29 23:36:14 +01:00
parent c4903e6e94
commit eea98e02af
3 changed files with 146 additions and 13 deletions

View file

@ -10,6 +10,7 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
{ {
[SerializeField] private Transform _initialPoint; [SerializeField] private Transform _initialPoint;
[SerializeField] private float _jumpHeight = 2f; [SerializeField] private float _jumpHeight = 2f;
[SerializeField] private float _jumpHeightTriple = 1f;
private Path _path; private Path _path;
private Animator _anim; private Animator _anim;
@ -33,11 +34,21 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
target = _initialPoint, target = _initialPoint,
height = _jumpHeight height = _jumpHeight
}; };
if (_game.IsTripleBeat(beat))
{
_path.positions[1] = new PathPos()
{
target = _game.GetJumperFrogPointAtBeat(beat, -1)
};
}
else
{
_path.positions[1] = new PathPos() _path.positions[1] = new PathPos()
{ {
target = _game.GetJumperPointAtBeat(beat) target = _game.GetJumperPointAtBeat(beat)
}; };
} }
}
public void StartJumping(double beat) public void StartJumping(double beat)
{ {
@ -45,7 +56,14 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
StartCoroutine(JumpCo(beat)); StartCoroutine(JumpCo(beat));
if (beat + 1 >= _game.EndBeat) return; 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 TripleJumping(double beat, bool enter)
{
StartCoroutine(JumpTripleCo(beat, enter));
if (beat + 0.5 >= _game.EndBeat) return;
_game.ScheduleInput(beat, 0.5, Minigame.InputAction_BasicPress, enter ? JustTripleExit : Just, enter ? MissTripleExit : Miss, Empty);
} }
public void Bop() public void Bop()
@ -59,17 +77,40 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
{ {
_path = new Path(); _path = new Path();
_path.positions = new PathPos[2]; _path.positions = new PathPos[2];
if (_game.IsTripleBeat(beat))
{
_path.positions[0] = new PathPos()
{
duration = 1 - (float)Conductor.instance.SecsToBeats(Minigame.justEarlyTime, Conductor.instance.GetBpmAtBeat(beat + 1)),
height = _jumpHeight,
target = _game.GetJumperFrogPointAtBeat(beat, 1)
};
}
else
{
_path.positions[0] = new PathPos() _path.positions[0] = new PathPos()
{ {
duration = 1 - (float)Conductor.instance.SecsToBeats(Minigame.justEarlyTime, Conductor.instance.GetBpmAtBeat(beat + 1)), duration = 1 - (float)Conductor.instance.SecsToBeats(Minigame.justEarlyTime, Conductor.instance.GetBpmAtBeat(beat + 1)),
height = _jumpHeight, height = _jumpHeight,
target = _game.GetJumperPointAtBeat(beat) target = _game.GetJumperPointAtBeat(beat)
}; };
}
if (_game.IsTripleBeat(beat + 1))
{
_path.positions[1] = new PathPos()
{
target = _game.GetJumperFrogPointAtBeat(beat + 1, -1)
};
}
else
{
_path.positions[1] = new PathPos() _path.positions[1] = new PathPos()
{ {
target = _game.GetJumperPointAtBeat(beat + 1) target = _game.GetJumperPointAtBeat(beat + 1)
}; };
} }
}
_anim.Play("Jump", 0, 0); _anim.Play("Jump", 0, 0);
float normalizedBeat = Conductor.instance.GetPositionFromBeat(beat, _path.positions[0].duration); float normalizedBeat = Conductor.instance.GetPositionFromBeat(beat, _path.positions[0].duration);
@ -91,6 +132,44 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
_anim.Play("Idle", 0, 0); _anim.Play("Idle", 0, 0);
} }
private IEnumerator JumpTripleCo(double beat, bool enter)
{
if (beat >= _startBeat)
{
_path = new Path();
_path.positions = new PathPos[2];
_path.positions[0] = new PathPos()
{
duration = 0.5f - (float)Conductor.instance.SecsToBeats(Minigame.justEarlyTime, Conductor.instance.GetBpmAtBeat(beat + 0.5)),
height = _jumpHeightTriple,
target = _game.GetJumperFrogPointAtBeat(beat, enter ? -1 : 0)
};
_path.positions[1] = new PathPos()
{
target = _game.GetJumperFrogPointAtBeat(beat + 0.5, enter ? 0 : 1)
};
}
_anim.Play("Jump", 0, 0);
float normalizedBeat = Conductor.instance.GetPositionFromBeat(beat, _path.positions[0].duration);
bool playedFall = false;
while (normalizedBeat < 1f)
{
transform.position = GetPathPositionFromBeat(_path, Math.Min(Conductor.instance.songPositionInBeatsAsDouble, beat + _path.positions[0].duration), beat);
if (normalizedBeat >= 0.5f && !playedFall)
{
_anim.Play("Fall", 0, 0);
playedFall = true;
}
normalizedBeat = Conductor.instance.GetPositionFromBeat(beat, _path.positions[0].duration);
yield return null;
}
_anim.Play("Idle", 0, 0);
}
private void Just(PlayerActionEvent caller, float state) private void Just(PlayerActionEvent caller, float state)
{ {
bool isTriple = _game.IsTripleBeat(caller.startBeat + caller.timer); bool isTriple = _game.IsTripleBeat(caller.startBeat + caller.timer);
@ -103,12 +182,42 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
SoundByte.PlayOneShotGame(isTriple ? "totemClimb/totemlandb" : "totemClimb/totemland"); SoundByte.PlayOneShotGame(isTriple ? "totemClimb/totemlandb" : "totemClimb/totemland");
} }
private void JustTripleEnter(PlayerActionEvent caller, float state)
{
TripleJumping(caller.startBeat + caller.timer, true);
if (state >= 1f || state <= -1f)
{
return;
}
SoundByte.PlayOneShotGame("totemClimb/totemland");
}
private void JustTripleExit(PlayerActionEvent caller, float state)
{
TripleJumping(caller.startBeat + caller.timer, false);
if (state >= 1f || state <= -1f)
{
return;
}
SoundByte.PlayOneShotGame("totemClimb/totemland");
}
private void Miss(PlayerActionEvent caller) private void Miss(PlayerActionEvent caller)
{ {
StartJumping(caller.startBeat + caller.timer); StartJumping(caller.startBeat + caller.timer);
_game.BopTotemAtBeat(caller.startBeat + caller.timer); _game.BopTotemAtBeat(caller.startBeat + caller.timer);
} }
private void MissTripleEnter(PlayerActionEvent caller)
{
TripleJumping(caller.startBeat + caller.timer, true);
}
private void MissTripleExit(PlayerActionEvent caller)
{
TripleJumping(caller.startBeat + caller.timer, false);
}
private void Empty(PlayerActionEvent caller) { } private void Empty(PlayerActionEvent caller) { }
} }
} }

View file

@ -55,8 +55,8 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
Transform spawnedFrog = Instantiate(_frogTransform, transform); Transform spawnedFrog = Instantiate(_frogTransform, transform);
spawnedFrog.transform.localPosition += new Vector3(_xDistance * (float)(beat - startBeat), _yDistance * (float)(beat - startBeat)); spawnedFrog.transform.localPosition += new Vector3(_xDistance * (float)(beat - startBeat), _yDistance * (float)(beat - startBeat));
spawnedFrog.gameObject.SetActive(true); spawnedFrog.gameObject.SetActive(true);
spawnedFrog.GetComponent<TCFrog>().beat = beat;
_frogs.Add(spawnedFrog.GetComponent<TCFrog>()); _frogs.Add(spawnedFrog.GetComponent<TCFrog>());
_frogs[i].beat = beat;
} }
} }
} }
@ -80,6 +80,25 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
return t.JumperPoint; return t.JumperPoint;
} }
public Transform GetJumperFrogPointAtBeat(double beat, int part)
{
var f = _frogs.Find(x => beat >= x.beat && beat < x.beat + 2);
if (f == null)
{
Debug.Log($"Jumper Frog Point unavaible at beat {beat}.");
return null;
}
switch (part)
{
case -1:
return f.JumperPointLeft;
case 0:
return f.JumperPointMiddle;
default:
return f.JumperPointRight;
}
}
private void Update() private void Update()
{ {
float currentScrollX = _scrollTransform.localPosition.x; float currentScrollX = _scrollTransform.localPosition.x;

View file

@ -162,6 +162,11 @@ namespace HeavenStudio.Games
return _totemManager.GetJumperPointAtBeat(beat); return _totemManager.GetJumperPointAtBeat(beat);
} }
public Transform GetJumperFrogPointAtBeat(double beat, int part)
{
return _totemManager.GetJumperFrogPointAtBeat(beat, part);
}
public void Bop(double beat, float length, double callBeat) public void Bop(double beat, float length, double callBeat)
{ {
List<BeatAction.Action> actions = new(); List<BeatAction.Action> actions = new();