HeavenStudio/Assets/Scripts/Games/DrummingPractice/DrummingPractice.cs

354 lines
14 KiB
C#
Raw Normal View History

2022-03-07 03:17:46 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
2022-03-07 03:17:46 +00:00
2022-03-14 14:21:05 +00:00
using HeavenStudio.Util;
2022-03-07 03:17:46 +00:00
namespace HeavenStudio.Games.Loaders
{
using static Minigames;
public static class CtrDrummingLoader
{
public static Minigame AddGame(EventCaller eventCaller) {
return new Minigame("drummingPractice", "Drumming Practice", "36d23e", false, false, new List<GameAction>()
{
2022-08-21 03:13:52 +00:00
new GameAction("bop", "Bop")
{
function = delegate { var e = eventCaller.currentEntity; DrummingPractice.instance.SetBop(e.beat, e.length, e["bop"], e["autoBop"]); },
resizable = true,
parameters = new List<Param>()
{
Mass Text Update (#615) * Air Rally Text Update * Blue Bear Text Update * Board Meeting Text Update * Built To Scale DS Text Update also changed Air Rally's assetbundle tag from "normal" to "keep" * Catchy Tune Text Update also changed some minor wording in Board Meeting and Built To Scale DS * Cheer Readers Text Update * The Clappy Trio Text Update * Coin Toss Text Update * Crop Stomp Text Update * DJ School Text Update * Dog Ninja Text Update * Double Date Text Update * Drumming Practice Text Update * Fan Club Text Update * Fireworks Text Update * Second Contact Text Update * Flipper-Flop Text Update also fix an error in Catchy Tune * Fork Lifter Text Update * Glee Club Text Update * Karate Man Text Update also minor updates to other games * Kitties! Text Update * Launch Party Text Update * Lockstep Text Update * Marching Orders Text Update * Meat Grinder Text Update also fixed an error in Second Contact * Mr. Upbeat Text Update * Munchy Monk Text Update * Octopus Machine Text Update * Pajama Party Text Update * Quiz Show Text Update also changed some wording in meat grinder * Rhythm Rally Text Update * Rhythm Somen Text Update that was easy * Rhythm Tweezers Text Update * Ringside Text Update * Rockers Text Update this sucked * Samurai Slice DS Text Update * See Saw Text Update * Sneaky Spirits Text Update * Spaceball Text Update * Space Dance Text Update * Space Soccer Text Update * Splashdown Text Update * Tambourine Text Update * Tap Trial Text Update * Tap Troupe Text Update * The Dazzles Text Update * Toss Boys Text Update * Tram & Pauline Text Update also added translation for Fireworks * Tunnel Text Update * Wizard's Waltz Text Update * Working Dough Text Update * fix compiler errors * fix editor offset bug(?) * fix missing param in second contact * Ball Redispense text * remove space soccer swing * Trick on the Class Text Update * Non-Game Text Update * fix pre-function sorting * camera shake ease * remove a bunch of prints * rhythm tweezers bug fix * Update Credits.txt * ssds nop samurai bop * swap order of shake properties * Update FirstContact.cs --------- Co-authored-by: minenice55 <star.elementa@gmail.com>
2024-01-15 02:04:10 +00:00
new Param("bop", true, "Bop", "Toggle if the drummers should bop for the duration of this event."),
new Param("autoBop", false, "Bop (Auto)", "Toggle if the drummers should automatically bop until another Bop event is reached.")
}
2022-08-21 03:13:52 +00:00
},
new GameAction("drum", "Hit Drum")
{
function = delegate { var e = eventCaller.currentEntity; DrummingPractice.instance.Prepare(e.beat, e["toggle"]); },
2022-08-21 03:13:52 +00:00
defaultLength = 2f,
parameters = new List<Param>()
{
Mass Text Update (#615) * Air Rally Text Update * Blue Bear Text Update * Board Meeting Text Update * Built To Scale DS Text Update also changed Air Rally's assetbundle tag from "normal" to "keep" * Catchy Tune Text Update also changed some minor wording in Board Meeting and Built To Scale DS * Cheer Readers Text Update * The Clappy Trio Text Update * Coin Toss Text Update * Crop Stomp Text Update * DJ School Text Update * Dog Ninja Text Update * Double Date Text Update * Drumming Practice Text Update * Fan Club Text Update * Fireworks Text Update * Second Contact Text Update * Flipper-Flop Text Update also fix an error in Catchy Tune * Fork Lifter Text Update * Glee Club Text Update * Karate Man Text Update also minor updates to other games * Kitties! Text Update * Launch Party Text Update * Lockstep Text Update * Marching Orders Text Update * Meat Grinder Text Update also fixed an error in Second Contact * Mr. Upbeat Text Update * Munchy Monk Text Update * Octopus Machine Text Update * Pajama Party Text Update * Quiz Show Text Update also changed some wording in meat grinder * Rhythm Rally Text Update * Rhythm Somen Text Update that was easy * Rhythm Tweezers Text Update * Ringside Text Update * Rockers Text Update this sucked * Samurai Slice DS Text Update * See Saw Text Update * Sneaky Spirits Text Update * Spaceball Text Update * Space Dance Text Update * Space Soccer Text Update * Splashdown Text Update * Tambourine Text Update * Tap Trial Text Update * Tap Troupe Text Update * The Dazzles Text Update * Toss Boys Text Update * Tram & Pauline Text Update also added translation for Fireworks * Tunnel Text Update * Wizard's Waltz Text Update * Working Dough Text Update * fix compiler errors * fix editor offset bug(?) * fix missing param in second contact * Ball Redispense text * remove space soccer swing * Trick on the Class Text Update * Non-Game Text Update * fix pre-function sorting * camera shake ease * remove a bunch of prints * rhythm tweezers bug fix * Update Credits.txt * ssds nop samurai bop * swap order of shake properties * Update FirstContact.cs --------- Co-authored-by: minenice55 <star.elementa@gmail.com>
2024-01-15 02:04:10 +00:00
new Param("toggle", true, "Applause", "Toggle if applause should be played on a successful hit.")
2022-08-21 03:13:52 +00:00
}
},
new GameAction("set mii", "Set Miis")
{
function = delegate { var e = eventCaller.currentEntity; DrummingPractice.instance.SetMiis(e["type"], e["type2"], e["type3"], e["toggle"]); },
2022-08-21 03:13:52 +00:00
defaultLength = 0.5f,
parameters = new List<Param>()
{
Mass Text Update (#615) * Air Rally Text Update * Blue Bear Text Update * Board Meeting Text Update * Built To Scale DS Text Update also changed Air Rally's assetbundle tag from "normal" to "keep" * Catchy Tune Text Update also changed some minor wording in Board Meeting and Built To Scale DS * Cheer Readers Text Update * The Clappy Trio Text Update * Coin Toss Text Update * Crop Stomp Text Update * DJ School Text Update * Dog Ninja Text Update * Double Date Text Update * Drumming Practice Text Update * Fan Club Text Update * Fireworks Text Update * Second Contact Text Update * Flipper-Flop Text Update also fix an error in Catchy Tune * Fork Lifter Text Update * Glee Club Text Update * Karate Man Text Update also minor updates to other games * Kitties! Text Update * Launch Party Text Update * Lockstep Text Update * Marching Orders Text Update * Meat Grinder Text Update also fixed an error in Second Contact * Mr. Upbeat Text Update * Munchy Monk Text Update * Octopus Machine Text Update * Pajama Party Text Update * Quiz Show Text Update also changed some wording in meat grinder * Rhythm Rally Text Update * Rhythm Somen Text Update that was easy * Rhythm Tweezers Text Update * Ringside Text Update * Rockers Text Update this sucked * Samurai Slice DS Text Update * See Saw Text Update * Sneaky Spirits Text Update * Spaceball Text Update * Space Dance Text Update * Space Soccer Text Update * Splashdown Text Update * Tambourine Text Update * Tap Trial Text Update * Tap Troupe Text Update * The Dazzles Text Update * Toss Boys Text Update * Tram & Pauline Text Update also added translation for Fireworks * Tunnel Text Update * Wizard's Waltz Text Update * Working Dough Text Update * fix compiler errors * fix editor offset bug(?) * fix missing param in second contact * Ball Redispense text * remove space soccer swing * Trick on the Class Text Update * Non-Game Text Update * fix pre-function sorting * camera shake ease * remove a bunch of prints * rhythm tweezers bug fix * Update Credits.txt * ssds nop samurai bop * swap order of shake properties * Update FirstContact.cs --------- Co-authored-by: minenice55 <star.elementa@gmail.com>
2024-01-15 02:04:10 +00:00
new Param("toggle", false, "Set All To Player", "Toggle if all Miis should be set to the player's (middle) Mii.", new List<Param.CollapseParam>()
{
new Param.CollapseParam((x, _) => !(bool)x, new string[] { "type", "type2", "type3" })
}),
Mass Text Update (#615) * Air Rally Text Update * Blue Bear Text Update * Board Meeting Text Update * Built To Scale DS Text Update also changed Air Rally's assetbundle tag from "normal" to "keep" * Catchy Tune Text Update also changed some minor wording in Board Meeting and Built To Scale DS * Cheer Readers Text Update * The Clappy Trio Text Update * Coin Toss Text Update * Crop Stomp Text Update * DJ School Text Update * Dog Ninja Text Update * Double Date Text Update * Drumming Practice Text Update * Fan Club Text Update * Fireworks Text Update * Second Contact Text Update * Flipper-Flop Text Update also fix an error in Catchy Tune * Fork Lifter Text Update * Glee Club Text Update * Karate Man Text Update also minor updates to other games * Kitties! Text Update * Launch Party Text Update * Lockstep Text Update * Marching Orders Text Update * Meat Grinder Text Update also fixed an error in Second Contact * Mr. Upbeat Text Update * Munchy Monk Text Update * Octopus Machine Text Update * Pajama Party Text Update * Quiz Show Text Update also changed some wording in meat grinder * Rhythm Rally Text Update * Rhythm Somen Text Update that was easy * Rhythm Tweezers Text Update * Ringside Text Update * Rockers Text Update this sucked * Samurai Slice DS Text Update * See Saw Text Update * Sneaky Spirits Text Update * Spaceball Text Update * Space Dance Text Update * Space Soccer Text Update * Splashdown Text Update * Tambourine Text Update * Tap Trial Text Update * Tap Troupe Text Update * The Dazzles Text Update * Toss Boys Text Update * Tram & Pauline Text Update also added translation for Fireworks * Tunnel Text Update * Wizard's Waltz Text Update * Working Dough Text Update * fix compiler errors * fix editor offset bug(?) * fix missing param in second contact * Ball Redispense text * remove space soccer swing * Trick on the Class Text Update * Non-Game Text Update * fix pre-function sorting * camera shake ease * remove a bunch of prints * rhythm tweezers bug fix * Update Credits.txt * ssds nop samurai bop * swap order of shake properties * Update FirstContact.cs --------- Co-authored-by: minenice55 <star.elementa@gmail.com>
2024-01-15 02:04:10 +00:00
new Param("type", DrummingPractice.MiiType.Random, "Player Mii", "Set the Mii that the player will control."),
new Param("type2", DrummingPractice.MiiType.Random, "Left Mii", "Set the Mii on the left."),
new Param("type3", DrummingPractice.MiiType.Random, "Right Mii", "Set the Mii on the right."),
2022-08-21 03:13:52 +00:00
}
},
Mass Text Update (#615) * Air Rally Text Update * Blue Bear Text Update * Board Meeting Text Update * Built To Scale DS Text Update also changed Air Rally's assetbundle tag from "normal" to "keep" * Catchy Tune Text Update also changed some minor wording in Board Meeting and Built To Scale DS * Cheer Readers Text Update * The Clappy Trio Text Update * Coin Toss Text Update * Crop Stomp Text Update * DJ School Text Update * Dog Ninja Text Update * Double Date Text Update * Drumming Practice Text Update * Fan Club Text Update * Fireworks Text Update * Second Contact Text Update * Flipper-Flop Text Update also fix an error in Catchy Tune * Fork Lifter Text Update * Glee Club Text Update * Karate Man Text Update also minor updates to other games * Kitties! Text Update * Launch Party Text Update * Lockstep Text Update * Marching Orders Text Update * Meat Grinder Text Update also fixed an error in Second Contact * Mr. Upbeat Text Update * Munchy Monk Text Update * Octopus Machine Text Update * Pajama Party Text Update * Quiz Show Text Update also changed some wording in meat grinder * Rhythm Rally Text Update * Rhythm Somen Text Update that was easy * Rhythm Tweezers Text Update * Ringside Text Update * Rockers Text Update this sucked * Samurai Slice DS Text Update * See Saw Text Update * Sneaky Spirits Text Update * Spaceball Text Update * Space Dance Text Update * Space Soccer Text Update * Splashdown Text Update * Tambourine Text Update * Tap Trial Text Update * Tap Troupe Text Update * The Dazzles Text Update * Toss Boys Text Update * Tram & Pauline Text Update also added translation for Fireworks * Tunnel Text Update * Wizard's Waltz Text Update * Working Dough Text Update * fix compiler errors * fix editor offset bug(?) * fix missing param in second contact * Ball Redispense text * remove space soccer swing * Trick on the Class Text Update * Non-Game Text Update * fix pre-function sorting * camera shake ease * remove a bunch of prints * rhythm tweezers bug fix * Update Credits.txt * ssds nop samurai bop * swap order of shake properties * Update FirstContact.cs --------- Co-authored-by: minenice55 <star.elementa@gmail.com>
2024-01-15 02:04:10 +00:00
new GameAction("move npc drummers", "NPC Drummers")
{
function = delegate {var e = eventCaller.currentEntity; DrummingPractice.instance.NPCDrummersEnterOrExit(e.beat, e.length, e["exit"], e["ease"]); },
defaultLength = 4f,
resizable = true,
parameters = new List<Param>()
{
Mass Text Update (#615) * Air Rally Text Update * Blue Bear Text Update * Board Meeting Text Update * Built To Scale DS Text Update also changed Air Rally's assetbundle tag from "normal" to "keep" * Catchy Tune Text Update also changed some minor wording in Board Meeting and Built To Scale DS * Cheer Readers Text Update * The Clappy Trio Text Update * Coin Toss Text Update * Crop Stomp Text Update * DJ School Text Update * Dog Ninja Text Update * Double Date Text Update * Drumming Practice Text Update * Fan Club Text Update * Fireworks Text Update * Second Contact Text Update * Flipper-Flop Text Update also fix an error in Catchy Tune * Fork Lifter Text Update * Glee Club Text Update * Karate Man Text Update also minor updates to other games * Kitties! Text Update * Launch Party Text Update * Lockstep Text Update * Marching Orders Text Update * Meat Grinder Text Update also fixed an error in Second Contact * Mr. Upbeat Text Update * Munchy Monk Text Update * Octopus Machine Text Update * Pajama Party Text Update * Quiz Show Text Update also changed some wording in meat grinder * Rhythm Rally Text Update * Rhythm Somen Text Update that was easy * Rhythm Tweezers Text Update * Ringside Text Update * Rockers Text Update this sucked * Samurai Slice DS Text Update * See Saw Text Update * Sneaky Spirits Text Update * Spaceball Text Update * Space Dance Text Update * Space Soccer Text Update * Splashdown Text Update * Tambourine Text Update * Tap Trial Text Update * Tap Troupe Text Update * The Dazzles Text Update * Toss Boys Text Update * Tram & Pauline Text Update also added translation for Fireworks * Tunnel Text Update * Wizard's Waltz Text Update * Working Dough Text Update * fix compiler errors * fix editor offset bug(?) * fix missing param in second contact * Ball Redispense text * remove space soccer swing * Trick on the Class Text Update * Non-Game Text Update * fix pre-function sorting * camera shake ease * remove a bunch of prints * rhythm tweezers bug fix * Update Credits.txt * ssds nop samurai bop * swap order of shake properties * Update FirstContact.cs --------- Co-authored-by: minenice55 <star.elementa@gmail.com>
2024-01-15 02:04:10 +00:00
new Param("exit", false, "Exit", "Toggle if the NPC drummers should enter or exit the scene."),
new Param("ease", EasingFunction.Ease.Linear, "Ease", "Set the easing of the action.")
}
},
Mass Text Update (#615) * Air Rally Text Update * Blue Bear Text Update * Board Meeting Text Update * Built To Scale DS Text Update also changed Air Rally's assetbundle tag from "normal" to "keep" * Catchy Tune Text Update also changed some minor wording in Board Meeting and Built To Scale DS * Cheer Readers Text Update * The Clappy Trio Text Update * Coin Toss Text Update * Crop Stomp Text Update * DJ School Text Update * Dog Ninja Text Update * Double Date Text Update * Drumming Practice Text Update * Fan Club Text Update * Fireworks Text Update * Second Contact Text Update * Flipper-Flop Text Update also fix an error in Catchy Tune * Fork Lifter Text Update * Glee Club Text Update * Karate Man Text Update also minor updates to other games * Kitties! Text Update * Launch Party Text Update * Lockstep Text Update * Marching Orders Text Update * Meat Grinder Text Update also fixed an error in Second Contact * Mr. Upbeat Text Update * Munchy Monk Text Update * Octopus Machine Text Update * Pajama Party Text Update * Quiz Show Text Update also changed some wording in meat grinder * Rhythm Rally Text Update * Rhythm Somen Text Update that was easy * Rhythm Tweezers Text Update * Ringside Text Update * Rockers Text Update this sucked * Samurai Slice DS Text Update * See Saw Text Update * Sneaky Spirits Text Update * Spaceball Text Update * Space Dance Text Update * Space Soccer Text Update * Splashdown Text Update * Tambourine Text Update * Tap Trial Text Update * Tap Troupe Text Update * The Dazzles Text Update * Toss Boys Text Update * Tram & Pauline Text Update also added translation for Fireworks * Tunnel Text Update * Wizard's Waltz Text Update * Working Dough Text Update * fix compiler errors * fix editor offset bug(?) * fix missing param in second contact * Ball Redispense text * remove space soccer swing * Trick on the Class Text Update * Non-Game Text Update * fix pre-function sorting * camera shake ease * remove a bunch of prints * rhythm tweezers bug fix * Update Credits.txt * ssds nop samurai bop * swap order of shake properties * Update FirstContact.cs --------- Co-authored-by: minenice55 <star.elementa@gmail.com>
2024-01-15 02:04:10 +00:00
new GameAction("set background color", "Background Appearance")
2022-08-21 03:13:52 +00:00
{
function = delegate {var e = eventCaller.currentEntity;
DrummingPractice.instance.BackgroundColor(e.beat, e.length, e["colorAStart"], e["colorA"], e["colorBStart"], e["colorB"], e["colorC"], e["ease"]); },
defaultLength = 4f,
resizable = true,
2022-08-21 03:13:52 +00:00
parameters = new List<Param>()
{
Mass Text Update (#615) * Air Rally Text Update * Blue Bear Text Update * Board Meeting Text Update * Built To Scale DS Text Update also changed Air Rally's assetbundle tag from "normal" to "keep" * Catchy Tune Text Update also changed some minor wording in Board Meeting and Built To Scale DS * Cheer Readers Text Update * The Clappy Trio Text Update * Coin Toss Text Update * Crop Stomp Text Update * DJ School Text Update * Dog Ninja Text Update * Double Date Text Update * Drumming Practice Text Update * Fan Club Text Update * Fireworks Text Update * Second Contact Text Update * Flipper-Flop Text Update also fix an error in Catchy Tune * Fork Lifter Text Update * Glee Club Text Update * Karate Man Text Update also minor updates to other games * Kitties! Text Update * Launch Party Text Update * Lockstep Text Update * Marching Orders Text Update * Meat Grinder Text Update also fixed an error in Second Contact * Mr. Upbeat Text Update * Munchy Monk Text Update * Octopus Machine Text Update * Pajama Party Text Update * Quiz Show Text Update also changed some wording in meat grinder * Rhythm Rally Text Update * Rhythm Somen Text Update that was easy * Rhythm Tweezers Text Update * Ringside Text Update * Rockers Text Update this sucked * Samurai Slice DS Text Update * See Saw Text Update * Sneaky Spirits Text Update * Spaceball Text Update * Space Dance Text Update * Space Soccer Text Update * Splashdown Text Update * Tambourine Text Update * Tap Trial Text Update * Tap Troupe Text Update * The Dazzles Text Update * Toss Boys Text Update * Tram & Pauline Text Update also added translation for Fireworks * Tunnel Text Update * Wizard's Waltz Text Update * Working Dough Text Update * fix compiler errors * fix editor offset bug(?) * fix missing param in second contact * Ball Redispense text * remove space soccer swing * Trick on the Class Text Update * Non-Game Text Update * fix pre-function sorting * camera shake ease * remove a bunch of prints * rhythm tweezers bug fix * Update Credits.txt * ssds nop samurai bop * swap order of shake properties * Update FirstContact.cs --------- Co-authored-by: minenice55 <star.elementa@gmail.com>
2024-01-15 02:04:10 +00:00
new Param("colorAStart", new Color(43/255f, 207/255f, 51/255f), "Color A Start", "Set the top-most color of the background gradient at the start of the event."),
new Param("colorA", new Color(43/255f, 207/255f, 51/255f), "Color A End", "Set the top-most color of the background gradient at the end of the event."),
new Param("colorBStart", new Color(1, 1, 1), "Color B Start", "Set the bottom-most color of the background gradient at the start of the event."),
new Param("colorB", new Color(1, 1, 1), "Color B End", "Set the bottom-most color of the background gradient at the end of the event."),
new Param("colorC", new Color(1, 247/255f, 0), "Streak Color", "Set the color of the streaks that appear upon a successful hit."),
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease", "Set the easing of the action.")
2022-08-21 03:13:52 +00:00
}
}
},
new List<string>() {"ctr", "normal"},
"ctrintro", "en",
new List<string>() {}
);
}
}
}
2022-03-14 14:21:05 +00:00
namespace HeavenStudio.Games
2022-03-07 03:17:46 +00:00
{
2022-03-12 04:10:13 +00:00
using Scripts_DrummingPractice;
2022-03-07 03:17:46 +00:00
public class DrummingPractice : Minigame
{
2022-03-07 05:26:59 +00:00
public enum MiiType
{
Random = -1,
2022-03-07 05:26:59 +00:00
GuestA,
GuestB,
GuestC,
GuestD,
GuestE,
GuestF,
Matt,
Tsunku,
Marshal
}
2022-03-07 03:17:46 +00:00
[Header("References")]
public SpriteRenderer background;
2022-03-07 03:17:46 +00:00
public SpriteRenderer backgroundGradient;
public SpriteRenderer[] streaks;
2022-03-07 03:17:46 +00:00
public Drummer player;
public Drummer leftDrummer;
public Drummer rightDrummer;
2022-03-07 05:00:54 +00:00
public GameObject hitPrefab;
[SerializeField] Animator NPCDrummers;
[Header("Variables")]
float movingLength;
double movingStartBeat;
bool isMoving;
string moveAnim;
EasingFunction.Ease lastEase;
2022-03-07 05:00:54 +00:00
public int count = 0;
2022-03-07 03:17:46 +00:00
public static DrummingPractice instance;
private void Awake()
{
instance = this;
SetMiis();
SetupBopRegion("drummingPractice", "bop", "autoBop");
2022-03-07 03:17:46 +00:00
}
public override void OnGameSwitch(double beat)
2022-03-07 05:00:54 +00:00
{
var changeMii = GameManager.instance.Beatmap.Entities.FindLast(c => c.datamodel == "drummingPractice/set mii" && c.beat <= beat);
if(changeMii != null)
{
EventCaller.instance.CallEvent(changeMii, true);
}
PersistColor(beat);
2022-03-07 05:00:54 +00:00
}
public override void OnBeatPulse(double beat)
2022-03-07 03:17:46 +00:00
{
if (BeatIsInBopRegion(beat))
2022-03-07 05:00:54 +00:00
{
Bop();
2022-03-07 05:00:54 +00:00
}
}
private void Update()
{
var cond = Conductor.instance;
if (isMoving && cond.isPlaying && !cond.isPaused)
{
float normalizedBeat = cond.GetPositionFromBeat(movingStartBeat, movingLength);
if (normalizedBeat >= 0 && normalizedBeat <= 1f)
{
EasingFunction.Function func = EasingFunction.GetEasingFunction(lastEase);
float newPos = func(0f, 1f, normalizedBeat);
NPCDrummers.DoNormalizedAnimation(moveAnim, newPos);
}
}
foreach (SpriteRenderer streak in streaks)
{
Color col = streak.color;
streak.color = new Color(col.r, col.g, col.b, Mathf.Lerp(col.a, 0, 3.5f * Time.deltaTime));
}
BackgroundColorUpdate();
2022-03-07 05:00:54 +00:00
}
public void NPCDrummersEnterOrExit(double beat, float length, bool exit, int ease)
{
movingStartBeat = beat;
movingLength = length;
moveAnim = exit ? "NPCDrummersExit" : "NPCDrummersEnter";
isMoving = true;
lastEase = (EasingFunction.Ease)ease;
BeatAction.New(instance, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + length - 0.01f, delegate { isMoving = false; })
});
}
public void SetBop(double beat, float length, bool shouldBop, bool autoBop)
2022-03-07 05:00:54 +00:00
{
if (shouldBop)
{
for (int i = 0; i < length; i++)
{
BeatAction.New(instance, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + i, delegate { Bop(); })
});
}
}
2022-03-07 05:00:54 +00:00
}
public void Bop()
{
player.Bop();
leftDrummer.Bop();
rightDrummer.Bop();
}
public void Prepare(double beat, bool applause)
2022-03-07 05:00:54 +00:00
{
int type = count % 2;
player.Prepare(beat, type);
leftDrummer.Prepare(beat, type);
rightDrummer.Prepare(beat, type);
2022-03-07 05:00:54 +00:00
count++;
SetFaces(0);
SoundByte.PlayOneShotGame("drummingPractice/prepare");
2022-03-07 05:00:54 +00:00
GameObject hit = Instantiate(hitPrefab);
hit.transform.parent = hitPrefab.transform.parent;
hit.SetActive(true);
DrummerHit h = hit.GetComponent<DrummerHit>();
h.startBeat = beat;
h.applause = applause;
2022-03-07 05:00:54 +00:00
}
public void SetFaces(int type)
{
player.SetFace(type);
leftDrummer.SetFace(type);
rightDrummer.SetFace(type);
2022-03-07 03:17:46 +00:00
}
2022-03-11 18:24:24 +00:00
public void SetMiis(int playerFace = (int) MiiType.Random, int leftFace = (int) MiiType.Random, int rightFace = (int) MiiType.Random, bool all = false)
2022-03-07 05:26:59 +00:00
{
2022-03-11 18:24:24 +00:00
if (playerFace == (int) MiiType.Random)
{
do
{
player.mii = UnityEngine.Random.Range(0, player.miiFaces.Count);
}
while (player.mii == leftFace || player.mii == rightFace);
}
else
player.mii = playerFace;
2022-03-07 05:26:59 +00:00
if (all && playerFace != -1)
2022-03-07 05:26:59 +00:00
{
leftDrummer.mii = playerFace;
rightDrummer.mii = playerFace;
}
else
{
2022-03-11 18:24:24 +00:00
if (leftFace == (int) MiiType.Random)
2022-03-07 05:26:59 +00:00
{
do
{
leftDrummer.mii = UnityEngine.Random.Range(0, player.miiFaces.Count);
}
while (leftDrummer.mii == player.mii);
2022-03-07 05:26:59 +00:00
}
else
leftDrummer.mii = leftFace;
2022-03-11 18:24:24 +00:00
if (rightFace == (int) MiiType.Random)
2022-03-07 05:26:59 +00:00
{
do
{
rightDrummer.mii = UnityEngine.Random.Range(0, player.miiFaces.Count);
}
while (rightDrummer.mii == leftDrummer.mii || rightDrummer.mii == player.mii);
2022-03-07 05:26:59 +00:00
}
else
rightDrummer.mii = rightFace;
2022-03-07 05:26:59 +00:00
}
SetFaces(0);
}
private double colorStartBeat = -1;
private float colorLength = 0f;
private Color colorStart = new Color(43 / 255f, 207 / 255f, 51 / 255f); //obviously put to the default color of the game
private Color colorEnd = new Color(43 / 255f, 207 / 255f, 51 / 255f);
private Color colorStartB = Color.white; //obviously put to the default color of the game
private Color colorEndB = Color.white;
private Util.EasingFunction.Ease colorEase; //putting Util in case this game is using jukebox
//call this in update
private void BackgroundColorUpdate()
{
float normalizedBeat = Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(colorStartBeat, colorLength));
var func = Util.EasingFunction.GetEasingFunction(colorEase);
float newR = func(colorStart.r, colorEnd.r, normalizedBeat);
float newG = func(colorStart.g, colorEnd.g, normalizedBeat);
float newB = func(colorStart.b, colorEnd.b, normalizedBeat);
backgroundGradient.color = new Color(newR, newG, newB);
float newRB = func(colorStartB.r, colorEndB.r, normalizedBeat);
float newGB = func(colorStartB.g, colorEndB.g, normalizedBeat);
float newBB = func(colorStartB.b, colorEndB.b, normalizedBeat);
background.color = new Color(newRB, newGB, newBB);
}
public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, Color colorStartSetB, Color colorEndSetB, Color setStreak, int ease)
{
colorStartBeat = beat;
colorLength = length;
colorStart = colorStartSet;
colorEnd = colorEndSet;
colorStartB = colorStartSetB;
colorEndB = colorEndSetB;
colorEase = (Util.EasingFunction.Ease)ease;
foreach (SpriteRenderer streak in streaks)
{
streak.color = new Color(setStreak.r, setStreak.g, setStreak.b, streak.color.a);
}
}
//call this in OnPlay(double beat) and OnGameSwitch(double beat)
private void PersistColor(double beat)
{
var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("drummingPractice", new string[] { "set background color" }).FindAll(x => x.beat < beat);
if (allEventsBeforeBeat.Count > 0)
{
allEventsBeforeBeat.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case
var lastEvent = allEventsBeforeBeat[^1];
BackgroundColor(lastEvent.beat, lastEvent.length, lastEvent["colorAStart"], lastEvent["colorA"], lastEvent["colorBStart"], lastEvent["colorB"], lastEvent["colorC"], lastEvent["ease"]);
}
}
public override void OnPlay(double beat)
{
PersistColor(beat);
}
public void Streak()
{
foreach (SpriteRenderer streak in streaks)
{
Color col = streak.color;
streak.color = new Color(col.r, col.g, col.b, 0.7f);
}
}
2022-03-07 03:17:46 +00:00
}
}