Fixed them bugs (#284)

This commit is contained in:
Rapandrasmus 2023-02-17 17:21:34 +01:00 committed by GitHub
parent 4ebf60cd45
commit e24bc63760
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 152 additions and 74 deletions

View file

@ -22,7 +22,7 @@ namespace HeavenStudio.Games.Loaders
{ {
new GameAction("rocket", "Family Model") new GameAction("rocket", "Family Model")
{ {
preFunction = delegate { var e = eventCaller.currentEntity; LaunchParty.instance.LaunchRocket(e.beat, e["offset"], e["note1"], e["note2"], e["note3"], e["note4"]); }, preFunction = delegate { var e = eventCaller.currentEntity; LaunchParty.LaunchRocket(e.beat, e["offset"], e["note1"], e["note2"], e["note3"], e["note4"]); },
defaultLength = 4f, defaultLength = 4f,
parameters = new List<Param>() parameters = new List<Param>()
{ {
@ -35,7 +35,7 @@ namespace HeavenStudio.Games.Loaders
}, },
new GameAction("partyCracker", "Party-Popper") new GameAction("partyCracker", "Party-Popper")
{ {
preFunction = delegate { var e = eventCaller.currentEntity; LaunchParty.instance.LaunchPartyCracker(e.beat, e["offset"], e["note1"], e["note2"], e["note3"], e["note4"], e["note5"], e["note6"]); }, preFunction = delegate { var e = eventCaller.currentEntity; LaunchParty.LaunchPartyCracker(e.beat, e["offset"], e["note1"], e["note2"], e["note3"], e["note4"], e["note5"], e["note6"]); },
defaultLength = 3f, defaultLength = 3f,
parameters = new List<Param>() parameters = new List<Param>()
{ {
@ -50,7 +50,7 @@ namespace HeavenStudio.Games.Loaders
}, },
new GameAction("bell", "Bell") new GameAction("bell", "Bell")
{ {
preFunction = delegate { var e = eventCaller.currentEntity; LaunchParty.instance.LaunchBell(e.beat, e["offset"], e["note1"], e["note2"], e["note3"], e["note4"], e["note5"], e["note6"], e["note7"], e["note8"], preFunction = delegate { var e = eventCaller.currentEntity; LaunchParty.LaunchBell(e.beat, e["offset"], e["note1"], e["note2"], e["note3"], e["note4"], e["note5"], e["note6"], e["note7"], e["note8"],
e["note9"]); }, e["note9"]); },
defaultLength = 3f, defaultLength = 3f,
parameters = new List<Param>() parameters = new List<Param>()
@ -69,7 +69,7 @@ namespace HeavenStudio.Games.Loaders
}, },
new GameAction("bowlingPin", "Bowling Pin") new GameAction("bowlingPin", "Bowling Pin")
{ {
preFunction = delegate { var e = eventCaller.currentEntity; LaunchParty.instance.LaunchBowlingPin(e.beat, e["offset"], e["note1"], e["note2"], e["note3"], e["note4"], e["note5"], e["note6"], e["note7"], preFunction = delegate { var e = eventCaller.currentEntity; LaunchParty.LaunchBowlingPin(e.beat, e["offset"], e["note1"], e["note2"], e["note3"], e["note4"], e["note5"], e["note6"], e["note7"],
e["note8"], e["note9"], e["note10"], e["note11"], e["note12"], e["note13"], e["note14"], e["note15"]); }, e["note8"], e["note9"], e["note10"], e["note11"], e["note12"], e["note13"], e["note14"], e["note15"]); },
defaultLength = 3f, defaultLength = 3f,
parameters = new List<Param>() parameters = new List<Param>()
@ -94,7 +94,6 @@ namespace HeavenStudio.Games.Loaders
}, },
new GameAction("posMove", "Change Launch Pad Position") new GameAction("posMove", "Change Launch Pad Position")
{ {
function = delegate { LaunchParty.instance.Nothing(); },
defaultLength = 4f, defaultLength = 4f,
resizable = true, resizable = true,
parameters = new List<Param>() parameters = new List<Param>()
@ -107,7 +106,6 @@ namespace HeavenStudio.Games.Loaders
}, },
new GameAction("rotMove", "Change Launch Pad Rotation") new GameAction("rotMove", "Change Launch Pad Rotation")
{ {
function = delegate { LaunchParty.instance.Nothing(); },
defaultLength = 4f, defaultLength = 4f,
resizable = true, resizable = true,
parameters = new List<Param>() parameters = new List<Param>()
@ -173,6 +171,21 @@ namespace HeavenStudio.Games
private float currentPadRotation; private float currentPadRotation;
private EasingFunction.Ease lastPosEase; private EasingFunction.Ease lastPosEase;
private EasingFunction.Ease lastRotEase; private EasingFunction.Ease lastRotEase;
public enum RocketType
{
Family = 0,
Cracker = 1,
Bell = 2,
BowlingPin = 3
}
public struct QueuedRocket
{
public RocketType type;
public float beat;
public float offSet;
public List<float> notes;
}
private static List<QueuedRocket> queuedRockets = new List<QueuedRocket>();
private int currentPosIndex; private int currentPosIndex;
@ -184,6 +197,11 @@ namespace HeavenStudio.Games
public static LaunchParty instance; public static LaunchParty instance;
void OnDestroy()
{
if (queuedRockets.Count > 0) queuedRockets.Clear();
}
void Awake() void Awake()
{ {
instance = this; instance = this;
@ -219,6 +237,17 @@ namespace HeavenStudio.Games
void Update() void Update()
{ {
var cond = Conductor.instance; var cond = Conductor.instance;
if (cond.isPlaying && !cond.isPaused)
{
if (queuedRockets.Count > 0)
{
foreach (var rocket in queuedRockets)
{
SpawnRocket(rocket.beat, rocket.offSet, rocket.type, rocket.notes);
}
queuedRockets.Clear();
}
}
if (allPosEvents.Count > 0) if (allPosEvents.Count > 0)
{ {
if (currentPosIndex < allPosEvents.Count && currentPosIndex >= 0) if (currentPosIndex < allPosEvents.Count && currentPosIndex >= 0)
@ -322,88 +351,141 @@ namespace HeavenStudio.Games
} }
} }
public void LaunchRocket(float beat, float beatOffset, int noteOne, int noteTwo, int noteThree, int noteFour) public void SpawnRocket(float beat, float beatOffset, RocketType type, List<float> notes)
{ {
GameObject rocketToSpawn = rocket;
GameObject spawnedRocket = Instantiate(rocket, spawnPad, false); switch (type)
{
case RocketType.Family:
rocketToSpawn = rocket;
break;
case RocketType.Cracker:
rocketToSpawn = partyCracker;
break;
case RocketType.Bell:
rocketToSpawn = bell;
break;
case RocketType.BowlingPin:
rocketToSpawn = bowlingPin;
break;
}
GameObject spawnedRocket = Instantiate(rocketToSpawn, spawnPad, false);
var rocketScript = spawnedRocket.GetComponent<LaunchPartyRocket>(); var rocketScript = spawnedRocket.GetComponent<LaunchPartyRocket>();
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteOne) * Conductor.instance.musicSource.pitch); rocketScript.pitches.AddRange(notes);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteTwo) * Conductor.instance.musicSource.pitch); switch (type)
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteThree) * Conductor.instance.musicSource.pitch); {
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteFour) * Conductor.instance.musicSource.pitch); case RocketType.Family:
rocketScript.InitFamilyRocket(beat); rocketScript.InitFamilyRocket(beat);
break;
case RocketType.Cracker:
rocketScript.InitPartyCracker(beat);
break;
case RocketType.Bell:
rocketScript.InitBell(beat);
break;
case RocketType.BowlingPin:
rocketScript.InitBowlingPin(beat);
break;
}
BeatAction.New(instance.gameObject, new List<BeatAction.Action>() BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{ {
new BeatAction.Action(beat + beatOffset, delegate { rocketScript.Rise(); }) new BeatAction.Action(beat + beatOffset, delegate { rocketScript.Rise(); })
}); });
} }
public void LaunchPartyCracker(float beat, float beatOffset, int noteOne, int noteTwo, int noteThree, int noteFour, int noteFive, int noteSix) public static void LaunchRocket(float beat, float beatOffset, int noteOne, int noteTwo, int noteThree, int noteFour)
{ {
GameObject spawnedRocket = Instantiate(partyCracker, spawnPad, false); List<float> pitches = new List<float>()
var rocketScript = spawnedRocket.GetComponent<LaunchPartyRocket>();
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteOne) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteTwo) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteThree) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteFour) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteFive) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteSix) * Conductor.instance.musicSource.pitch);
rocketScript.InitPartyCracker(beat);
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{ {
new BeatAction.Action(beat + beatOffset, delegate { rocketScript.Rise(); }) Mathf.Pow(2f, (1f / 12f) * noteOne) * Conductor.instance.musicSource.pitch,
}); Mathf.Pow(2f, (1f / 12f) * noteTwo) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteThree) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteFour) * Conductor.instance.musicSource.pitch
};
if (GameManager.instance.currentGame == "launchParty")
{
LaunchParty.instance.SpawnRocket(beat, beatOffset, RocketType.Family, pitches);
}
else
{
queuedRockets.Add(new QueuedRocket { beat = beat, offSet = beatOffset, notes = pitches, type = RocketType.Family});
}
} }
public void LaunchBell(float beat, float beatOffset, int noteOne, int noteTwo, int noteThree, int noteFour, int noteFive, int noteSix, int noteSeven, int noteEight, int noteNine) public static void LaunchPartyCracker(float beat, float beatOffset, int noteOne, int noteTwo, int noteThree, int noteFour, int noteFive, int noteSix)
{ {
GameObject spawnedRocket = Instantiate(bell, spawnPad, false); List<float> pitches = new List<float>()
var rocketScript = spawnedRocket.GetComponent<LaunchPartyRocket>();
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteOne) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteTwo) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteThree) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteFour) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteFive) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteSix) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteSeven) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteEight) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteNine) * Conductor.instance.musicSource.pitch);
rocketScript.InitBell(beat);
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{ {
new BeatAction.Action(beat + beatOffset, delegate { rocketScript.Rise(); }) Mathf.Pow(2f, (1f / 12f) * noteOne) * Conductor.instance.musicSource.pitch,
}); Mathf.Pow(2f, (1f / 12f) * noteTwo) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteThree) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteFour) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteFive) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteSix) * Conductor.instance.musicSource.pitch,
};
if (GameManager.instance.currentGame == "launchParty")
{
LaunchParty.instance.SpawnRocket(beat, beatOffset, RocketType.Cracker, pitches);
}
else
{
queuedRockets.Add(new QueuedRocket { beat = beat, offSet = beatOffset, notes = pitches, type = RocketType.Cracker });
}
} }
public void LaunchBowlingPin(float beat, float beatOffset, int noteOne, int noteTwo, int noteThree, int noteFour, int noteFive, int noteSix, int noteSeven, public static void LaunchBell(float beat, float beatOffset, int noteOne, int noteTwo, int noteThree, int noteFour, int noteFive, int noteSix, int noteSeven, int noteEight, int noteNine)
{
List<float> pitches = new List<float>()
{
Mathf.Pow(2f, (1f / 12f) * noteOne) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteTwo) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteThree) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteFour) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteFive) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteSix) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteSeven) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteEight) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteNine) * Conductor.instance.musicSource.pitch,
};
if (GameManager.instance.currentGame == "launchParty")
{
LaunchParty.instance.SpawnRocket(beat, beatOffset, RocketType.Bell, pitches);
}
else
{
queuedRockets.Add(new QueuedRocket { beat = beat, offSet = beatOffset, notes = pitches, type = RocketType.Bell });
}
}
public static void LaunchBowlingPin(float beat, float beatOffset, int noteOne, int noteTwo, int noteThree, int noteFour, int noteFive, int noteSix, int noteSeven,
int noteEight, int noteNine, int noteTen, int noteEleven, int noteTwelve, int noteThirteen, int noteFourteen, int noteFifteen) int noteEight, int noteNine, int noteTen, int noteEleven, int noteTwelve, int noteThirteen, int noteFourteen, int noteFifteen)
{ {
GameObject spawnedRocket = Instantiate(bowlingPin, spawnPad, false); List<float> pitches = new List<float>()
var rocketScript = spawnedRocket.GetComponent<LaunchPartyRocket>();
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteOne) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteTwo) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteThree) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteFour) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteFive) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteSix) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteSeven) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteEight) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteNine) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteTen) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteEleven) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteTwelve) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteThirteen) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteFourteen) * Conductor.instance.musicSource.pitch);
rocketScript.pitches.Add(Mathf.Pow(2f, (1f / 12f) * noteFifteen) * Conductor.instance.musicSource.pitch);
rocketScript.InitBowlingPin(beat);
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{ {
new BeatAction.Action(beat + beatOffset, delegate { rocketScript.Rise(); }) Mathf.Pow(2f, (1f / 12f) * noteOne) * Conductor.instance.musicSource.pitch,
}); Mathf.Pow(2f, (1f / 12f) * noteTwo) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteThree) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteFour) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteFive) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteSix) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteSeven) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteEight) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteNine) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteTen) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteEleven) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteTwelve) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteThirteen) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteFourteen) * Conductor.instance.musicSource.pitch,
Mathf.Pow(2f, (1f / 12f) * noteFifteen) * Conductor.instance.musicSource.pitch,
};
if (GameManager.instance.currentGame == "launchParty")
{
LaunchParty.instance.SpawnRocket(beat, beatOffset, RocketType.BowlingPin, pitches);
}
else
{
queuedRockets.Add(new QueuedRocket { beat = beat, offSet = beatOffset, notes = pitches, type = RocketType.BowlingPin });
}
} }
public void CreateParticles(float beat, bool toggle, float starDensity, float starSpeed, float starSpeedBack) public void CreateParticles(float beat, bool toggle, float starDensity, float starSpeed, float starSpeedBack)
@ -430,11 +512,6 @@ namespace HeavenStudio.Games
break; break;
} }
} }
public void Nothing()
{
}
} }
} }

View file

@ -31,6 +31,7 @@ namespace HeavenStudio.Games.Scripts_LaunchParty
void Update() void Update()
{ {
if (GameManager.instance.currentGame != "launchParty") Destroy(gameObject);
if (PlayerInput.Pressed() && !game.IsExpectingInputNow(InputType.STANDARD_DOWN) && !noInput) if (PlayerInput.Pressed() && !game.IsExpectingInputNow(InputType.STANDARD_DOWN) && !noInput)
{ {
Jukebox.PlayOneShotGame("launchParty/miss"); Jukebox.PlayOneShotGame("launchParty/miss");