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: m_EditorClassIdentifier:
platformRef: {fileID: 1558448204157038467, guid: 73364b4dafdbd914f83c316a1fcf8dd7, type: 3} platformRef: {fileID: 1558448204157038467, guid: 73364b4dafdbd914f83c316a1fcf8dd7, type: 3}
defaultYPos: -11.76 defaultYPos: -11.76
heightAmount: 2
platformDistance: 3.8 platformDistance: 3.8
playerXPos: -6.78 playerXPos: -6.78
platformCount: 15 platformCount: 16
--- !u!1 &955264990193298390 --- !u!1 &955264990193298390
GameObject: GameObject:
m_ObjectHideFlags: 0 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>() 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); }, preFunction = delegate { if (!eventCaller.currentEntity["mute"] && AgbNightWalk.IsValidCountIn(eventCaller.currentEntity)) AgbNightWalk.CountInSound(eventCaller.currentEntity.beat); },
defaultLength = 8, defaultLength = 8,
@ -50,7 +50,12 @@ namespace HeavenStudio.Games
[NonSerialized] public double countInBeat = -1; [NonSerialized] public double countInBeat = -1;
[Header("Curves")] [Header("Curves")]
[SerializeField] SuperCurveObject.Path[] jumpPaths; [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() new void OnDrawGizmos()
{ {
@ -80,18 +85,25 @@ namespace HeavenStudio.Games
{ {
instance = this; instance = this;
List<RiqEntity> heightEvents = EventCaller.GetAllInGameManagerList("nightWalkAgb", new string[] { "height" }); 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"]); heightEntityEvents.Add(new HeightEvent()
if (platformHeightChanges.ContainsKey(height.beat))
{ {
platformHeightChanges[height.beat] += height["value"] + randomValue; beat = heightEvent.beat,
} value = heightEvent["value"] + UnityEngine.Random.Range(heightEvent["rmin"], heightEvent["rmax"] + 1)
else });
{
platformHeightChanges.Add(height.beat, height["value"] + randomValue);
} }
} }
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) public override void OnGameSwitch(double beat)

View file

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

View file

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