functional dragon
This commit is contained in:
parent
16c15b6531
commit
e3c06aa582
|
|
@ -2875,6 +2875,7 @@ MonoBehaviour:
|
|||
_initialPoint: {fileID: 7302560279692477592}
|
||||
_jumpHeight: 2
|
||||
_jumpHeightTriple: 1
|
||||
_jumpHighHeight: 4
|
||||
--- !u!95 &7450811870195608846
|
||||
Animator:
|
||||
serializedVersion: 5
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using UnityEngine;
|
||||
using System;
|
||||
using HeavenStudio.Util;
|
||||
using static UnityEngine.GraphicsBuffer;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_TotemClimb
|
||||
{
|
||||
|
|
@ -11,6 +12,7 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
|
|||
[SerializeField] private Transform _initialPoint;
|
||||
[SerializeField] private float _jumpHeight = 2f;
|
||||
[SerializeField] private float _jumpHeightTriple = 1f;
|
||||
[SerializeField] private float _jumpHighHeight = 6f;
|
||||
|
||||
private Path _path;
|
||||
private Animator _anim;
|
||||
|
|
@ -53,10 +55,29 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
|
|||
public void StartJumping(double beat, bool miss = false)
|
||||
{
|
||||
bool nextIsTriple = _game.IsTripleBeat(beat + 1);
|
||||
bool nextIsHigh = _game.IsHighBeat(beat + 1);
|
||||
StartCoroutine(JumpCo(beat, miss));
|
||||
if (beat + 1 >= _game.EndBeat) return;
|
||||
|
||||
_game.ScheduleInput(beat, 1, Minigame.InputAction_BasicPress, nextIsTriple ? JustTripleEnter : Just, nextIsTriple ? MissTripleEnter : Miss, Empty);
|
||||
if (nextIsHigh)
|
||||
{
|
||||
_game.ScheduleInput(beat, 1, Minigame.InputAction_BasicPress, JustHold, Empty, Empty);
|
||||
_game.ScheduleInput(beat, 3, Minigame.InputAction_FlickRelease, JustRelease, MissRelease, Empty);
|
||||
}
|
||||
else _game.ScheduleInput(beat, 1, Minigame.InputAction_BasicPress, nextIsTriple ? JustTripleEnter : Just, nextIsTriple ? MissTripleEnter : Miss, Empty);
|
||||
}
|
||||
|
||||
public void HighJump(double beat, bool miss)
|
||||
{
|
||||
bool nextIsTriple = _game.IsTripleBeat(beat + 2);
|
||||
bool nextIsHigh = _game.IsHighBeat(beat + 2);
|
||||
StartCoroutine(JumpHighCo(beat, miss));
|
||||
if (beat + 2 >= _game.EndBeat) return;
|
||||
if (nextIsHigh)
|
||||
{
|
||||
_game.ScheduleInput(beat, 2, Minigame.InputAction_BasicPress, JustHold, Empty, Empty);
|
||||
_game.ScheduleInput(beat, 5, Minigame.InputAction_FlickRelease, JustRelease, MissRelease, Empty);
|
||||
}
|
||||
else _game.ScheduleInput(beat, 2, Minigame.InputAction_BasicPress, nextIsTriple ? JustTripleEnter : Just, nextIsTriple ? MissTripleEnter : Miss, Empty);
|
||||
}
|
||||
|
||||
public void TripleJumping(double beat, bool enter, bool miss = false)
|
||||
|
|
@ -77,37 +98,25 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
|
|||
{
|
||||
_path = new Path();
|
||||
_path.positions = new PathPos[2];
|
||||
if (_game.IsTripleBeat(beat))
|
||||
_path.positions[0] = new PathPos()
|
||||
{
|
||||
_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()
|
||||
{
|
||||
duration = 1 - (float)Conductor.instance.SecsToBeats(Minigame.justEarlyTime, Conductor.instance.GetBpmAtBeat(beat + 1)),
|
||||
height = _jumpHeight,
|
||||
target = _game.GetJumperPointAtBeat(beat)
|
||||
};
|
||||
}
|
||||
duration = 1 - (float)Conductor.instance.SecsToBeats(Minigame.justEarlyTime, Conductor.instance.GetBpmAtBeat(beat + 1)),
|
||||
height = _jumpHeight,
|
||||
target = _game.IsTripleBeat(beat) ? _game.GetJumperFrogPointAtBeat(beat, 1) : _game.GetJumperPointAtBeat(beat)
|
||||
};
|
||||
|
||||
if (_game.IsTripleBeat(beat + 1))
|
||||
if (_game.IsHighBeat(beat + 1))
|
||||
{
|
||||
_path.positions[1] = new PathPos()
|
||||
{
|
||||
target = _game.GetJumperFrogPointAtBeat(beat + 1, -1)
|
||||
target = _game.GetDragonPointAtBeat(beat + 1)
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
_path.positions[1] = new PathPos()
|
||||
{
|
||||
target = _game.GetJumperPointAtBeat(beat + 1)
|
||||
target = _game.IsTripleBeat(beat + 1) ? _game.GetJumperFrogPointAtBeat(beat + 1, -1) : _game.GetJumperPointAtBeat(beat + 1)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -172,6 +181,68 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
|
|||
_anim.Play("Idle", 0, 0);
|
||||
}
|
||||
|
||||
private IEnumerator JumpHighCo(double beat, bool miss)
|
||||
{
|
||||
if (beat >= _startBeat)
|
||||
{
|
||||
_path = new Path();
|
||||
_path.positions = new PathPos[2];
|
||||
_path.positions[0] = new PathPos()
|
||||
{
|
||||
duration = 2 - (float)Conductor.instance.SecsToBeats(Minigame.justEarlyTime, Conductor.instance.GetBpmAtBeat(beat + 2)),
|
||||
height = _jumpHighHeight,
|
||||
target = _game.GetDragonPointAtBeat(beat)
|
||||
};
|
||||
|
||||
if (_game.IsHighBeat(beat + 2))
|
||||
{
|
||||
_path.positions[1] = new PathPos()
|
||||
{
|
||||
target = _game.GetDragonPointAtBeat(beat + 2)
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
_path.positions[1] = new PathPos()
|
||||
{
|
||||
target = _game.IsTripleBeat(beat + 2) ? _game.GetJumperFrogPointAtBeat(beat + 2, -1) : _game.GetJumperPointAtBeat(beat + 2)
|
||||
};
|
||||
}
|
||||
}
|
||||
if (!miss) _anim.Play("Jump", 0, 0);
|
||||
else _anim.DoScaledAnimationAsync("Miss", 0.5f);
|
||||
|
||||
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)
|
||||
{
|
||||
if (!miss) _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 IEnumerator HoldCo(double beat)
|
||||
{
|
||||
float normalizedBeat = Conductor.instance.GetPositionFromBeat(beat, 1);
|
||||
Transform dragonPoint = _game.GetDragonPointAtBeat(beat);
|
||||
while (normalizedBeat < 1f)
|
||||
{
|
||||
normalizedBeat = Conductor.instance.GetPositionFromBeat(beat, 1);
|
||||
transform.position = dragonPoint.position;
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void Just(PlayerActionEvent caller, float state)
|
||||
{
|
||||
bool isTriple = _game.IsTripleBeat(caller.startBeat + caller.timer);
|
||||
|
|
@ -210,6 +281,30 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
|
|||
SoundByte.PlayOneShotGame("totemClimb/totemland");
|
||||
}
|
||||
|
||||
private void JustHold(PlayerActionEvent caller, float state)
|
||||
{
|
||||
SoundByte.PlayOneShotGame("totemClimb/chargejump");
|
||||
_game.HoldDragonAtBeat(caller.startBeat + caller.timer);
|
||||
StartCoroutine(HoldCo(caller.startBeat + caller.timer));
|
||||
if (state >= 1f || state <= -1f)
|
||||
{
|
||||
SoundByte.PlayOneShot("nearMiss");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void JustRelease(PlayerActionEvent caller, float state)
|
||||
{
|
||||
HighJump(caller.startBeat + caller.timer, false);
|
||||
_game.ReleaseDragonAtBeat(caller.startBeat + caller.timer);
|
||||
if (state >= 1f || state <= -1f)
|
||||
{
|
||||
SoundByte.PlayOneShot("nearMiss");
|
||||
return;
|
||||
}
|
||||
SoundByte.PlayOneShotGame("totemClimb/superjumpgood");
|
||||
}
|
||||
|
||||
private void Miss(PlayerActionEvent caller)
|
||||
{
|
||||
StartJumping(caller.startBeat + caller.timer, true);
|
||||
|
|
@ -232,6 +327,13 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
|
|||
SoundByte.PlayOneShot("miss");
|
||||
}
|
||||
|
||||
private void MissRelease(PlayerActionEvent caller)
|
||||
{
|
||||
HighJump(caller.startBeat + caller.timer, true);
|
||||
_game.ReleaseDragonAtBeat(caller.startBeat + caller.timer);
|
||||
SoundByte.PlayOneShot("miss");
|
||||
}
|
||||
|
||||
private void Empty(PlayerActionEvent caller) { }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,6 +123,39 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
|
|||
f.FallPiece(part);
|
||||
}
|
||||
|
||||
public Transform GetHighJumperPointAtBeat(double beat)
|
||||
{
|
||||
var d = _dragons.Find(x => beat >= x.beat && beat < x.beat + 4);
|
||||
if (d == null)
|
||||
{
|
||||
Debug.Log($"Jumper Dragon Point unavaible at beat {beat}.");
|
||||
return null;
|
||||
}
|
||||
return d.JumperPoint;
|
||||
}
|
||||
|
||||
public void HoldDragonAtBeat(double beat)
|
||||
{
|
||||
var d = _dragons.Find(x => beat >= x.beat && beat < x.beat + 4);
|
||||
if (d == null)
|
||||
{
|
||||
Debug.Log($"Dragon unavaible at beat {beat}.");
|
||||
return;
|
||||
}
|
||||
d.Hold();
|
||||
}
|
||||
|
||||
public void ReleaseDragonAtBeat(double beat)
|
||||
{
|
||||
var d = _dragons.Find(x => beat >= x.beat && beat < x.beat + 4);
|
||||
if (d == null)
|
||||
{
|
||||
Debug.Log($"Dragon unavaible at beat {beat}.");
|
||||
return;
|
||||
}
|
||||
d.Release();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float currentScrollX = _scrollTransform.localPosition.x;
|
||||
|
|
|
|||
|
|
@ -208,6 +208,21 @@ namespace HeavenStudio.Games
|
|||
return _totemManager.GetJumperFrogPointAtBeat(beat, part);
|
||||
}
|
||||
|
||||
public Transform GetDragonPointAtBeat(double beat)
|
||||
{
|
||||
return _totemManager.GetHighJumperPointAtBeat(beat);
|
||||
}
|
||||
|
||||
public void HoldDragonAtBeat(double beat)
|
||||
{
|
||||
_totemManager.HoldDragonAtBeat(beat);
|
||||
}
|
||||
|
||||
public void ReleaseDragonAtBeat(double beat)
|
||||
{
|
||||
_totemManager.ReleaseDragonAtBeat(beat);
|
||||
}
|
||||
|
||||
public void FallFrogAtBeat(double beat, int part)
|
||||
{
|
||||
_totemManager.FallFrogAtBeat(beat, part);
|
||||
|
|
@ -250,7 +265,7 @@ namespace HeavenStudio.Games
|
|||
double highBeat = h.beat - _startBeat;
|
||||
if (normalizedBeat >= highBeat + 2)
|
||||
{
|
||||
normalizedBeat = Mathf.Clamp(normalizedBeat - 2 + (cond.GetPositionFromBeat(highBeat + 2, 2) * 2), (float)highBeat, (float)highBeat + 4);
|
||||
normalizedBeat = Mathf.Clamp(normalizedBeat - 2 + (cond.GetPositionFromBeat(h.beat + 2, 2) * 2), (float)highBeat, (float)highBeat + 4);
|
||||
Debug.Log(normalizedBeat);
|
||||
}
|
||||
else if (normalizedBeat >= highBeat)
|
||||
|
|
|
|||
Loading…
Reference in a new issue