Ok height changes should be flawless now

This commit is contained in:
Rapandrasmus 2023-06-22 13:06:18 +02:00
parent ecc67c5daa
commit 7b25ee197b
4 changed files with 29 additions and 28 deletions

View file

@ -78,9 +78,10 @@ MonoBehaviour:
m_EditorClassIdentifier:
platformRef: {fileID: 1558448204157038467, guid: 73364b4dafdbd914f83c316a1fcf8dd7, type: 3}
defaultYPos: -11.76
heightAmount: 2
platformDistance: 3.8
playerXPos: -6.78
platformCount: 15
platformCount: 16
--- !u!1 &955264990193298390
GameObject:
m_ObjectHideFlags: 0

View file

@ -15,7 +15,7 @@ namespace HeavenStudio.Games.Loaders
{
return new Minigame("nightWalkAgb", "Night Walk (GBA)", "FFFFFF", false, false, new List<GameAction>()
{
new GameAction("countIn", "Count In")
new GameAction("countIn", "8 Beat Count-In")
{
preFunction = delegate { if (!eventCaller.currentEntity["mute"] && AgbNightWalk.IsValidCountIn(eventCaller.currentEntity)) AgbNightWalk.CountInSound(eventCaller.currentEntity.beat); },
defaultLength = 8,
@ -50,7 +50,12 @@ namespace HeavenStudio.Games
[NonSerialized] public double countInBeat = -1;
[Header("Curves")]
[SerializeField] SuperCurveObject.Path[] jumpPaths;
[NonSerialized] public Dictionary<double, int> platformHeightChanges = new Dictionary<double, int>();
private struct HeightEvent
{
public double beat;
public int value;
}
List<HeightEvent> heightEntityEvents = new();
new void OnDrawGizmos()
{
@ -80,20 +85,27 @@ namespace HeavenStudio.Games
{
instance = this;
List<RiqEntity> heightEvents = EventCaller.GetAllInGameManagerList("nightWalkAgb", new string[] { "height" });
foreach (var height in heightEvents)
foreach (var heightEvent in heightEvents)
{
int randomValue = UnityEngine.Random.Range(height["rmin"], height["rmax"]);
if (platformHeightChanges.ContainsKey(height.beat))
heightEntityEvents.Add(new HeightEvent()
{
platformHeightChanges[height.beat] += height["value"] + randomValue;
}
else
{
platformHeightChanges.Add(height.beat, height["value"] + randomValue);
}
beat = heightEvent.beat,
value = heightEvent["value"] + UnityEngine.Random.Range(heightEvent["rmin"], heightEvent["rmax"] + 1)
});
}
}
public int FindHeightUnitsAtBeat(double beat)
{
List<HeightEvent> tempEvents = heightEntityEvents.FindAll(e => e.beat <= beat);
int height = 0;
foreach (var heightEvent in tempEvents)
{
height += heightEvent.value;
}
return height;
}
public override void OnGameSwitch(double beat)
{
SetCountInBeat(beat);

View file

@ -32,21 +32,10 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk
public void StartInput(double beat, double hitBeat)
{
if (game == null) game = AgbNightWalk.instance;
if (game.platformHeightChanges.ContainsKey(hitBeat))
{
handler.defaultHeightUnits += game.platformHeightChanges[hitBeat];
}
lastAdditionalHeightInUnits = handler.defaultHeightUnits;
additionalHeight = handler.defaultHeightUnits * handler.heightAmount;
if (game.platformHeightChanges.ContainsKey(hitBeat + 1))
{
additionalHeightInUnits = lastAdditionalHeightInUnits + game.platformHeightChanges[hitBeat + 1];
}
else
{
additionalHeightInUnits = lastAdditionalHeightInUnits;
}
platform.SetActive(!game.platformHeightChanges.ContainsKey(hitBeat + 1));
lastAdditionalHeightInUnits = game.FindHeightUnitsAtBeat(hitBeat);
additionalHeightInUnits = game.FindHeightUnitsAtBeat(hitBeat + 1);
additionalHeight = lastAdditionalHeightInUnits * handler.heightAmount;
platform.SetActive(lastAdditionalHeightInUnits == additionalHeightInUnits);
startBeat = beat;
endBeat = hitBeat;
if (startBeat < endBeat)

View file

@ -13,7 +13,6 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk
[SerializeField] private AgbPlatform platformRef;
public float defaultYPos = -11.76f;
public float heightAmount = 2;
[NonSerialized] public int defaultHeightUnits = 0;
public float platformDistance = 3.80f;
public float playerXPos = -6.78f;
[Range(1, 100)]