Nightwalk GBA (#569)

* Nightwalks set up

* Play yan with balloons

* platformSetUp

* Platform handler fundamentals

* Count In Added

* small thing

* Got em inputs in nightwalk gba to work

* Platforms now spawn when there's no count-in

* He jumps now!

* Decreased platform count

* Height changes added

* Randomness for height changes

* Name changing

* Fixed a bug with no count in blocks

* Ok height changes should be flawless now

* No jumping added

* Umbrella and lollipop added

* Umbrella drum pattern added

* Fallyan :(

* Implemented falling :(

* Fixed drum patterns not working

* Fish implemented

* Fixed kick sound being weird

* 4 beat count in added

* Tweaked landing pos

* Walking Count-In added

* new sprites touched up anims

* oops1

* barely anims

* Implemented barelies into nightwalk gba

* Balloons have random positioning now

* New sounds and whiff/barely sounds

* Fall smear added

* Fixed issues with platform heights on gameswitches

* 24 platforms

* walk is normalized now

* Star scrolling functionality done

* Blink animations n stuff

* STARS BLINK NOW

* Force evolve added + tweaks

* Fixed stars not stopping + upped amount of stars

* End event setup

* Finding end blocks logic added

* end event functionality finished

* end platform anim

* fixed anim

* only stars on screen evolve

* 2 evolve by default

* End event fixes

* more blinking

* star blinks now and has string

* minor tweak

* fix to interaction between fish and end block

* tweaked dropdown values

* removed fish sound

* named some sprites in the spritesheet

* high jump and roll anims

* Roll sound should only play if valid

* Small fix to roll cue sound logic

* Another small fix to roll cue sound logic

* ok actually fixed roll sound

* roll platform added to jumpl platform prefab

* Roll cue platform visuals done

* Basic Roll Cue implemented

* flower

* umbrella

* barely for roll release

* OOPS

* smol fixes

* fixed visual stuff and added missing to rolls

* redid sheet, new anims

* slow walkin'

* adjustments

* oops

* adjusted smear

* improved interaction between roll and end block

* improved interaction between roll cue and platform heights

* 32 stars

* made the star boundary way smaller

* how was i this stupid

* fixed more interactions

* stack proof roll cue and also end block + roll cue fix

* Fixed things related to stars

* fixed no jumping not working with end block + roll

* nearing the final stages

* rolls counts for 2 jumps now

* fixed a bug to do with roll platforms and made roll platform sounds not be able to be played on invalid beats

* made stage 2 stars bigger

* added destroy roll platform sprites

* update to new systems

---------

Co-authored-by: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com>
Co-authored-by: minenice55 <star.elementa@gmail.com>
This commit is contained in:
ev
2024-01-28 01:03:53 -05:00
committed by GitHub
parent 59a0227b07
commit fc55712779
219 changed files with 37202 additions and 0 deletions

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3b145e6ca3f761c40b587dfcb154e23f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,703 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HeavenStudio.Util;
using Jukebox;
using System;
using HeavenStudio.InputSystem;
namespace HeavenStudio.Games.Loaders
{
using static Minigames;
public static class AgbNightWalkLoader
{
public static Minigame AddGame(EventCaller eventCaller)
{
return new Minigame("nightWalkAgb", "Night Walk (GBA)", "FFFFFF", false, false, new List<GameAction>()
{
new GameAction("countIn8", "8 Beat Count-In")
{
preFunction = delegate { if (!eventCaller.currentEntity["mute"] && AgbNightWalk.IsValidCountIn(eventCaller.currentEntity)) AgbNightWalk.CountInSound8(eventCaller.currentEntity.beat); },
defaultLength = 8,
parameters = new List<Param>()
{
new Param("mute", false, "Mute Cowbell")
}
},
new GameAction("countIn4", "4 Beat Count-In")
{
preFunction = delegate { if (!eventCaller.currentEntity["mute"] && AgbNightWalk.IsValidCountIn(eventCaller.currentEntity)) AgbNightWalk.CountInSound4(eventCaller.currentEntity.beat); },
defaultLength = 4,
parameters = new List<Param>()
{
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"),
new Param("rmin", new EntityTypes.Integer(-10, 10, 0), "Random Units (Minimum)"),
new Param("rmax", new EntityTypes.Integer(-10, 10, 0), "Random Units (Maximum)"),
}
},
new GameAction("type", "Platform Type")
{
preFunction = delegate
{
var e = eventCaller.currentEntity;
if (e["type"] == (int)AgbNightWalk.PlatformType.Umbrella)
{
AgbNightWalk.FillSound(e.beat, (AgbNightWalk.FillType)e["fill"]);
}
},
parameters = new List<Param>()
{
new Param("type", AgbNightWalk.PlatformType.Lollipop, "Type"),
new Param("fill", AgbNightWalk.FillType.None, "Umbrella Drum Pattern")
},
preFunctionLength = 1
},
new GameAction("fish", "Electric Fish")
{
},
new GameAction("roll", "Roll")
{
preFunctionLength = 1,
defaultLength = 2,
preFunction = delegate { var e = eventCaller.currentEntity; if (!e["mute"]) AgbNightWalk.PlayRollCue(e.beat, e); },
parameters = new List<Param>()
{
new Param("mute", false, "Mute Sound")
}
},
new GameAction("end", "End")
{
parameters = new List<Param>()
{
new Param("minAmount", new EntityTypes.Integer(0, 1000, 10), "Minimum Jumps Required"),
new Param("minAmountP", new EntityTypes.Integer(0, 1000, 0), "Minimum Jumps Required (Persistent)"),
}
},
new GameAction("noJump", "No Jumping")
{
defaultLength = 4,
resizable = true
},
new GameAction("walkingCountIn", "Walking Count-In")
{
preFunction = delegate { var e = eventCaller.currentEntity; AgbNightWalk.WalkingCountIn(e.beat, e.length); },
defaultLength = 4,
resizable = true
},
new GameAction("evolveAmount", "Star Evolve Amount")
{
function = delegate { AgbNightWalk.instance.evolveAmount = eventCaller.currentEntity["am"]; },
defaultLength = 0.5f,
parameters = new List<Param>()
{
new Param("am", new EntityTypes.Integer(0, 100, 1), "Amount", "How many stars will evolve when play-yan jumps?"),
}
},
new GameAction("forceEvolve", "Force Star Evolve")
{
function = delegate { var e = eventCaller.currentEntity; AgbNightWalk.instance.ForceEvolve(e.beat, e.length, e["am"], e["repeat"]); },
resizable = true,
parameters = new List<Param>()
{
new Param("am", new EntityTypes.Integer(0, 100, 1), "Star Amount", "How many stars will evolve?"),
new Param("repeat", new EntityTypes.Integer(0, 100, 1), "Repeat Amount", "How many times will this event repeat?"),
}
},
});
}
}
}
namespace HeavenStudio.Games
{
using Scripts_AgbNightWalk;
public class AgbNightWalk : Minigame
{
public enum PlatformType
{
Lollipop = 2,
Umbrella = 3
}
public enum FillType
{
None,
Pattern1,
Pattern2,
Pattern3,
}
public static AgbNightWalk instance;
public AgbPlayYan playYan;
[SerializeField] private AgbPlatformHandler platformHandler;
public AgbStarHandler starHandler;
[NonSerialized] public double countInBeat = double.MinValue;
[NonSerialized] public float countInLength = 8;
[Header("Curves")]
[SerializeField] SuperCurveObject.Path[] jumpPaths;
private struct HeightEvent
{
public double beat;
public int value;
}
List<HeightEvent> heightEntityEvents = new();
[NonSerialized] public Dictionary<double, TypeEvent> platformTypes = new();
private List<double> fishBeats = new();
private List<double> rollBeats = new();
public struct TypeEvent
{
public PlatformType platformType;
public FillType fillType;
}
[NonSerialized] public int evolveAmount = 1;
[NonSerialized] public int hitJumps;
[NonSerialized] public static int hitJumpsPersist;
[NonSerialized] public double endBeat = double.MaxValue;
[NonSerialized] public int requiredJumps;
[NonSerialized] public int requiredJumpsP;
const int IAAltDownCat = IAMAXCAT;
const int IAAltUpCat = IAMAXCAT + 1;
protected static bool IA_PadAltDown(out double dt)
{
return PlayerInput.GetPadDown(InputController.ActionsPad.South, out dt);
}
protected static bool IA_BatonAltDown(out double dt)
{
return PlayerInput.GetSqueezeDown(out dt);
}
protected static bool IA_TouchAltDown(out double dt)
{
return PlayerInput.GetTouchDown(InputController.ActionsTouch.Tap, out dt)
&& instance.IsExpectingInputNow(InputAction_AltDown);
}
protected static bool IA_PadAltUp(out double dt)
{
return PlayerInput.GetPadUp(InputController.ActionsPad.South, out dt);
}
protected static bool IA_BatonAltUp(out double dt)
{
return PlayerInput.GetSqueezeUp(out dt);
}
protected static bool IA_TouchAltUp(out double dt)
{
return PlayerInput.GetFlick(out dt)
&& instance.IsExpectingInputNow(InputAction_AltUp);
}
protected static bool IA_EmptyTouchUp(out double dt)
{
return PlayerInput.GetTouchUp(InputController.ActionsTouch.Tap, out dt) && !PlayerInput.GetFlick(out _);
}
public static PlayerInput.InputAction InputAction_AltDown =
new("KarateAltDown", new int[] { IAAltDownCat, IAAltDownCat, IAAltDownCat },
IA_PadAltDown, IA_TouchAltDown, IA_BatonAltDown);
public static PlayerInput.InputAction InputAction_AltUp =
new("KarateAltUp", new int[] { IAAltUpCat, IAAltUpCat, IAAltUpCat },
IA_PadAltUp, IA_TouchAltUp, IA_BatonAltUp);
public static PlayerInput.InputAction InputAction_TouchUp =
new("KarateAltUp", new int[] { IAEmptyCat, IAReleaseCat, IAEmptyCat },
IA_PadAltUp, IA_EmptyTouchUp, IA_BatonAltUp);
new void OnDrawGizmos()
{
base.OnDrawGizmos();
foreach (SuperCurveObject.Path path in jumpPaths)
{
if (path.preview)
{
playYan.DrawEditorGizmo(path);
}
}
}
public SuperCurveObject.Path GetPath(string name)
{
foreach (SuperCurveObject.Path path in jumpPaths)
{
if (path.name == name)
{
return path;
}
}
return default(SuperCurveObject.Path);
}
private void Awake()
{
instance = this;
List<RiqEntity> heightEvents = EventCaller.GetAllInGameManagerList("nightWalkAgb", new string[] { "height" });
List<RiqEntity> rollEvents = EventCaller.GetAllInGameManagerList("nightWalkAgb", new string[] { "roll" });
var validRollEvents = rollEvents.FindAll(x => IsValidRollCue(x));
foreach (var heightEvent in heightEvents)
{
if (validRollEvents.Count > 0 && validRollEvents.Find(x => heightEvent.beat >= x.beat + 1 && heightEvent.beat < x.beat + 2) != null) continue;
heightEntityEvents.Add(new HeightEvent()
{
beat = heightEvent.beat,
value = heightEvent["value"] + UnityEngine.Random.Range(heightEvent["rmin"], heightEvent["rmax"] + 1)
});
}
List<RiqEntity> typeEvents = EventCaller.GetAllInGameManagerList("nightWalkAgb", new string[] { "type" });
foreach (var typeEvent in typeEvents)
{
if (!platformTypes.ContainsKey(typeEvent.beat))
{
PlatformType type = (PlatformType)typeEvent["type"];
FillType fill = (FillType)typeEvent["fill"];
platformTypes.Add(typeEvent.beat, new TypeEvent
{
fillType = fill,
platformType = type
});
}
}
List<RiqEntity> fishEvents = EventCaller.GetAllInGameManagerList("nightWalkAgb", new string[] { "fish" });
foreach(var fishEvent in fishEvents)
{
fishBeats.Add(fishEvent.beat);
}
foreach (var rollEvent in validRollEvents)
{
rollBeats.Add(rollEvent.beat);
}
}
private void OnDestroy()
{
foreach (var evt in scheduledInputs)
{
evt.Disable();
}
if (!Conductor.instance.isPlaying) hitJumpsPersist = 0;
}
public void ForceEvolve(double beat, float length, int starAmount, int repeatAmount)
{
List<BeatAction.Action> actions = new();
for (int i = 0; i < repeatAmount; i++)
{
actions.Add(new BeatAction.Action(beat + (length * i), delegate
{
starHandler.Evolve(starAmount);
}));
}
BeatAction.New(this, actions);
}
public bool FishOnBeat(double beat)
{
return fishBeats.Contains(beat);
}
public bool RollOnBeat(double beat)
{
return rollBeats.Contains(beat);
}
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 bool ShouldNotJumpOnBeat(double beat)
{
List<RiqEntity> heightEvents = EventCaller.GetAllInGameManagerList("nightWalkAgb", new string[] { "noJump" });
return heightEvents.Find(x => beat >= x.beat && beat < x.beat + x.length) != null;
}
public override void OnGameSwitch(double beat)
{
SetCountInBeat(beat);
SetEndValues(beat);
platformHandler.SpawnPlatforms(beat);
}
public override void OnPlay(double beat)
{
SetCountInBeat(beat);
SetEndValues(beat);
platformHandler.SpawnPlatforms(beat);
hitJumpsPersist = 0;
}
public void SetEndValues(double beat)
{
List<RiqEntity> endEvents = EventCaller.GetAllInGameManagerList("nightWalkAgb", new string[] { "end" });
if (endEvents.Count > 0)
{
var allEnds = EventCaller.GetAllInGameManagerList("gameManager", new string[] { "switchGame" });
if (allEnds.Count == 0)
{
endBeat = endEvents[^1].beat;
requiredJumps = endEvents[^1]["minAmount"];
requiredJumpsP = endEvents[^1]["minAmountP"];
}
else
{
allEnds.Sort((x, y) => x.beat.CompareTo(y.beat));
double nextSwitchBeat = double.MaxValue;
foreach (var end in allEnds)
{
if (end.datamodel.Split(2) == "nightWalkAgb") continue;
if (end.beat > beat)
{
nextSwitchBeat = end.beat;
break;
}
}
var tempEvents = endEvents.FindAll(e => e.beat >= beat && e.beat < nextSwitchBeat);
if (tempEvents.Count > 0)
{
endBeat = tempEvents[^1].beat;
requiredJumps = tempEvents[^1]["minAmount"];
requiredJumpsP = tempEvents[^1]["minAmountP"];
}
}
}
}
/*public static void FishSound(double beat)
{
if (GameManager.instance.currentGame == "nightWalkAgb" && instance.platformHandler.PlatformsStopped()) return;
MultiSound.Play(new MultiSound.Sound[]
{
new MultiSound.Sound("nightWalkAgb/fish1", beat - 1),
new MultiSound.Sound("nightWalkAgb/fish2", beat - 0.75),
new MultiSound.Sound("nightWalkAgb/fish3", beat - 0.5),
}, forcePlay: true);
}*/
public static bool IsValidRollCue(RiqEntity entity)
{
List<RiqEntity> allEnds = EventCaller.GetAllInGameManagerList("gameManager", new string[] { "switchGame" });
List<RiqEntity> allRolls = EventCaller.GetAllInGameManagerList("nightWalkAgb", new string[] { "roll" });
if (allRolls.Find(x => x != entity && entity.beat >= x.beat && entity.beat < x.beat + x.length) != null)
{
return false;
}
if (allEnds.Count > 0)
{
List<RiqEntity> tempEnds = new();
foreach (var end in allEnds)
{
if (end.datamodel.Split(2) == "nightWalkAgb")
{
tempEnds.Add(end);
}
}
List<RiqEntity> tempEnds2 = new();
foreach (var end in tempEnds)
{
if (end.beat <= entity.beat) tempEnds2.Add(end);
}
double lastSwitchBeat = double.MinValue;
if (tempEnds2.Count > 0)
{
tempEnds2.Sort((x, y) => x.beat.CompareTo(y.beat));
lastSwitchBeat = tempEnds2[^1].beat;
}
else if (tempEnds.Count > 0)
{
tempEnds.Sort((x, y) => x.beat.CompareTo(y.beat));
lastSwitchBeat = tempEnds[0].beat;
}
double countInBeat = double.MinValue;
float countInLength = 0;
FindCountInBeatAndLength(lastSwitchBeat, ref countInBeat, ref countInLength);
bool isNotOffbeat = entity.beat % 1 == countInBeat % 1;
return entity.beat >= countInBeat + countInLength && entity.beat >= lastSwitchBeat && isNotOffbeat;
}
else
{
double countInBeat = double.MinValue;
float countInLength = 0;
FindCountInBeatAndLength(0, ref countInBeat, ref countInLength);
bool isNotOffbeat = entity.beat % 1 == countInBeat % 1;
return entity.beat >= countInBeat + countInLength && isNotOffbeat;
}
}
public static void FindCountInBeatAndLength(double beat, ref double countInBeat, ref float countInLength)
{
List<RiqEntity> countInEvents = EventCaller.GetAllInGameManagerList("nightWalkAgb", new string[] { "countIn8", "countIn4" });
if (countInEvents.Count > 0)
{
var allEnds = EventCaller.GetAllInGameManagerList("gameManager", new string[] { "switchGame" });
if (allEnds.Count == 0)
{
countInBeat = countInEvents[^1].beat;
countInLength = countInEvents[^1].length;
}
else
{
allEnds.Sort((x, y) => x.beat.CompareTo(y.beat));
double nextSwitchBeat = double.MaxValue;
foreach (var end in allEnds)
{
if (end.datamodel.Split(2) == "nightWalkAgb") continue;
if (end.beat > beat)
{
nextSwitchBeat = end.beat;
break;
}
}
List<RiqEntity> tempEvents = new();
foreach (var countIn in countInEvents)
{
if (countIn.beat < nextSwitchBeat)
{
tempEvents.Add(countIn);
}
}
if (tempEvents.Count > 0)
{
tempEvents.Sort((x, y) => x.beat.CompareTo(y.beat));
countInBeat = tempEvents[tempEvents.Count - 1].beat;
countInLength = tempEvents[tempEvents.Count - 1].length;
}
}
}
}
public static void PlayRollCue(double beat, RiqEntity entity)
{
if (!IsValidRollCue(entity)) return;
Debug.Log("played roll sound");
MultiSound.Play(new MultiSound.Sound[]
{
new MultiSound.Sound("games/nightWalkRvl/highJump1", beat - 1),
new MultiSound.Sound("games/nightWalkRvl/highJump2", beat - 0.75),
new MultiSound.Sound("games/nightWalkRvl/highJump3", beat - 0.5),
new MultiSound.Sound("games/nightWalkRvl/highJump4", beat - 0.25),
new MultiSound.Sound("games/nightWalkRvl/highJump6", beat + 0.25),
}, false, true);
}
public static void WalkingCountIn(double beat, float length)
{
List<MultiSound.Sound> sounds = new();
for (int i = 0; i < length; i++)
{
sounds.Add(new MultiSound.Sound("nightWalkAgb/boxKick", beat + i));
sounds.Add(new MultiSound.Sound("nightWalkAgb/open1", beat + 0.5 + i));
}
MultiSound.Play(sounds.ToArray(), forcePlay: true);
}
public static void FillSound(double beat, FillType fill)
{
if (GameManager.instance.currentGame == "nightWalkAgb" && instance.platformHandler.PlatformsStopped()) return;
double third = 1.0 / 3.0;
switch (fill)
{
case FillType.None:
break;
case FillType.Pattern1:
MultiSound.Play(new MultiSound.Sound[]
{
new MultiSound.Sound("nightWalkAgb/fill1A", beat - (third * 2)),
new MultiSound.Sound("nightWalkAgb/fill1B", beat - 0.5),
new MultiSound.Sound("nightWalkAgb/fill1C", beat - third),
new MultiSound.Sound("nightWalkAgb/fill1D", beat - (third * 0.5)),
}, forcePlay: true);
break;
case FillType.Pattern2:
MultiSound.Play(new MultiSound.Sound[]
{
new MultiSound.Sound("nightWalkAgb/fill2A", beat - (third * 2)),
new MultiSound.Sound("nightWalkAgb/fill2B", beat - 0.5),
new MultiSound.Sound("nightWalkAgb/fill2C", beat - (third * 0.5)),
}, forcePlay: true);
break;
case FillType.Pattern3:
MultiSound.Play(new MultiSound.Sound[]
{
new MultiSound.Sound("nightWalkAgb/fill3A", beat - (third * 2)),
new MultiSound.Sound("nightWalkAgb/fill3B", beat - 0.5),
}, forcePlay: true);
break;
}
}
private void SetCountInBeat(double beat)
{
List<RiqEntity> countInEvents = EventCaller.GetAllInGameManagerList("nightWalkAgb", new string[] { "countIn8", "countIn4" });
if (countInEvents.Count > 0)
{
var allEnds = EventCaller.GetAllInGameManagerList("gameManager", new string[] { "switchGame" });
if (allEnds.Count == 0)
{
countInBeat = countInEvents[^1].beat;
countInLength = countInEvents[^1].length;
}
else
{
allEnds.Sort((x, y) => x.beat.CompareTo(y.beat));
double nextSwitchBeat = double.MaxValue;
foreach (var end in allEnds)
{
if (end.datamodel.Split(2) == "nightWalkAgb") continue;
if (end.beat > beat)
{
nextSwitchBeat = end.beat;
break;
}
}
List<RiqEntity> tempEvents = new();
foreach (var countIn in countInEvents)
{
if (countIn.beat < nextSwitchBeat)
{
tempEvents.Add(countIn);
}
}
if (tempEvents.Count > 0)
{
tempEvents.Sort((x, y) => x.beat.CompareTo(y.beat));
countInBeat = tempEvents[tempEvents.Count - 1].beat;
countInLength = tempEvents[tempEvents.Count - 1].length;
}
}
}
UpdateBalloons(beat);
}
public static bool IsValidCountIn(RiqEntity countInEntity)
{
List<RiqEntity> countInEvents = EventCaller.GetAllInGameManagerList("nightWalkAgb", new string[] { "countIn8", "countIn4" });
if (countInEvents.Count > 0)
{
var allEnds = EventCaller.GetAllInGameManagerList("gameManager", new string[] { "switchGame" });
if (allEnds.Count == 0)
{
return countInEntity == countInEvents[0];
}
else
{
allEnds.Sort((x, y) => x.beat.CompareTo(y.beat));
List<RiqEntity> tempEnds = new();
double beat = double.MinValue;
for (int i = 0; i < allEnds.Count; i++)
{
if (allEnds[i].datamodel.Split(2) == "nightWalkAgb")
{
if (allEnds[i].beat >= countInEntity.beat)
{
tempEnds.Add(allEnds[i]);
}
}
}
if (tempEnds.Count > 0) beat = tempEnds[0].beat;
double nextSwitchBeat = double.MaxValue;
foreach (var end in allEnds)
{
if (end.datamodel.Split(2) == "nightWalkAgb") continue;
if (end.beat > beat)
{
nextSwitchBeat = end.beat;
break;
}
}
List<RiqEntity> tempEvents = new();
foreach (var countIn in countInEvents)
{
if (countIn.beat < nextSwitchBeat)
{
tempEvents.Add(countIn);
}
}
if (tempEvents.Count == 0) return true;
tempEvents.Sort((x, y) => x.beat.CompareTo(y.beat));
return countInEntity == tempEvents[tempEvents.Count - 1];
}
}
return false;
}
private void UpdateBalloons(double beat)
{
if (countInBeat != -1)
{
if (countInLength == 8)
{
BeatAction.New(this, new List<BeatAction.Action>()
{
new BeatAction.Action(countInBeat, delegate { playYan.PopBalloon(0, beat > countInBeat); }),
new BeatAction.Action(countInBeat + 2, delegate { playYan.PopBalloon(1, beat > countInBeat + 2); }),
new BeatAction.Action(countInBeat + 4, delegate { playYan.PopBalloon(2, beat > countInBeat + 4); }),
new BeatAction.Action(countInBeat + 5, delegate { playYan.PopBalloon(3, beat > countInBeat + 5); }),
new BeatAction.Action(countInBeat + 6, delegate { playYan.PopBalloon(4, beat > countInBeat + 6); }),
new BeatAction.Action(countInBeat + 7, delegate { playYan.PopBalloon(5, beat > countInBeat + 7); }),
new BeatAction.Action(countInBeat + 8, delegate { playYan.PopBalloon(6, beat > countInBeat + 8); }),
});
}
else
{
playYan.PopBalloon(0, true);
playYan.PopBalloon(1, true);
BeatAction.New(this, new List<BeatAction.Action>()
{
new BeatAction.Action(countInBeat, delegate { playYan.PopBalloon(2, beat > countInBeat); }),
new BeatAction.Action(countInBeat + 1, delegate { playYan.PopBalloon(3, beat > countInBeat + 1); }),
new BeatAction.Action(countInBeat + 2, delegate { playYan.PopBalloon(4, beat > countInBeat + 2); }),
new BeatAction.Action(countInBeat + 3, delegate { playYan.PopBalloon(5, beat > countInBeat + 3); }),
new BeatAction.Action(countInBeat + 4, delegate { playYan.PopBalloon(6, beat > countInBeat + 4); }),
});
}
}
else
{
playYan.PopAll();
}
}
public static void CountInSound8(double beat)
{
MultiSound.Play(new MultiSound.Sound[]
{
new MultiSound.Sound("count-ins/cowbell", beat),
new MultiSound.Sound("count-ins/cowbell", beat + 2),
new MultiSound.Sound("count-ins/cowbell", beat + 4),
new MultiSound.Sound("count-ins/cowbell", beat + 5),
new MultiSound.Sound("count-ins/cowbell", beat + 6),
new MultiSound.Sound("count-ins/cowbell", beat + 7),
}, false, true);
}
public static void CountInSound4(double beat)
{
MultiSound.Play(new MultiSound.Sound[]
{
new MultiSound.Sound("count-ins/cowbell", beat),
new MultiSound.Sound("count-ins/cowbell", beat + 1),
new MultiSound.Sound("count-ins/cowbell", beat + 2),
new MultiSound.Sound("count-ins/cowbell", beat + 3),
}, false, true);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2da8a7ce973face47ad8d366ee8cd701
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,667 @@
using HeavenStudio.Util;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace HeavenStudio.Games.Scripts_AgbNightWalk
{
public class AgbPlatform : MonoBehaviour
{
public enum PlatformType
{
Flower = 1,
Lollipop = 2,
Umbrella = 3
}
private double startBeat;
[NonSerialized] public double endBeat;
[NonSerialized] public AgbPlatformHandler handler;
private Animator anim;
private AgbNightWalk game;
private PlatformType type = PlatformType.Flower;
private float additionalHeight = 0f;
private int additionalHeightInUnits = 0;
private int lastAdditionalHeightInUnits = 0;
[SerializeField] private GameObject platform;
private bool canKick;
private bool canKickRelease;
private bool doFillStartSound = false;
private PlayerActionEvent inputEvent;
private PlayerActionEvent releaseEvent;
[NonSerialized] public bool stopped;
[SerializeField] private GameObject fallYan;
[SerializeField] private GameObject fallYanRoll;
[SerializeField] private Animator fish;
[SerializeField] private Animator rollPlatform;
[SerializeField] private GameObject rollPlatformLong;
[SerializeField] private GameObject rollPlatformLong2;
private bool playYanIsFalling;
private double playYanFallBeat;
private bool isFish;
private bool isFinalBlock;
private bool isEndEvent;
private bool nextPlatformIsSameHeight;
private bool isRollPlatform;
public void StartInput(double beat, double hitBeat)
{
if (game == null) game = AgbNightWalk.instance;
if (anim == null) anim = GetComponent<Animator>();
if (hitBeat > game.endBeat + 1)
{
foreach (Transform child in transform)
{
child.gameObject.SetActive(false);
}
return;
}
if (game.RollOnBeat(hitBeat - 1))
{
startBeat = beat;
endBeat = hitBeat;
ResetInput();
return;
}
isRollPlatform = game.RollOnBeat(hitBeat);
lastAdditionalHeightInUnits = game.FindHeightUnitsAtBeat(hitBeat);
additionalHeightInUnits = game.FindHeightUnitsAtBeat(hitBeat + (isRollPlatform ? 2 : 1));
additionalHeight = lastAdditionalHeightInUnits * handler.heightAmount;
nextPlatformIsSameHeight = lastAdditionalHeightInUnits == additionalHeightInUnits;
isFinalBlock = hitBeat == game.endBeat + 1;
platform.SetActive(nextPlatformIsSameHeight && !isFinalBlock);
startBeat = beat;
endBeat = hitBeat;
isFish = game.FishOnBeat(endBeat);
fish.gameObject.SetActive(isFish);
isEndEvent = game.endBeat == endBeat;
rollPlatform.transform.parent.gameObject.SetActive(isRollPlatform);
rollPlatformLong.SetActive(nextPlatformIsSameHeight && !isFinalBlock && !isEndEvent);
rollPlatformLong2.SetActive(nextPlatformIsSameHeight && !isFinalBlock && !isEndEvent);
if (isEndEvent)
{
if (isRollPlatform) rollPlatform.Play("EndIdle", 0, 0);
else anim.Play("EndIdle", 0, 0);
}
if (isRollPlatform)
{
platform.SetActive(false);
if (startBeat < endBeat)
{
if (game.ShouldNotJumpOnBeat(endBeat) || isFish)
{
inputEvent = game.ScheduleUserInput(startBeat, endBeat - startBeat, AgbNightWalk.InputAction_AltDown, JustRollHold, RollMissHold, Empty);
if (nextPlatformIsSameHeight && !isFinalBlock && !isEndEvent)
{
BeatAction.New(this, new List<BeatAction.Action>()
{
new BeatAction.Action(endBeat, delegate
{
if (GameManager.instance.autoplay && !stopped)
{
game.playYan.Walk();
}
}),
new BeatAction.Action(endBeat + 0.5, delegate
{
if (GameManager.instance.autoplay && !stopped && !isEndEvent)
{
game.playYan.Walk();
anim.DoScaledAnimationAsync("Note", 0.5f);
SoundByte.PlayOneShotGame("nightWalkAgb/open" + (int)type);
}
}),
new BeatAction.Action(endBeat + 1, delegate
{
if (GameManager.instance.autoplay && !stopped && !isEndEvent)
{
rollPlatform.DoScaledAnimationAsync("Note", 0.5f);
SoundByte.PlayOneShotGame("nightWalkAgb/open" + (int)type);
}
})
});
}
else
{
BeatAction.New(this, new List<BeatAction.Action>()
{
new BeatAction.Action(endBeat + 0.5, delegate
{
if (GameManager.instance.autoplay && !stopped)
{
handler.StopAll();
handler.DestroyPlatforms(endBeat + 2, endBeat - 3, endBeat + 6);
SoundByte.PlayOneShotGame("nightWalkAgb/wot");
game.playYan.Hide();
fallYanRoll.SetActive(true);
fallYanRoll.GetComponent<Animator>().DoScaledAnimationAsync("FallSmear", 0.5f);
}
})
});
}
}
else
{
inputEvent = game.ScheduleInput(startBeat, endBeat - startBeat, AgbNightWalk.InputAction_AltDown, JustRollHold, RollMissHold, Empty);
}
canKick = true;
BeatAction.New(this, new List<BeatAction.Action>()
{
new BeatAction.Action(endBeat, delegate
{
if (!stopped)
{
SoundByte.PlayOneShotGame("nightWalkAgb/boxKick");
if (canKick)
{
anim.Play("Kick", 0, 0);
}
}
}),
});
if (nextPlatformIsSameHeight && !isEndEvent)
{
canKickRelease = true;
BeatAction.New(this, new List<BeatAction.Action>()
{
new BeatAction.Action(endBeat + 0.5, delegate
{
if (!stopped)
{
SoundByte.PlayOneShotGame("nightWalkAgb/boxKick");
if (canKickRelease)
{
rollPlatform.Play("Kick", 0, 0);
}
}
}),
});
}
}
}
else
{
if (game.platformTypes.ContainsKey(hitBeat))
{
if (game.platformTypes[hitBeat].platformType == AgbNightWalk.PlatformType.Lollipop)
{
type = PlatformType.Lollipop;
}
else
{
type = PlatformType.Umbrella;
}
doFillStartSound = false;
}
else
{
type = PlatformType.Flower;
if (game.platformTypes.ContainsKey(hitBeat + 1))
{
doFillStartSound = game.platformTypes[hitBeat + 1].fillType != AgbNightWalk.FillType.None;
}
}
if (startBeat < endBeat)
{
if (game.ShouldNotJumpOnBeat(endBeat) || isFish)
{
inputEvent = AgbNightWalk.instance.ScheduleUserInput(startBeat, endBeat - startBeat, Minigame.InputAction_BasicPress, isEndEvent ? JustEnd : Just, Miss, Empty);
if (nextPlatformIsSameHeight && !isFinalBlock)
{
BeatAction.New(this, new List<BeatAction.Action>()
{
new BeatAction.Action(endBeat, delegate
{
if (GameManager.instance.autoplay && !stopped)
{
game.playYan.Walk();
}
}),
new BeatAction.Action(endBeat + 0.5, delegate
{
if (GameManager.instance.autoplay && !stopped && !isEndEvent)
{
anim.DoScaledAnimationAsync("Note", 0.5f);
SoundByte.PlayOneShotGame("nightWalkAgb/open" + (int)type);
}
})
});
}
else
{
BeatAction.New(this, new List<BeatAction.Action>()
{
new BeatAction.Action(endBeat, delegate
{
if (GameManager.instance.autoplay && !stopped)
{
handler.StopAll();
handler.DestroyPlatforms(endBeat + 2, endBeat - 3, endBeat + 6);
SoundByte.PlayOneShotGame("nightWalkAgb/wot");
game.playYan.Hide();
fallYan.SetActive(true);
fallYan.GetComponent<Animator>().DoScaledAnimationAsync("FallSmear", 0.5f);
}
})
});
}
}
else if (!isFish)
{
inputEvent = AgbNightWalk.instance.ScheduleInput(startBeat, endBeat - startBeat, Minigame.InputAction_BasicPress, isEndEvent ? JustEnd : Just, Miss, Empty);
}
if (nextPlatformIsSameHeight && !isEndEvent)
{
canKick = true;
BeatAction.New(this, new List<BeatAction.Action>()
{
new BeatAction.Action(endBeat, delegate
{
if (!stopped)
{
SoundByte.PlayOneShotGame("nightWalkAgb/boxKick");
if (canKick)
{
anim.Play("Kick", 0, 0);
}
}
})
});
}
}
}
}
private void Awake()
{
game = AgbNightWalk.instance;
anim = GetComponent<Animator>();
Update();
}
private bool startGlowing;
private void Update()
{
var cond = Conductor.instance;
if (cond.isPlaying && !cond.isPaused)
{
if (!stopped)
{
float normalizedBeat = cond.GetPositionFromBeat(startBeat, endBeat - startBeat);
float newPosX = Mathf.LerpUnclamped(handler.playerXPos + (float)((endBeat - startBeat) * handler.platformDistance), handler.playerXPos, normalizedBeat);
transform.localPosition = new Vector3(newPosX, handler.defaultYPos + additionalHeight);
if (cond.songPositionInBeats > endBeat + (handler.platformCount * 0.5f))
{
ResetInput();
}
}
if (playYanIsFalling)
{
float normalizedFallBeat = cond.GetPositionFromBeat(playYanFallBeat, 2);
EasingFunction.Function func = EasingFunction.GetEasingFunction(EasingFunction.Ease.EaseInQuad);
float newPlayYanY = func(0, -12, normalizedFallBeat);
if (fallYan.activeSelf) fallYan.transform.localPosition = new Vector3(0, newPlayYanY);
else if (fallYanRoll.activeSelf) fallYanRoll.transform.localPosition = new Vector3(fallYanRoll.transform.localPosition.x, newPlayYanY);
}
if (!startGlowing && isEndEvent && game.hitJumps >= game.requiredJumps && AgbNightWalk.hitJumpsPersist >= game.requiredJumpsP)
{
if (isRollPlatform) rollPlatform.DoScaledAnimationAsync("EndGlow", 0.5f);
else anim.DoScaledAnimationAsync("EndGlow", 0.5f);
startGlowing = true;
}
}
}
public void Stop()
{
stopped = true;
if (inputEvent != null) inputEvent.Disable();
if (releaseEvent != null) releaseEvent.Disable();
}
public void Disappear(double beat)
{
anim.DoScaledAnimationAsync("Destroy", 0.5f);
rollPlatform.DoScaledAnimationAsync("Destroy", 0.5f);
SoundByte.PlayOneShotGame("nightWalkAgb/disappear");
if (fallYan.activeSelf || fallYanRoll.activeSelf)
{
SoundByte.PlayOneShotGame("nightWalkAgb/fall");
playYanIsFalling = true;
playYanFallBeat = beat;
Update();
}
}
private void ResetInput(float multiplier = 0.5f)
{
double newStartBeat = endBeat + (handler.platformCount * multiplier);
anim.Play("Idle", 0, 0);
StartInput(newStartBeat, newStartBeat + (handler.platformCount * multiplier));
}
private void JustRollHold(PlayerActionEvent caller, float state)
{
canKick = false;
if (caller.noAutoplay)
{
releaseEvent = game.ScheduleUserInput(startBeat, endBeat - startBeat + 0.5, AgbNightWalk.InputAction_AltUp, JustRollRelease, RollMissRelease, Empty);
}
else
{
releaseEvent = game.ScheduleInput(startBeat, endBeat - startBeat + 0.5, AgbNightWalk.InputAction_AltUp, JustRollRelease, RollMissRelease, Empty);
}
if (state >= 1f || state <= -1f)
{
anim.DoScaledAnimationAsync("FlowerBarely", 0.5f);
return;
}
game.playYan.Roll(Conductor.instance.songPositionInBeats);
SoundByte.PlayOneShot("games/nightWalkRvl/highJump5");
anim.DoScaledAnimationAsync("Flower", 0.5f);
}
private void JustRollRelease(PlayerActionEvent caller, float state)
{
canKickRelease = false;
double beat = Conductor.instance.songPositionInBeats;
if (isEndEvent)
{
if (game.hitJumps >= game.requiredJumps && AgbNightWalk.hitJumpsPersist >= game.requiredJumpsP)
{
rollPlatform.DoScaledAnimationAsync("EndPop", 0.5f);
handler.StopAll();
handler.DestroyPlatforms(caller.timer + caller.startBeat + 2, endBeat - 2, endBeat + 1);
game.playYan.Float(Conductor.instance.songPositionInBeats);
handler.DevolveAll();
if (isFish)
{
BeatAction.New(this, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 1, delegate
{
game.ScoreMiss();
game.playYan.Shock();
fish.DoScaledAnimationAsync("Shock", 0.5f);
}),
new BeatAction.Action(caller.timer + caller.startBeat + 4, delegate
{
game.playYan.Fall(caller.timer + caller.startBeat + 4);
fish.DoScaledAnimationAsync("FishIdle", 0.5f);
})
});
}
}
else
{
if (isFish)
{
game.ScoreMiss();
game.playYan.transform.localPosition = new Vector3(0, 2);
game.playYan.Shock(true);
fish.DoScaledAnimationAsync("Shock", 0.5f);
handler.StopAll();
handler.DestroyPlatforms(caller.timer + caller.startBeat + 2, endBeat - 2, endBeat + 6);
BeatAction.New(this, new List<BeatAction.Action>()
{
new BeatAction.Action(caller.timer + caller.startBeat + 4, delegate
{
game.playYan.Fall(caller.timer + caller.startBeat + 4);
fish.DoScaledAnimationAsync("FishIdle", 0.5f);
})
});
}
else
{
game.playYan.HighJump(beat, true, state >= 1f || state <= -1f);
handler.DestroyPlatforms(caller.timer + caller.startBeat + 2, endBeat - 2, endBeat);
double missTime = 1.5 - Conductor.instance.SecsToBeats(Minigame.justEarlyTime, Conductor.instance.GetBpmAtBeat(beat));
BeatAction.New(this, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + missTime, delegate
{
game.ScoreMiss();
handler.StopAll();
}),
});
}
}
}
else
{
handler.RaiseHeight(beat, lastAdditionalHeightInUnits, additionalHeightInUnits);
game.playYan.HighJump(beat, isFinalBlock, state >= 1f || state <= -1f);
if (isFish)
{
game.ScoreMiss();
game.playYan.transform.localPosition = new Vector3(0, 2);
game.playYan.Shock(true);
fish.DoScaledAnimationAsync("Shock", 0.5f);
handler.StopAll();
handler.DestroyPlatforms(caller.timer + caller.startBeat + 2, endBeat - 2, endBeat + 6);
BeatAction.New(this, new List<BeatAction.Action>()
{
new BeatAction.Action(caller.timer + caller.startBeat + 4, delegate
{
game.playYan.Fall(caller.timer + caller.startBeat + 4);
fish.DoScaledAnimationAsync("FishIdle", 0.5f);
})
});
}
else if (isFinalBlock)
{
handler.DestroyPlatforms(caller.timer + caller.startBeat + 2, endBeat - 2, endBeat);
double missTime2 = 1.5 - Conductor.instance.SecsToBeats(Minigame.justEarlyTime, Conductor.instance.GetBpmAtBeat(beat));
BeatAction.New(this, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + missTime2, delegate
{
game.ScoreMiss();
handler.StopAll();
}),
});
}
}
if (state >= 1f || state <= -1f)
{
SoundByte.PlayOneShotGame("nightWalkAgb/ng");
if (!isEndEvent) rollPlatform.DoScaledAnimationAsync("UmbrellaBarely", 0.5f);
return;
}
SoundByte.PlayOneShot("games/nightWalkRvl/highJump7");
if (!isEndEvent) rollPlatform.DoScaledAnimationAsync("Umbrella", 0.5f);
game.starHandler.Evolve(game.evolveAmount * 2);
game.hitJumps += 2;
AgbNightWalk.hitJumpsPersist += 2;
}
private void RollMissHold(PlayerActionEvent caller)
{
if (caller.noAutoplay)
{
releaseEvent = game.ScheduleUserInput(startBeat, endBeat - startBeat + 0.5, AgbNightWalk.InputAction_AltUp, JustRollRelease, RollMissRelease, Empty);
}
else
{
releaseEvent = game.ScheduleInput(startBeat, endBeat - startBeat + 0.5, AgbNightWalk.InputAction_AltUp, JustRollRelease, RollMissRelease, Empty);
}
releaseEvent.canHit = false;
game.playYan.Walk();
SoundByte.PlayOneShotGame("nightWalkAgb/open" + (int)type, caller.timer + caller.startBeat + 0.5);
BeatAction.New(this, new List<BeatAction.Action>()
{
new BeatAction.Action(caller.timer + caller.startBeat + 0.5, delegate { anim.DoScaledAnimationAsync("Note", 0.5f); })
});
}
private void RollMissRelease(PlayerActionEvent caller)
{
if (nextPlatformIsSameHeight && !isEndEvent)
{
game.playYan.Walk();
SoundByte.PlayOneShotGame("nightWalkAgb/open" + (int)type, caller.timer + caller.startBeat + 0.5);
BeatAction.New(this, new List<BeatAction.Action>()
{
new BeatAction.Action(caller.timer + caller.startBeat + 0.5, delegate { rollPlatform.DoScaledAnimationAsync("Note", 0.5f); })
});
}
else
{
handler.StopAll();
handler.DestroyPlatforms(caller.timer + caller.startBeat + 1.5, endBeat - 2, endBeat + 6);
SoundByte.PlayOneShotGame("nightWalkAgb/wot");
game.playYan.Hide();
fallYanRoll.SetActive(true);
fallYanRoll.GetComponent<Animator>().DoScaledAnimationAsync("FallSmear", 0.5f);
}
}
private void Just(PlayerActionEvent caller, float state)
{
canKick = false;
double beat = Conductor.instance.songPositionInBeats;
handler.RaiseHeight(beat, lastAdditionalHeightInUnits, additionalHeightInUnits);
game.playYan.Jump(beat, isFinalBlock);
if (isFish)
{
BeatAction.New(this, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 0.5, delegate
{
game.ScoreMiss();
game.playYan.Shock();
fish.DoScaledAnimationAsync("Shock", 0.5f);
handler.StopAll();
handler.DestroyPlatforms(caller.timer + caller.startBeat + 2, endBeat - 2, endBeat + 6);
}),
new BeatAction.Action(caller.timer + caller.startBeat + 4, delegate
{
game.playYan.Fall(caller.timer + caller.startBeat + 4);
fish.DoScaledAnimationAsync("FishIdle", 0.5f);
})
});
}
else if (isFinalBlock)
{
handler.DestroyPlatforms(caller.timer + caller.startBeat + 2, endBeat - 2, endBeat);
double missTime = 1 - Conductor.instance.SecsToBeats(Minigame.justEarlyTime, Conductor.instance.GetBpmAtBeat(beat));
BeatAction.New(this, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + missTime, delegate
{
game.ScoreMiss();
handler.StopAll();
}),
});
}
if (state >= 1 || state <= -1)
{
SoundByte.PlayOneShotGame("nightWalkAgb/ng");
switch (type)
{
case PlatformType.Flower:
anim.DoScaledAnimationAsync("FlowerBarely", 0.5f);
break;
case PlatformType.Lollipop:
anim.DoScaledAnimationAsync("LollipopBarely", 0.5f);
break;
case PlatformType.Umbrella:
anim.DoScaledAnimationAsync("UmbrellaBarely", 0.5f);
break;
}
return;
}
if (doFillStartSound) SoundByte.PlayOneShotGame("nightWalkAgb/fillStart");
else SoundByte.PlayOneShotGame("nightWalkAgb/jump" + (int)type);
switch (type)
{
case PlatformType.Flower:
anim.DoScaledAnimationAsync("Flower", 0.5f);
break;
case PlatformType.Lollipop:
anim.DoScaledAnimationAsync("Lollipop", 0.5f);
break;
case PlatformType.Umbrella:
anim.DoScaledAnimationAsync("Umbrella", 0.5f);
break;
}
game.starHandler.Evolve(game.evolveAmount);
game.hitJumps++;
AgbNightWalk.hitJumpsPersist++;
}
private void JustEnd(PlayerActionEvent caller, float state)
{
double beat = caller.timer + caller.startBeat;
if (game.hitJumps >= game.requiredJumps && AgbNightWalk.hitJumpsPersist >= game.requiredJumpsP)
{
anim.DoScaledAnimationAsync("EndPop", 0.5f);
handler.StopAll();
handler.DestroyPlatforms(caller.timer + caller.startBeat + 2, endBeat - 2, endBeat + 1);
game.playYan.Float(Conductor.instance.songPositionInBeats);
handler.DevolveAll();
if (isFish)
{
BeatAction.New(this, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 0.5, delegate
{
game.ScoreMiss();
game.playYan.Shock();
fish.DoScaledAnimationAsync("Shock", 0.5f);
}),
new BeatAction.Action(caller.timer + caller.startBeat + 4, delegate
{
game.playYan.Fall(caller.timer + caller.startBeat + 4);
fish.DoScaledAnimationAsync("FishIdle", 0.5f);
})
});
}
}
else
{
handler.RaiseHeight(beat, lastAdditionalHeightInUnits, additionalHeightInUnits);
game.playYan.Jump(beat);
}
}
private void Miss(PlayerActionEvent caller)
{
if (nextPlatformIsSameHeight)
{
game.playYan.Walk();
SoundByte.PlayOneShotGame("nightWalkAgb/open" + (int)type, caller.timer + caller.startBeat + 0.5);
BeatAction.New(this, new List<BeatAction.Action>()
{
new BeatAction.Action(caller.timer + caller.startBeat + 0.5, delegate { anim.DoScaledAnimationAsync("Note", 0.5f); })
});
}
else
{
handler.StopAll();
handler.DestroyPlatforms(caller.timer + caller.startBeat + 2, endBeat - 2, endBeat + 6);
SoundByte.PlayOneShotGame("nightWalkAgb/wot");
game.playYan.Hide();
fallYan.SetActive(true);
fallYan.GetComponent<Animator>().DoScaledAnimationAsync("FallSmear", 0.5f);
}
}
private void Empty(PlayerActionEvent caller) { }
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2b6892a770a77394ca687ef93f8935db
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,139 @@
using HeavenStudio.Util;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace HeavenStudio.Games.Scripts_AgbNightWalk
{
public class AgbPlatformHandler : MonoBehaviour
{
private AgbNightWalk game;
[Header("Properties")]
[SerializeField] private AgbPlatform platformRef;
[SerializeField] private AgbStarHandler starHandler;
public float defaultYPos = -11.76f;
public float heightAmount = 2;
public float platformDistance = 3.80f;
public float playerXPos = -6.78f;
[SerializeField] private float starLength = 16;
[SerializeField] private float starHeight = 0.0625f;
[Range(1, 100)]
public int platformCount = 20;
private float lastHeight = 0;
private float heightToRaiseTo = 0;
private double raiseBeat = double.MinValue;
[NonSerialized] public List<AgbPlatform> allPlatforms = new();
private int lastHeightUnits;
private int currentHeightUnits;
private bool stopStars;
private void Awake()
{
game = AgbNightWalk.instance;
}
public void SpawnPlatforms(double beat)
{
if (game.countInBeat != double.MinValue)
{
for (int i = 0; i < platformCount; i++)
{
AgbPlatform platform = Instantiate(platformRef, transform);
allPlatforms.Add(platform);
platform.handler = this;
platform.StartInput(game.countInBeat + i + game.countInLength - (platformCount * 0.5), game.countInBeat + i + game.countInLength);
platform.gameObject.SetActive(true);
}
}
else
{
double firstInputBeat = Math.Ceiling(beat);
for (int i = 0; i < platformCount; i++)
{
AgbPlatform platform = Instantiate(platformRef, transform);
allPlatforms.Add(platform);
platform.handler = this;
platform.StartInput(beat, firstInputBeat + i - platformCount);
platform.gameObject.SetActive(true);
}
int lastUnits = game.FindHeightUnitsAtBeat(firstInputBeat - 1);
int currentUnits = game.FindHeightUnitsAtBeat(firstInputBeat);
RaiseHeight(firstInputBeat - 1, lastUnits, currentUnits);
if (lastUnits != currentUnits)
{
game.playYan.Jump(firstInputBeat - 1);
}
}
}
private void Update()
{
var cond = Conductor.instance;
if (cond.isPlaying && !cond.isPaused)
{
if (raiseBeat != double.MinValue)
{
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);
starHandler.normalizedY = -func(starHeight * lastHeightUnits, starHeight * currentHeightUnits, normalizedBeat);
}
if (stopStars) return;
float normalizedValue = cond.GetPositionFromBeat(0, starLength);
starHandler.normalizedX = -normalizedValue;
}
}
public void StopAll()
{
foreach (var platform in allPlatforms)
{
platform.Stop();
}
stopStars = true;
}
public void DevolveAll()
{
starHandler.Devolve();
}
public bool PlatformsStopped()
{
return allPlatforms[0].stopped;
}
public void DestroyPlatforms(double startBeat, double firstBeat, double lastBeat)
{
List<AgbPlatform> platformsToDestroy = allPlatforms.FindAll(x => x.endBeat >= firstBeat && x.endBeat <= lastBeat);
platformsToDestroy.Sort((x, y) => x.endBeat.CompareTo(y.endBeat));
List<BeatAction.Action> actions = new();
for (int i = 0; i < platformsToDestroy.Count; i++)
{
AgbPlatform currentPlatformToDdestroy = platformsToDestroy[i];
double fallBeat = startBeat + i;
actions.Add(new BeatAction.Action(fallBeat, delegate
{
currentPlatformToDdestroy.Disappear(fallBeat);
}));
}
BeatAction.New(this, actions);
}
public void RaiseHeight(double beat, int lastUnits, int currentUnits)
{
raiseBeat = beat;
lastHeight = lastUnits * heightAmount * transform.localScale.y;
heightToRaiseTo = currentUnits * heightAmount * transform.localScale.y;
currentHeightUnits = currentUnits;
lastHeightUnits = lastUnits;
Update();
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fc6d77daa4e399f4fbac22c2f7de8777
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,251 @@
using HeavenStudio.Util;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace HeavenStudio.Games.Scripts_AgbNightWalk
{
public class AgbPlayYan : SuperCurveObject
{
private enum JumpingState
{
Flying,
Walking,
Jumping,
Shocked,
Falling,
Whiffing,
Floating,
Rolling,
HighJumping,
JumpingFall,
HighJumpingFall
}
private JumpingState jumpingState;
private AgbNightWalk game;
private double jumpBeat;
[SerializeField] private List<Animator> balloons = new List<Animator>();
[SerializeField] private Animator star;
private Path jumpPath;
private Path whiffPath;
private Path highJumpPath;
private Animator anim;
private float fallStartY;
private double playYanFallBeat;
private double walkBeat;
[SerializeField] private float randomMinBalloonX = -0.45f;
[SerializeField] private float randomMaxBalloonX = 0.45f;
[SerializeField] private Transform spriteTrans; //for rolling rotation
private void Awake()
{
game = AgbNightWalk.instance;
jumpPath = game.GetPath("Jump");
whiffPath = game.GetPath("Whiff");
highJumpPath = game.GetPath("highJump");
anim = GetComponent<Animator>();
foreach (var balloon in balloons)
{
balloon.Play("Idle", 0, UnityEngine.Random.Range(0f, 1f));
Transform balloonTrans = balloon.transform.parent;
balloonTrans.localPosition = new Vector3(balloonTrans.localPosition.x + UnityEngine.Random.Range(randomMinBalloonX, randomMaxBalloonX), balloonTrans.localPosition.y);
}
}
bool hasFallen;
private void Update()
{
var cond = Conductor.instance;
if (cond.isPlaying && !cond.isPaused)
{
switch (jumpingState)
{
case JumpingState.Jumping:
Vector3 pos = GetPathPositionFromBeat(jumpPath, Math.Min(jumpBeat + jumpPath.positions[0].duration, cond.songPositionInBeatsAsDouble), jumpBeat);
transform.localPosition = pos;
float normalizedBeat = cond.GetPositionFromBeat(jumpBeat, jumpPath.positions[0].duration);
if (normalizedBeat >= 1f)
{
Walk();
}
break;
case JumpingState.JumpingFall:
Vector3 posf = GetPathPositionFromBeat(jumpPath, cond.songPositionInBeatsAsDouble, jumpBeat);
transform.localPosition = posf;
float normalizedBeatf = cond.GetPositionFromBeat(jumpBeat, jumpPath.positions[0].duration);
if (normalizedBeatf >= 1f && !hasFallen)
{
hasFallen = true;
SoundByte.PlayOneShotGame("nightWalkAgb/fall");
}
break;
case JumpingState.Walking:
transform.localPosition = Vector3.zero;
anim.DoScaledAnimation("Walk", walkBeat, 0.5f, 0.35f);
if (PlayerInput.GetIsAction(Minigame.InputAction_BasicPress) && !game.IsExpectingInputNow(Minigame.InputAction_BasicPress))
{
Whiff(cond.songPositionInBeatsAsDouble);
}
break;
case JumpingState.Flying:
transform.localPosition = Vector3.zero;
break;
case JumpingState.Shocked:
break;
case JumpingState.Falling:
float normalizedFallBeat = cond.GetPositionFromBeat(playYanFallBeat, 2);
EasingFunction.Function func = EasingFunction.GetEasingFunction(EasingFunction.Ease.EaseInQuad);
float newPlayYanY = func(fallStartY, -12, normalizedFallBeat);
transform.localPosition = new Vector3(0, newPlayYanY);
break;
case JumpingState.Whiffing:
Vector3 pos2 = GetPathPositionFromBeat(whiffPath, Math.Min(jumpBeat + 0.5, cond.songPositionInBeatsAsDouble), jumpBeat);
transform.localPosition = pos2;
float normalizedBeat2 = cond.GetPositionFromBeat(jumpBeat, 0.5);
if (normalizedBeat2 >= 1f)
{
Walk();
}
break;
case JumpingState.Floating:
float normalizedFloatBeat = cond.GetPositionFromBeat(playYanFallBeat, 10);
EasingFunction.Function funcF = EasingFunction.GetEasingFunction(EasingFunction.Ease.Linear);
float newPlayYanYF = funcF(fallStartY, 12, normalizedFloatBeat);
transform.localPosition = new Vector3(0, newPlayYanYF);
break;
case JumpingState.Rolling:
float normalizedRoll = cond.GetPositionFromBeat(jumpBeat, 0.5f);
float newRot = Mathf.LerpUnclamped(0, -360, normalizedRoll);
spriteTrans.localEulerAngles = new Vector3(0, 0, newRot);
break;
case JumpingState.HighJumping:
Vector3 posH = GetPathPositionFromBeat(highJumpPath, Math.Min(jumpBeat + highJumpPath.positions[0].duration, cond.songPositionInBeatsAsDouble), jumpBeat);
transform.localPosition = posH;
float normalizedBeatH = cond.GetPositionFromBeat(jumpBeat, highJumpPath.positions[0].duration);
if (normalizedBeatH >= 1f)
{
Walk();
}
break;
case JumpingState.HighJumpingFall:
Vector3 posHf = GetPathPositionFromBeat(highJumpPath, cond.songPositionInBeatsAsDouble, jumpBeat);
transform.localPosition = posHf;
float normalizedBeatHf = cond.GetPositionFromBeat(jumpBeat, highJumpPath.positions[0].duration);
if (normalizedBeatHf >= 1f && !hasFallen)
{
hasFallen = true;
SoundByte.PlayOneShotGame("nightWalkAgb/fall");
}
break;
}
}
}
public void Shock(bool roll = false)
{
jumpingState = JumpingState.Shocked;
anim.DoScaledAnimationAsync(roll ? "RollShock" : "Shock", 0.5f);
SoundByte.PlayOneShotGame("nightWalkAgb/shock");
spriteTrans.localEulerAngles = Vector3.zero;
}
public void Fall(double beat)
{
jumpingState = JumpingState.Falling;
anim.Play("Jump", 0, 0);
playYanFallBeat = beat;
fallStartY = transform.localPosition.y;
SoundByte.PlayOneShotGame("nightWalkAgb/fall");
spriteTrans.localEulerAngles = Vector3.zero;
Update();
}
public void Float(double beat)
{
jumpingState = JumpingState.Floating;
anim.Play("Jump", 0, 0);
playYanFallBeat = beat;
fallStartY = transform.localPosition.y;
star.gameObject.SetActive(true);
StarBlink();
spriteTrans.localEulerAngles = Vector3.zero;
Update();
}
private void StarBlink()
{
if (UnityEngine.Random.Range(1, 3) == 1) star.DoScaledAnimationAsync("Blink", 0.5f);
Invoke("StarBlink", UnityEngine.Random.Range(0.1f, 0.3f));
}
public void Jump(double beat, bool fall = false)
{
jumpingState = fall ? JumpingState.JumpingFall : JumpingState.Jumping;
jumpBeat = beat;
anim.Play("Jump", 0, 0);
spriteTrans.localEulerAngles = Vector3.zero;
jumpPath.positions[0].duration = 1 - (float)Conductor.instance.SecsToBeats(Minigame.justEarlyTime, Conductor.instance.GetBpmAtBeat(jumpBeat));
Update();
}
public void HighJump(double beat, bool fall = false, bool barely = false)
{
jumpingState = fall ? JumpingState.HighJumpingFall : JumpingState.HighJumping;
jumpBeat = beat;
anim.DoScaledAnimationAsync("HighJump", 0.5f);
spriteTrans.localEulerAngles = Vector3.zero;
highJumpPath.positions[0].duration = 1.5f - (float)Conductor.instance.SecsToBeats(Minigame.justEarlyTime, Conductor.instance.GetBpmAtBeat(jumpBeat));
highJumpPath.positions[0].height = barely ? 3.5f : 4.5f;
Update();
}
public void Roll(double beat)
{
jumpingState = JumpingState.Rolling;
jumpBeat = beat;
anim.DoScaledAnimationAsync("Roll", 0.5f);
Update();
}
public void Whiff(double beat)
{
jumpingState = JumpingState.Whiffing;
jumpBeat = beat;
anim.Play("Jump", 0, 0);
SoundByte.PlayOneShotGame("nightWalkAgb/whiff");
spriteTrans.localEulerAngles = Vector3.zero;
Update();
}
public void Walk()
{
if (jumpingState == JumpingState.Walking) return;
jumpingState = JumpingState.Walking;
walkBeat = Conductor.instance.songPositionInBeats;
spriteTrans.localEulerAngles = Vector3.zero;
}
public void PopBalloon(int index, bool instant)
{
if (instant)
{
balloons[index].DoNormalizedAnimation("Pop", 1);
return;
}
balloons[index].DoScaledAnimationAsync("Pop", 0.5f);
}
public void PopAll()
{
foreach (var balloon in balloons)
{
balloon.DoNormalizedAnimation("Pop", 1);
}
}
public void Hide()
{
anim.gameObject.SetActive(false);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cad73dbef6e1da04d8e17fbf557d5f8e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,60 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HeavenStudio.Util;
using System;
namespace HeavenStudio.Games.Scripts_AgbNightWalk
{
public class AgbStar : MonoBehaviour
{
private float originX;
private float originY;
private AgbStarHandler handler;
private Animator anim;
[NonSerialized] public int evoStage = 1;
private bool devolved = false;
private void Awake()
{
anim = GetComponent<Animator>();
}
public void Init(float x, float y, AgbStarHandler handlerToPut)
{
originX = x;
originY = y;
handler = handlerToPut;
Update();
}
private void Update()
{
transform.localPosition = handler.GetRelativePosition(ref originX, ref originY);
}
public void Blink()
{
if (devolved) return;
if (anim.IsAnimationNotPlaying())
{
anim.Play("Blink" + evoStage, 0, 0);
}
}
public void Evolve()
{
if (evoStage >= 5 || devolved) return;
anim.Play("Evolve" + evoStage, 0, 0);
evoStage++;
}
public void Devolve()
{
if (devolved) return;
anim.Play("Devolve" + evoStage, 0, 0);
devolved = true;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8b6e7ad57461ba341b895eefe9e54cf1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,146 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HeavenStudio.Util;
using System;
using System.Linq;
namespace HeavenStudio.Games.Scripts_AgbNightWalk
{
public class AgbStarHandler : MonoBehaviour
{
[SerializeField] private AgbStar starRef;
public float boundaryX = 10;
public float boundaryY = 10;
[SerializeField] private int starCount = 45;
[SerializeField] private double blinkFrequency = 0.125;
[SerializeField] private int blinkAmount = 5;
[NonSerialized] public float normalizedX;
[NonSerialized] public float normalizedY;
private AgbStar[] currentStars;
private int collectiveEvoStage = 1;
private GameEvent blinkEvent = new GameEvent();
private float halfScreenBoundaryX = 17.77695f / 2;
private void Awake()
{
currentStars = new AgbStar[starCount];
for (int i = 0; i < starCount; i++)
{
AgbStar spawnedStar = Instantiate(starRef, transform);
float xPos = UnityEngine.Random.Range(-boundaryX, boundaryX);
float yPos = UnityEngine.Random.Range(-boundaryY, boundaryY);
spawnedStar.Init(xPos, yPos, this);
currentStars[i] = spawnedStar;
}
}
private void Update()
{
var cond = Conductor.instance;
if (cond.isPlaying && !cond.isPaused)
{
if (ReportBlinkBeat(ref blinkEvent.lastReportedBeat))
{
Blink();
}
}
}
private void Blink()
{
List<AgbStar> alreadyBlinked = new List<AgbStar>();
for (int i = 0; i < blinkAmount; i++)
{
AgbStar blinkedStar = currentStars[UnityEngine.Random.Range(0, currentStars.Length)];
if (alreadyBlinked.Count > 0 && alreadyBlinked.Contains(blinkedStar)) continue;
blinkedStar.Blink();
alreadyBlinked.Add(blinkedStar);
}
}
public void Evolve(int amount)
{
for (int i = 0; i < amount; i++)
{
List<AgbStar> nonEvolvedStars = currentStars.ToList().FindAll(x => x.evoStage == collectiveEvoStage);
List<AgbStar> onScreenStars = nonEvolvedStars.FindAll(x => x.transform.localPosition.x <= halfScreenBoundaryX && x.transform.localPosition.x >= -halfScreenBoundaryX && x.transform.localPosition.y <= 5 && x.transform.localPosition.y >= -5);
//Debug.Log("OnScreen: " + onScreenStars.Count + " nonEvolved: " + nonEvolvedStars.Count);
if (onScreenStars.Count > 0)
{
AgbStar randomStar = onScreenStars[UnityEngine.Random.Range(0, onScreenStars.Count)];
randomStar.Evolve();
}
else if (nonEvolvedStars.Count > 0)
{
AgbStar randomStar = nonEvolvedStars[UnityEngine.Random.Range(0, nonEvolvedStars.Count)];
randomStar.Evolve();
}
else
{
collectiveEvoStage++;
if (collectiveEvoStage > 5) collectiveEvoStage = 5;
currentStars[UnityEngine.Random.Range(0, currentStars.Length)].Evolve();
}
}
}
public void Devolve()
{
foreach (var star in currentStars)
{
star.Devolve();
}
}
public Vector3 GetRelativePosition(ref float ogX, ref float ogY)
{
float x = Mathf.LerpUnclamped(0, boundaryX, normalizedX) + ogX;
if (x > boundaryX)
{
ogX -= boundaryX * 2;
x = Mathf.LerpUnclamped(0, boundaryX, normalizedX) + ogX;
}
else if (x < -boundaryX)
{
ogX += boundaryX * 2;
x = Mathf.LerpUnclamped(0, boundaryX, normalizedX) + ogX;
}
float y = Mathf.LerpUnclamped(0, boundaryY, normalizedY) + ogY;
if (y > boundaryY)
{
ogY -= boundaryY * 2;
y = Mathf.LerpUnclamped(0, boundaryY, normalizedY) + ogY;
}
else if (y < -boundaryY)
{
ogY += boundaryY * 2;
y = Mathf.LerpUnclamped(0, boundaryY, normalizedY) + ogY;
}
return new Vector3(x, y);
}
private void OnDrawGizmos()
{
Gizmos.color = Color.blue;
Gizmos.DrawWireCube(Vector3.zero, new Vector3(boundaryX * 2, boundaryY * 2, 0));
}
private bool ReportBlinkBeat(ref double lastReportedBeat)
{
var cond = Conductor.instance;
bool result = cond.songPositionInBeats >= (lastReportedBeat) + blinkFrequency;
if (result)
{
lastReportedBeat += blinkFrequency;
}
return result;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f8d3bb4a5dc4096438adc447790d7217
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0860b92513b386f41b294923a72dcc1b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HeavenStudio.Util;
// namespace HeavenStudio.Games.Loaders
// {
// using static Minigames;
// public static class RvlNightWalkLoader
// {
// public static Minigame AddGame(EventCaller eventCaller)
// {
// return new Minigame("nightWalkRvl", "Night Walk (Wii)", "FFFFFF", false, false, new List<GameAction>()
// {
// });
// }
// }
// }
namespace HeavenStudio.Games
{
public class RvlNightWalk : Minigame
{
public static RvlNightWalk instance;
private void Awake()
{
instance = this;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 35555d14c0564e145857c218d0fb64a4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -310,6 +310,17 @@ namespace HeavenStudio
Debug.LogWarning("Game loader ntrMunchyMonkLoader failed!");
}
Debug.Log("Running game loader AgbNightWalkLoader");
game = AgbNightWalkLoader.AddGame(eventCaller);
if (game != null)
{
eventCaller.minigames.Add(game.name, game);
}
else
{
Debug.LogWarning("Game loader AgbNightWalkLoader failed!");
}
Debug.Log("Running game loader NtrOctopusMachineLoader");
game = NtrOctopusMachineLoader.AddGame(eventCaller);
if (game != null)