Implemented Audio and prefunction, not done with it though

This commit is contained in:
Rapandrasmus 2023-01-15 15:17:33 +01:00
parent d4f927a56c
commit 9d60481bc4
18 changed files with 267 additions and 31 deletions

Binary file not shown.

View file

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: c87bf41c21b43ab44a20f4e143bed453
guid: 7fa90f9639d59314b891b04113a87376
AudioImporter:
externalObjects: {}
serializedVersion: 6

View file

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: e810abbf398d2b244a266d6460f27e40
guid: 0b9e88c13727472458ee17e02959f7ae
AudioImporter:
externalObjects: {}
serializedVersion: 6

Binary file not shown.

View file

@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: 11e4ffd422e5041449bb6a649dc75d1e
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View file

@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: 2cd9ec8dd2b89594b937fd43a63302fd
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: b98e01e9184c9c94ba69a5eda9182abe
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: a0cbaa7ba5b83f64b9cdade5829f6d8b
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: e0d74c59ec5b943409f83854ca7426f8
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View file

@ -7,19 +7,19 @@ using HeavenStudio.Util;
namespace HeavenStudio.Games.Scripts_WorkingDough
{
public enum FlyingStage
{
EnteringUp = 0,
EnteringDown = 1,
ExitingUp = 2,
ExitingDown = 3
}
public class NPCDoughBall : PlayerActionObject
{
public float startBeat;
//public bool isBig;
public enum FlyingStage
{
EnteringUp,
EnteringDown,
ExitingUp,
ExitingDown
}
FlyingStage currentFlyingStage = FlyingStage.EnteringUp;
public FlyingStage currentFlyingStage = FlyingStage.EnteringUp;
[NonSerialized] public BezierCurve3D enterUpCurve;

View file

@ -21,13 +21,13 @@ namespace HeavenStudio.Games.Loaders
},
new GameAction("small ball", "Small Ball")
{
function = delegate { WorkingDough.instance.SpawnBall(eventCaller.currentEntity.beat, false); },
defaultLength = 2f,
preFunction = delegate { var e = eventCaller.currentEntity; WorkingDough.instance.PreSpawnBall(e.beat, false); },
defaultLength = 0.5f,
},
new GameAction("big ball", "Big Ball")
{
function = delegate { WorkingDough.instance.SpawnBall(eventCaller.currentEntity.beat, true); },
defaultLength = 2f,
preFunction = delegate { var e = eventCaller.currentEntity; WorkingDough.instance.PreSpawnBall(e.beat, true); },
defaultLength = 0.5f,
},
});
}
@ -60,9 +60,21 @@ namespace HeavenStudio.Games
[Header("Variables")]
public bool intervalStarted;
//float intervalStartBeat;
float intervalStartBeat;
public float beatInterval = 4f;
public bool bigMode;
static List<QueuedBall> queuedBalls = new List<QueuedBall>();
struct QueuedBall
{
public float beat;
public bool isBig;
}
static List<QueuedInterval> queuedIntervals = new List<QueuedInterval>();
struct QueuedInterval
{
public float beat;
public float interval;
}
[Header("Curves")]
public BezierCurve3D npcEnterUpCurve;
@ -92,28 +104,30 @@ namespace HeavenStudio.Games
ballTransporterRightNPC.GetComponent<Animator>().Play("BallTransporterRightOpen", 0, 0);
BeatAction.New(ballTransporterLeftNPC, new List<BeatAction.Action>()
{
//Open player transporters
new BeatAction.Action(beat + interval - 1f, delegate { ballTransporterLeftPlayer.GetComponent<Animator>().Play("BallTransporterLeftOpen", 0, 0); }),
new BeatAction.Action(beat + interval - 1f, delegate { ballTransporterRightPlayer.GetComponent<Animator>().Play("BallTransporterRightOpen", 0, 0); }),
//End interval
new BeatAction.Action(beat + interval, delegate { intervalStarted = false; }),
//Open player transporters
new BeatAction.Action(beat + interval, delegate { ballTransporterLeftPlayer.GetComponent<Animator>().Play("BallTransporterLeftOpen", 0, 0); }),
new BeatAction.Action(beat + interval, delegate { ballTransporterRightPlayer.GetComponent<Animator>().Play("BallTransporterRightOpen", 0, 0); }),
new BeatAction.Action(beat + interval, delegate {
//Close npc transporters
new BeatAction.Action(beat + interval + 1f, delegate {
if (bigMode)
{
NPCBallTransporters.GetComponent<Animator>().Play("NPCExitBigMode", 0, 0);
bigMode = false;
}
}),
//Close npc transporters
new BeatAction.Action(beat + interval + 0.5f, delegate { ballTransporterLeftNPC.GetComponent<Animator>().Play("BallTransporterLeftClose", 0, 0); }),
new BeatAction.Action(beat + interval + 0.5f, delegate { ballTransporterRightNPC.GetComponent<Animator>().Play("BallTransporterRightClose", 0, 0); }),
new BeatAction.Action(beat + interval + 1f, delegate { ballTransporterLeftNPC.GetComponent<Animator>().Play("BallTransporterLeftClose", 0, 0); }),
new BeatAction.Action(beat + interval + 1f, delegate { ballTransporterRightNPC.GetComponent<Animator>().Play("BallTransporterRightClose", 0, 0); }),
//Close player transporters
new BeatAction.Action(beat + interval * 2 + 0.5f, delegate { ballTransporterLeftPlayer.GetComponent<Animator>().Play("BallTransporterLeftClose", 0, 0); }),
new BeatAction.Action(beat + interval * 2 + 0.5f, delegate { ballTransporterRightPlayer.GetComponent<Animator>().Play("BallTransporterRightClose", 0, 0); }),
new BeatAction.Action(beat + interval * 2 + 1f, delegate { ballTransporterLeftPlayer.GetComponent<Animator>().Play("BallTransporterLeftClose", 0, 0); }),
new BeatAction.Action(beat + interval * 2 + 1f, delegate { ballTransporterRightPlayer.GetComponent<Animator>().Play("BallTransporterRightClose", 0, 0); }),
});
}
//intervalStartBeat = beat;
intervalStartBeat = beat;
beatInterval = interval;
}
@ -156,17 +170,129 @@ namespace HeavenStudio.Games
}
public void InstantExitBall(float beat, bool isBig, float offSet)
{
Debug.Log("Offset: " + offSet.ToString());
var objectToSpawn = isBig ? bigBallNPC : smallBallNPC;
var spawnedBall = GameObject.Instantiate(objectToSpawn, ballHolder);
var ballComponent = spawnedBall.GetComponent<NPCDoughBall>();
ballComponent.startBeat = beat - 1;
ballComponent.exitUpCurve = npcExitUpCurve;
ballComponent.enterUpCurve = npcEnterUpCurve;
ballComponent.exitDownCurve = npcExitDownCurve;
ballComponent.enterDownCurve = npcEnterDownCurve;
ballComponent.currentFlyingStage = (FlyingStage)(2 - Mathf.Abs(offSet * 2));
spawnedBall.SetActive(true);
if (isBig && !bigMode)
{
bigMode = true;
}
BeatAction.New(doughDudesNPC, new List<BeatAction.Action>()
{
new BeatAction.Action(beat, delegate { doughDudesNPC.GetComponent<Animator>().Play(isBig ? "BigDoughJump" : "SmallDoughJump", 0, 0); } ),
new BeatAction.Action(beat, delegate { Jukebox.PlayOneShotGame(isBig ? "workingDough/NPCBigBall" : "workingDough/NPCSmallBall"); } ),
new BeatAction.Action(beat, delegate { npcImpact.SetActive(true); } ),
new BeatAction.Action(beat + 0.1f, delegate { npcImpact.SetActive(false); }),
new BeatAction.Action(beat + 0.9f, delegate { arrowSRRightNPC.sprite = redArrowSprite; }),
new BeatAction.Action(beat + 1f, delegate { arrowSRRightNPC.sprite = whiteArrowSprite; }),
});
}
public void PreSpawnBall(float beat, bool isBig)
{
float spawnBeat = beat - 1f;
beat -= 1f;
if (GameManager.instance.currentGame == "workingDough")
{
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(spawnBeat, delegate { if (instance != null) instance.SpawnBall(beat, isBig); }),
});
}
else
{
queuedBalls.Add(new QueuedBall()
{
beat = beat + 1f,
isBig = isBig,
});
}
}
public void PreSetIntervalStart(float beat, float interval)
{
float spawnBeat = beat - 1f;
beat -= 1f;
interval += 1f;
if (GameManager.instance.currentGame == "workingDough")
{
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(spawnBeat, delegate { if (instance != null) instance.SetIntervalStart(beat, interval); }),
});
}
else
{
queuedIntervals.Add(new QueuedInterval()
{
beat = beat + 1f,
interval = interval - 1f,
});
}
}
void Update()
{
if(PlayerInput.Pressed())
Conductor cond = Conductor.instance;
if (!cond.isPlaying || cond.isPaused) return;
if (queuedIntervals.Count > 0)
{
doughDudesPlayer.GetComponent<Animator>().Play("SmallDoughJump", 0, 0);
Jukebox.PlayOneShotGame("workingDough/PlayerSmallBall");
foreach (var interval in queuedIntervals)
{
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(interval.beat, delegate { SetIntervalStart(interval.beat, interval.interval); beatInterval += 1; }),
});
}
queuedIntervals.Clear();
}
else if (PlayerInput.AltPressed())
if (!IsExpectingInputNow())
{
doughDudesPlayer.GetComponent<Animator>().Play("BigDoughJump", 0, 0);
Jukebox.PlayOneShotGame("workingDough/PlayerBigBall");
if (PlayerInput.Pressed())
{
doughDudesPlayer.GetComponent<Animator>().Play("SmallDoughJump", 0, 0);
Jukebox.PlayOneShotGame("workingDough/PlayerSmallJump");
}
else if (PlayerInput.AltPressed())
{
doughDudesPlayer.GetComponent<Animator>().Play("BigDoughJump", 0, 0);
Jukebox.PlayOneShotGame("workingDough/PlayerBigJump");
}
}
}
void LateUpdate()
{
Conductor cond = Conductor.instance;
if (!cond.isPlaying || cond.isPaused) return;
if (queuedBalls.Count > 0)
{
foreach (var ball in queuedBalls)
{
if (ball.isBig) NPCBallTransporters.GetComponent<Animator>().Play("BigMode", 0, 0);
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(ball.beat - (ball.beat - intervalStartBeat), delegate { if (!intervalStarted) SetIntervalStart(ball.beat, beatInterval); }),
new BeatAction.Action(ball.beat - (ball.beat - intervalStartBeat), delegate { InstantExitBall(ball.beat, ball.isBig, ball.beat - intervalStartBeat); }),
});
}
queuedBalls.Clear();
}
}
}