Got em inputs in nightwalk gba to work

This commit is contained in:
Rapandrasmus 2023-06-21 20:12:45 +02:00
parent fc07d6a170
commit 4f904c99c2
5 changed files with 91 additions and 3 deletions

View file

@ -680,6 +680,7 @@ MonoBehaviour:
scheduledInputs: []
firstEnable: 0
playYan: {fileID: 1314280037714680423}
platformHandler: {fileID: 6715217060937385611}
--- !u!1 &4465275889429203320
GameObject:
m_ObjectHideFlags: 0

View file

@ -16,7 +16,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!4 &9016694733661613840
Transform:
m_ObjectHideFlags: 0

View file

@ -37,6 +37,7 @@ namespace HeavenStudio.Games
{
public static AgbNightWalk instance;
[SerializeField] private AgbPlayYan playYan;
[SerializeField] private AgbPlatformHandler platformHandler;
[NonSerialized] public double countInBeat = -1;
private void Awake()
@ -47,11 +48,13 @@ namespace HeavenStudio.Games
public override void OnGameSwitch(double beat)
{
SetCountInBeat(beat);
platformHandler.SpawnPlatforms(beat);
}
public override void OnPlay(double beat)
{
SetCountInBeat(beat);
platformHandler.SpawnPlatforms(beat);
}
private void SetCountInBeat(double beat)
@ -85,8 +88,11 @@ namespace HeavenStudio.Games
tempEvents.Add(countIn);
}
}
tempEvents.Sort((x, y) => x.beat.CompareTo(y.beat));
countInBeat = tempEvents[tempEvents.Count - 1].beat;
if (tempEvents.Count > 0)
{
tempEvents.Sort((x, y) => x.beat.CompareTo(y.beat));
countInBeat = tempEvents[tempEvents.Count - 1].beat;
}
}
}
UpdateBalloons(beat);
@ -136,6 +142,7 @@ namespace HeavenStudio.Games
tempEvents.Add(countIn);
}
}
if (tempEvents.Count == 0) return true;
tempEvents.Sort((x, y) => x.beat.CompareTo(y.beat));
return countInEntity == tempEvents[tempEvents.Count - 1];
}

View file

@ -7,7 +7,62 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk
{
public class AgbPlatform : MonoBehaviour
{
private double startBeat;
private double endBeat;
private AgbPlatformHandler handler;
public void Init(double beat, double hitBeat, AgbPlatformHandler handlerToPut)
{
handler = handlerToPut;
startBeat = beat;
endBeat = hitBeat;
if (startBeat < endBeat)
{
AgbNightWalk.instance.ScheduleInput(startBeat, endBeat - startBeat, InputType.STANDARD_DOWN, Just, Miss, Empty);
}
}
private void Awake()
{
Update();
}
private void Update()
{
var cond = Conductor.instance;
if (cond.isPlaying && !cond.isPaused)
{
float normalizedBeat = cond.GetPositionFromBeat(startBeat, endBeat - startBeat);
float newPosX = Mathf.LerpUnclamped(handler.playerXPos + (float)((endBeat - startBeat) * handler.platformDistance), handler.playerXPos, normalizedBeat);
transform.localPosition = new Vector3(newPosX, handler.defaultYPos);
if (cond.songPositionInBeats > endBeat + (handler.platformCount * 0.5f))
{
ResetInput();
}
}
}
private void ResetInput()
{
double newStartBeat = endBeat + (handler.platformCount * 0.5f);
Init(newStartBeat, newStartBeat + (handler.platformCount * 0.5f), handler);
}
private void Just(PlayerActionEvent caller, float state)
{
if (state >= 1 || state <= -1)
{
return;
}
}
private void Miss(PlayerActionEvent caller)
{
}
private void Empty(PlayerActionEvent caller) { }
}
}

View file

@ -6,11 +6,36 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk
{
public class AgbPlatformHandler : MonoBehaviour
{
private AgbNightWalk game;
[Header("Properties")]
[SerializeField] private AgbPlatform platformRef;
public float defaultYPos = -11.76f;
public float platformDistance = 3.80f;
public float playerXPos = -6.78f;
[Range(1, 100)]
public int platformCount = 20;
private void Awake()
{
game = AgbNightWalk.instance;
}
public void SpawnPlatforms(double beat)
{
if (game.countInBeat != -1)
{
for (int i = 0; i < platformCount; i++)
{
AgbPlatform platform = Instantiate(platformRef, transform);
platform.Init(game.countInBeat + i - (platformCount * 0.5), game.countInBeat + i + 8, this);
platform.gameObject.SetActive(true);
}
}
else
{
}
}
}
}