Height changes added

This commit is contained in:
Rapandrasmus 2023-06-22 00:15:33 +02:00
parent 18cdfa222f
commit 6c0d780576
4 changed files with 78 additions and 3 deletions

View file

@ -131,6 +131,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 2b6892a770a77394ca687ef93f8935db, type: 3} m_Script: {fileID: 11500000, guid: 2b6892a770a77394ca687ef93f8935db, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
platform: {fileID: 8602790381015410525}
--- !u!95 &4653690538679061971 --- !u!95 &4653690538679061971
Animator: Animator:
serializedVersion: 5 serializedVersion: 5

View file

@ -23,6 +23,13 @@ namespace HeavenStudio.Games.Loaders
{ {
new Param("mute", false, "Mute Cowbell") new Param("mute", false, "Mute Cowbell")
} }
},
new GameAction("height", "Platform Height")
{
parameters = new List<Param>()
{
new Param("value", new EntityTypes.Integer(-10, 10, 1), "Height Units")
}
} }
}); });
} }
@ -41,6 +48,7 @@ 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, RiqEntity> platformHeightChanges = new Dictionary<double, RiqEntity>();
new void OnDrawGizmos() new void OnDrawGizmos()
{ {
@ -69,6 +77,18 @@ namespace HeavenStudio.Games
private void Awake() private void Awake()
{ {
instance = this; instance = this;
List<RiqEntity> heightEvents = EventCaller.GetAllInGameManagerList("nightWalkAgb", new string[] { "height" });
foreach (var height in heightEvents)
{
if (platformHeightChanges.ContainsKey(height.beat))
{
platformHeightChanges[height.beat]["value"] += height["value"];
}
else
{
platformHeightChanges.Add(height.beat, height);
}
}
} }
public override void OnGameSwitch(double beat) public override void OnGameSwitch(double beat)

View file

@ -23,8 +23,30 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk
private PlatformType type = PlatformType.Flower; private PlatformType type = PlatformType.Flower;
private float additionalHeight = 0f;
private int additionalHeightInUnits = 0;
private int lastAdditionalHeightInUnits = 0;
[SerializeField] private GameObject platform;
public void StartInput(double beat, double hitBeat) public void StartInput(double beat, double hitBeat)
{ {
if (game == null) game = AgbNightWalk.instance;
if (game.platformHeightChanges.ContainsKey(hitBeat))
{
handler.defaultHeightUnits += game.platformHeightChanges[hitBeat]["value"];
}
lastAdditionalHeightInUnits = handler.defaultHeightUnits;
additionalHeight = handler.defaultHeightUnits * handler.heightAmount;
if (game.platformHeightChanges.ContainsKey(hitBeat + 1))
{
additionalHeightInUnits = lastAdditionalHeightInUnits + game.platformHeightChanges[hitBeat + 1]["value"];
}
else
{
additionalHeightInUnits = lastAdditionalHeightInUnits;
}
platform.SetActive(!game.platformHeightChanges.ContainsKey(hitBeat + 1));
startBeat = beat; startBeat = beat;
endBeat = hitBeat; endBeat = hitBeat;
if (startBeat < endBeat) if (startBeat < endBeat)
@ -49,7 +71,7 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk
float newPosX = Mathf.LerpUnclamped(handler.playerXPos + (float)((endBeat - startBeat) * handler.platformDistance), handler.playerXPos, normalizedBeat); float newPosX = Mathf.LerpUnclamped(handler.playerXPos + (float)((endBeat - startBeat) * handler.platformDistance), handler.playerXPos, normalizedBeat);
transform.localPosition = new Vector3(newPosX, handler.defaultYPos); transform.localPosition = new Vector3(newPosX, handler.defaultYPos + additionalHeight);
if (cond.songPositionInBeats > endBeat + (handler.platformCount * 0.5f)) if (cond.songPositionInBeats > endBeat + (handler.platformCount * 0.5f))
{ {
@ -66,6 +88,7 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk
} }
private void Just(PlayerActionEvent caller, float state) private void Just(PlayerActionEvent caller, float state)
{ {
handler.RaiseHeight(Conductor.instance.songPositionInBeats, lastAdditionalHeightInUnits, additionalHeightInUnits);
game.playYan.Jump(Conductor.instance.songPositionInBeats); game.playYan.Jump(Conductor.instance.songPositionInBeats);
if (state >= 1 || state <= -1) if (state >= 1 || state <= -1)
{ {

View file

@ -1,3 +1,4 @@
using HeavenStudio.Util;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
@ -11,10 +12,15 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk
[Header("Properties")] [Header("Properties")]
[SerializeField] private AgbPlatform platformRef; [SerializeField] private AgbPlatform platformRef;
public float defaultYPos = -11.76f; public float defaultYPos = -11.76f;
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)]
public int platformCount = 20; public int platformCount = 20;
private float lastHeight = 0;
private float heightToRaiseTo = 0;
private double raiseBeat = -1;
private void Awake() private void Awake()
{ {
@ -28,8 +34,8 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk
for (int i = 0; i < platformCount; i++) for (int i = 0; i < platformCount; i++)
{ {
AgbPlatform platform = Instantiate(platformRef, transform); AgbPlatform platform = Instantiate(platformRef, transform);
platform.StartInput(game.countInBeat + i + 8 - (platformCount * 0.5), game.countInBeat + i + 8);
platform.handler = this; platform.handler = this;
platform.StartInput(game.countInBeat + i + 8 - (platformCount * 0.5), game.countInBeat + i + 8);
platform.gameObject.SetActive(true); platform.gameObject.SetActive(true);
} }
} }
@ -38,12 +44,37 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk
for (int i = 0; i < platformCount; i++) for (int i = 0; i < platformCount; i++)
{ {
AgbPlatform platform = Instantiate(platformRef, transform); AgbPlatform platform = Instantiate(platformRef, transform);
platform.StartInput(Math.Ceiling(beat) + i - (platformCount * 1.5), Math.Ceiling(beat) + i - platformCount);
platform.handler = this; platform.handler = this;
platform.StartInput(Math.Ceiling(beat) + i - (platformCount * 1.5), Math.Ceiling(beat) + i - platformCount);
platform.gameObject.SetActive(true); platform.gameObject.SetActive(true);
} }
} }
} }
private void Update()
{
var cond = Conductor.instance;
if (cond.isPlaying && !cond.isPaused)
{
if (raiseBeat != -1)
{
float normalizedBeat = Mathf.Clamp(cond.GetPositionFromBeat(raiseBeat, 1), 0, 1);
EasingFunction.Function func = EasingFunction.GetEasingFunction(EasingFunction.Ease.EaseOutQuint);
float newPosY = func(lastHeight, heightToRaiseTo, normalizedBeat);
transform.localPosition = new Vector3(0, -newPosY, 0);
}
}
}
public void RaiseHeight(double beat, int lastUnits, int currentUnits)
{
raiseBeat = beat;
lastHeight = lastUnits * heightAmount * transform.localScale.y;
heightToRaiseTo = currentUnits * heightAmount * transform.localScale.y;
Update();
}
} }
} }