mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 12:57:39 +02:00
Octopus Machine Finalized (#437)
* copied some code broken rn but i'll fix it on my pc (commiting to work not on my laptop) * general work idk basically got all the blocks/parameters in that i want for now mostly need to fix the copied glee club at this point * blehh it's almost done but no animators means no real progress. * squeeze anim done * pop anim has popped up * inputs are inputting and animations are animating TODO: * fix bopping/preparing so it's not janky and weird * bubble entrance * color tweening (about halfway done) * more stuff yippee * so much stuff * bubbles block (still kinda wip?) * squeeze color works * preparing so much better * added the thing where the release sfx doesn't play sometimes * finalizing the game! hopefully no bugs :3 * i'm pretty sure it's done! yippee * final --------- Co-authored-by: wookywok <wookywok11@gmail.com>
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
using HeavenStudio.Util;
|
||||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@ -7,12 +7,20 @@ namespace HeavenStudio.Games.Scripts_OctopusMachine
|
||||
{
|
||||
public class Octopus : MonoBehaviour
|
||||
{
|
||||
[SerializeField] Animator anim;
|
||||
[SerializeField] SpriteRenderer sr;
|
||||
[SerializeField] SpriteRenderer[] sr;
|
||||
[SerializeField] SpriteRenderer[] srAll;
|
||||
[SerializeField] bool player;
|
||||
public Animator anim;
|
||||
|
||||
public bool cantBop;
|
||||
public bool isSqueezed;
|
||||
public bool isPreparing;
|
||||
public bool queuePrepare;
|
||||
public float lastReportedBeat = 0f;
|
||||
float lastSqueezeBeat;
|
||||
bool isActive = true;
|
||||
|
||||
private OctopusMachine game;
|
||||
public static Octopus instance;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
@ -21,138 +29,82 @@ namespace HeavenStudio.Games.Scripts_OctopusMachine
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (queuePrepare && Conductor.instance.NotStopped()) {
|
||||
if (!(isPreparing || isSqueezed || anim.IsPlayingAnimationName("Release") || anim.IsPlayingAnimationName("Pop")))
|
||||
{
|
||||
anim.DoScaledAnimationAsync("Prepare", 0.5f);
|
||||
isPreparing = true;
|
||||
queuePrepare = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isActive && player)
|
||||
{
|
||||
if (PlayerInput.Pressed() && !game.IsExpectingInputNow(InputType.STANDARD_DOWN))
|
||||
OctoAction("Squeeze");
|
||||
|
||||
if (PlayerInput.PressedUp() && !game.IsExpectingInputNow(InputType.STANDARD_UP)) {
|
||||
OctoAction(PlayerInput.Pressing(true) ? "Pop" : "Release");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
if (Conductor.instance.ReportBeat(ref game.lastReportedBeat)/* && !game.isPreparing && game.bopOn*/)
|
||||
if (Conductor.instance.ReportBeat(ref lastReportedBeat)
|
||||
&& !anim.IsPlayingAnimationName("Bop")
|
||||
&& !anim.IsPlayingAnimationName("Happy")
|
||||
&& !anim.IsPlayingAnimationName("Angry")
|
||||
&& !anim.IsPlayingAnimationName("Oops")
|
||||
&& !anim.IsPlayingAnimationName("Release")
|
||||
&& !anim.IsPlayingAnimationName("Pop")
|
||||
&& !isPreparing
|
||||
&& !isSqueezed
|
||||
&& !cantBop )
|
||||
{
|
||||
//if (anim.IsAnimationNotPlaying() || anim.IsPlayingAnimationName("Idle"))
|
||||
if (game.isHappy) {
|
||||
anim.DoScaledAnimation("Happy", 0.5f);
|
||||
} else if (game.isAngry) {
|
||||
anim.DoScaledAnimation("Angry", 0.5f);
|
||||
} else if (game.isShocked) {
|
||||
anim.DoScaledAnimation("Oops", 0.5f);
|
||||
} else {
|
||||
anim.DoScaledAnimation("Bop", 0.5f);
|
||||
}
|
||||
PlayAnimation(game.bopStatus);
|
||||
}
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
public void PlayAnimation(int whichBop)
|
||||
{
|
||||
|
||||
if (whichBop == 2 && player) whichBop = 3;
|
||||
anim.DoScaledAnimationAsync(whichBop switch {
|
||||
0 => "Bop",
|
||||
1 => "Happy",
|
||||
2 => "Angry",
|
||||
3 => "Oops",
|
||||
}, 0.5f);
|
||||
}
|
||||
|
||||
public void TogglePresence(bool disappear)
|
||||
public void ForceSqueeze()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
anim.DoScaledAnimationAsync("ForceSqueeze", 0.5f);
|
||||
isSqueezed = true;
|
||||
}
|
||||
|
||||
public void MissPose()
|
||||
public void OctopusModifiers(float x, float y, bool enable)
|
||||
{
|
||||
|
||||
gameObject.transform.position = new Vector3(x, y, 0);
|
||||
foreach (var sprite in srAll) sprite.color = new Color(sprite.color.r, sprite.color.g, sprite.color.b, enable ? 1 : 0);
|
||||
isActive = enable;
|
||||
}
|
||||
|
||||
public void StartCrouch()
|
||||
public void OctoAction(string action)
|
||||
{
|
||||
|
||||
if (action != "Release" || (Conductor.instance.songPositionInBeats - lastSqueezeBeat) > 0.15f) Jukebox.PlayOneShotGame($"octopusMachine/{action.ToLower()}");
|
||||
if (action == "Squeeze") lastSqueezeBeat = Conductor.instance.songPositionInBeats;
|
||||
|
||||
anim.DoScaledAnimationAsync(action, 0.5f);
|
||||
isSqueezed = (action == "Squeeze");
|
||||
isPreparing =
|
||||
queuePrepare = false;
|
||||
}
|
||||
|
||||
public void StartYell()
|
||||
public void AnimationColor(int poppingColor)
|
||||
{
|
||||
/*
|
||||
if (singing || disappeared) return;
|
||||
singing = true;
|
||||
anim.SetBool("Mega", true);
|
||||
anim.Play("OpenMouth", 0, 0);
|
||||
shouldMegaClose = true;
|
||||
if (currentSound != null) Jukebox.KillLoop(currentSound, 0f);
|
||||
Jukebox.PlayOneShotGame("gleeClub/LoudWailStart");
|
||||
currentSound = Jukebox.PlayOneShotGame("gleeClub/LoudWailLoop", -1, currentPitch, 1f, true);
|
||||
BeatAction.New(game.gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(Conductor.instance.songPositionInBeats + 1f, delegate { UnYell(); })
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
void UnYell()
|
||||
{
|
||||
//if (singing && !anim.GetCurrentAnimatorStateInfo(0).IsName("YellIdle")) anim.Play("YellIdle", 0, 0);
|
||||
}
|
||||
|
||||
public void StartSinging(bool forced = false)
|
||||
{
|
||||
/*
|
||||
if ((singing && !forced) || disappeared) return;
|
||||
singing = true;
|
||||
anim.SetBool("Mega", false);
|
||||
shouldMegaClose = false;
|
||||
anim.Play("OpenMouth", 0, 0);
|
||||
if (currentSound != null) Jukebox.KillLoop(currentSound, 0f);
|
||||
currentSound = Jukebox.PlayOneShotGame("gleeClub/WailLoop", -1, currentPitch, 1f, true);
|
||||
*/
|
||||
}
|
||||
|
||||
public void StopSinging(bool mega = false, bool playSound = true)
|
||||
{
|
||||
/*
|
||||
if (!singing || disappeared) return;
|
||||
singing = false;
|
||||
anim.Play(mega ? "MegaCloseMouth" : "CloseMouth", 0, 0);
|
||||
if (currentSound != null) Jukebox.KillLoop(currentSound, 0f);
|
||||
if (playSound) Jukebox.PlayOneShotGame("gleeClub/StopWail");
|
||||
*/
|
||||
}
|
||||
|
||||
public void Bop(float beat)
|
||||
{
|
||||
if (!game.isPreparing && game.bopOn)
|
||||
{
|
||||
if (anim.IsAnimationNotPlaying() || anim.IsPlayingAnimationName("Idle"))
|
||||
if (game.isHappy) {
|
||||
anim.DoScaledAnimation("Happy", 0.5f);
|
||||
} else if (game.isAngry) {
|
||||
anim.DoScaledAnimation("Angry", 0.5f);
|
||||
} else if (game.isShocked) {
|
||||
anim.DoScaledAnimation("Oops", 0.5f);
|
||||
} else {
|
||||
anim.DoScaledAnimation("Bop", 0.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayAnimation(float beat, bool keepBopping, int whichBop)
|
||||
{
|
||||
switch (whichBop)
|
||||
{
|
||||
case 0:
|
||||
anim.DoScaledAnimation("Bop", 0.5f);
|
||||
break;
|
||||
case 1:
|
||||
anim.DoScaledAnimation("Happy", 0.5f);
|
||||
break;
|
||||
case 2:
|
||||
anim.DoScaledAnimation("Angry", 0.5f);
|
||||
break;
|
||||
case 3:
|
||||
anim.DoScaledAnimation("Oops", 0.5f);
|
||||
break;
|
||||
}
|
||||
if (keepBopping) {
|
||||
game.isHappy = whichBop == 1 ? keepBopping : !keepBopping;
|
||||
game.isAngry = whichBop == 2 ? keepBopping : !keepBopping;
|
||||
game.isShocked = whichBop == 3 ? keepBopping : !keepBopping;
|
||||
}
|
||||
}
|
||||
|
||||
public void GameplayModifiers(bool isActive, Color octoColor)
|
||||
{
|
||||
gameObject.SetActive(isActive);
|
||||
sr.color = octoColor;
|
||||
foreach (var sprite in sr) sprite.material.SetColor("_ColorAlpha", (poppingColor == 0 ? OctopusMachine.octopodesColor : OctopusMachine.octopodesSqueezedColor));
|
||||
if (poppingColor == 1) isSqueezed = true;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
using HeavenStudio.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
// using GhostlyGuy's Balls;
|
||||
|
||||
namespace HeavenStudio.Games.Loaders
|
||||
@ -10,67 +12,142 @@ namespace HeavenStudio.Games.Loaders
|
||||
public static class NtrOctopusMachineLoader
|
||||
{
|
||||
public static Minigame AddGame(EventCaller eventCaller) {
|
||||
return new Minigame("OctopusMachine", "Octopus Machine \n<color=#eb5454>[INITIALIZATION ONLY]</color>", "FFf362B", false, false, new List<GameAction>()
|
||||
return new Minigame("octopusMachine", "Octopus Machine", "FFf362B", false, false, new List<GameAction>()
|
||||
{
|
||||
new GameAction("Bop", "Bop")
|
||||
new GameAction("bop", "Bop")
|
||||
{
|
||||
function = delegate {
|
||||
var e = eventCaller.currentEntity;
|
||||
OctopusMachine.instance.Bop(e.beat, e["disableBop"], e[""], e["whichBop"]);
|
||||
function = delegate {
|
||||
var e = eventCaller.currentEntity;
|
||||
OctopusMachine.instance.Bop(e.length, e["whichBop"], e["singleBop"], e["keepBop"]);
|
||||
},
|
||||
parameters = new List<Param>()
|
||||
{
|
||||
new Param("bop", false, "Which Bop?", "Plays a sepcific bop type"),
|
||||
new Param("whichBop", OctopusMachine.Bops.Bop, "Which Bop?", "Plays a sepcific bop type"),
|
||||
parameters = new List<Param>() {
|
||||
new Param("whichBop", OctopusMachine.Bops.Bop, "Which Bop", "Plays a specific bop type"),
|
||||
new Param("singleBop", true, "Single Bop", "Plays one bop"),
|
||||
new Param("keepBop", false, "Keep Bopping", "Keeps playing the specified bop type"),
|
||||
},
|
||||
defaultLength = 0.5f,
|
||||
},
|
||||
new GameAction("Expand", "Expand")
|
||||
new GameAction("startInterval", "Start Interval")
|
||||
{
|
||||
function = delegate {
|
||||
var e = eventCaller.currentEntity;
|
||||
OctopusMachine.instance.Expand(e.beat);
|
||||
function = delegate {
|
||||
var e = eventCaller.currentEntity;
|
||||
OctopusMachine.instance.StartInterval(e.beat, e.length);
|
||||
},
|
||||
defaultLength = 1f,
|
||||
resizable = true,
|
||||
priority = 5,
|
||||
},
|
||||
new GameAction("squeeze", "Squeeze")
|
||||
{
|
||||
function = delegate {
|
||||
var e = eventCaller.currentEntity;
|
||||
OctopusMachine.instance.OctoAction(e.beat, e.length, "Squeeze");
|
||||
},
|
||||
resizable = true,
|
||||
parameters = new List<Param>() {
|
||||
new Param("shouldPrep", true, "Prepare?", "Plays a prepare animation before the cue."),
|
||||
new Param("prepBeats", new EntityTypes.Float(0, 4, 1), "Prepare Beats", "How many beats before the cue does the octopus prepare?"),
|
||||
},
|
||||
preFunctionLength = 4f,
|
||||
preFunction = delegate {
|
||||
var e = eventCaller.currentEntity;
|
||||
OctopusMachine.instance.Prepare(e.beat);
|
||||
if (e["shouldPrep"]) OctopusMachine.Prepare(e.beat, e["prepBeats"]);
|
||||
},
|
||||
priority = 1,
|
||||
},
|
||||
new GameAction("Prepare", "Prepare")
|
||||
new GameAction("release", "Release")
|
||||
{
|
||||
function = delegate {
|
||||
var e = eventCaller.currentEntity;
|
||||
OctopusMachine.instance.OctoAction(e.beat, e.length, "Release");
|
||||
},
|
||||
resizable = true,
|
||||
priority = 1,
|
||||
},
|
||||
new GameAction("pop", "Pop")
|
||||
{
|
||||
function = delegate {
|
||||
var e = eventCaller.currentEntity;
|
||||
OctopusMachine.instance.OctoAction(e.beat, e.length, "Pop");
|
||||
},
|
||||
resizable = true,
|
||||
priority = 1,
|
||||
},
|
||||
new GameAction("automaticActions", "Automatic Actions")
|
||||
{
|
||||
function = delegate {
|
||||
var e = eventCaller.currentEntity;
|
||||
OctopusMachine.instance.Prepare(e.beat);
|
||||
OctopusMachine.instance.AutoAction(e["autoBop"], e["autoText"], e["hitText"], e["missText"]);
|
||||
},
|
||||
parameters = new List<Param>() {
|
||||
new Param("autoBop", true, "Hit/Miss Bop", "Plays a bop depending on if you hit or missed the cues."),
|
||||
new Param("autoText", true, "Display Text", "Displays text depending on if you hit or missed the cues."),
|
||||
new Param("hitText", "Good!", "Hit Text", "The text to display if you hit the cues."),
|
||||
new Param("missText", "Wrong! n/ Try again!", "Miss Text", "The text to display if you missed the cues."),
|
||||
},
|
||||
},
|
||||
new GameAction("forceSqueeze", "Force Squeeze")
|
||||
{
|
||||
function = delegate { OctopusMachine.instance.ForceSqueeze(); }
|
||||
},
|
||||
new GameAction("prepare", "Prepare")
|
||||
{
|
||||
function = delegate { OctopusMachine.queuePrepare = true; },
|
||||
defaultLength = 0.5f,
|
||||
},
|
||||
new GameAction("OctopusAnimation", "Octopus Animation")
|
||||
new GameAction("bubbles", "Bubbles")
|
||||
{
|
||||
function = delegate {
|
||||
var e = eventCaller.currentEntity;
|
||||
OctopusMachine.instance.PlayAnimation(e.beat, e["keepWhich"], e["whichBop"]);
|
||||
function = delegate {
|
||||
var e = eventCaller.currentEntity;
|
||||
OctopusMachine.instance.BubbleToggle(e["isInstant"], e["setActive"], e["particleStrength"], e["particleSpeed"]);
|
||||
},
|
||||
parameters = new List<Param>()
|
||||
{
|
||||
new Param("keepWhich", true, "Bop Like This?", "Keep bopping using the selected bop"),
|
||||
new Param("whichBop", OctopusMachine.Bops.Bop, "Which Bop?", "Plays a sepcific bop type"),
|
||||
parameters = new List<Param>() {
|
||||
new Param("isInstant", true, "Instant", "Will the bubbles disappear appear?"),
|
||||
new Param("setActive", OctopusMachine.Actives.Activate, "Activate or Deactivate", "Will the bubbles disappear or appear?"),
|
||||
new Param("particleStrength", new EntityTypes.Float(0, 25, 3), "Bubble Intensity", "The amount of bubbles"),
|
||||
new Param("particleSpeed", new EntityTypes.Float(0, 25, 5), "Bubble Speed", "The speed of the bubbles"),
|
||||
},
|
||||
defaultLength = 0.5f,
|
||||
},
|
||||
new GameAction("GameplayModifiers", "Gameplay Modifiers")
|
||||
new GameAction("changeText", "Change Text")
|
||||
{
|
||||
function = delegate {
|
||||
var e = eventCaller.currentEntity;
|
||||
OctopusMachine.instance.GameplayModifiers(e.beat, e["color"], e["octoColor"], e["oct1"], e["oct2"], e["oct3"]);
|
||||
function = delegate {
|
||||
var e = eventCaller.currentEntity;
|
||||
OctopusMachine.instance.ChangeText(e["text"], e["youText"]);
|
||||
},
|
||||
parameters = new List<Param>()
|
||||
{
|
||||
new Param("color", new Color(1f, 0.84f, 0), "Background Color", "Set the background color"),
|
||||
new Param("octoColor", new Color(1f, 0.145f, 0.5f), "Octopodes Color", "Set the octopode's color"),
|
||||
new Param("oct1", true, "Show Octopus 1?", "Keep bopping using the selected bop"),
|
||||
new Param("oct2", true, "Show Octopus 2?", "Keep bopping using the selected bop"),
|
||||
new Param("oct3", true, "Show Octopus 3?", "Keep bopping using the selected bop"),
|
||||
parameters = new List<Param>() {
|
||||
new Param("text", "Do what the others do.", "Text", "Set the text on the screen"),
|
||||
new Param("youText", "You", "You Text", "Set the text that orginally says \"You\""),
|
||||
},
|
||||
},
|
||||
new GameAction("changeColor", "Change Color")
|
||||
{
|
||||
function = delegate {
|
||||
var e = eventCaller.currentEntity;
|
||||
OctopusMachine.instance.ChangeColor(e["color1"], e["color2"], e["octoColor"], e["squeezedColor"], e.length, e["bgInstant"]);
|
||||
},
|
||||
parameters = new List<Param>() {
|
||||
new Param("color1", new Color(1f, 0.87f, 0.24f), "Background Start Color", "Set the beginning background color"),
|
||||
new Param("color2", new Color(1f, 0.87f, 0.24f), "Background End Color", "Set the end background color"),
|
||||
new Param("bgInstant", false, "Instant Background?", "Set the end background color instantly"),
|
||||
new Param("octoColor", new Color(0.97f, 0.235f, 0.54f), "Octopodes Color", "Set the octopodes' colors"),
|
||||
new Param("squeezedColor", new Color(1f, 0f, 0f), "Squeezed Color", "Set the octopodes' colors when they're squeezed"),
|
||||
},
|
||||
resizable = true,
|
||||
},
|
||||
new GameAction("octopusModifiers", "Octopus Positions")
|
||||
{
|
||||
function = delegate {
|
||||
var e = eventCaller.currentEntity;
|
||||
OctopusMachine.instance.OctopusModifiers(e.beat, e["oct1x"], e["oct2x"], e["oct3x"], e["oct1y"], e["oct2y"], e["oct3y"], e["oct1"], e["oct2"], e["oct3"]);
|
||||
},
|
||||
parameters = new List<Param>() {
|
||||
new Param("oct1", true, "Show Octopus 1", "Should the first octopus be enabled?"),
|
||||
new Param("oct1x", new EntityTypes.Float(-10, 10, -4.64f), "X Octopus 1", "Change Octopus 1's X"),
|
||||
new Param("oct1y", new EntityTypes.Float(-10, 10, 2.5f), "Y Octopus 1", "Change Octopus 1's Y"),
|
||||
new Param("oct2", true, "Show Octopus 2", "Should the second octopus be enabled?"),
|
||||
new Param("oct2x", new EntityTypes.Float(-10, 10, -0.637f), "X Octopus 2", "Change Octopus 2's X"),
|
||||
new Param("oct2y", new EntityTypes.Float(-10, 10, 0f), "Y Octopus 2", "Change Octopus 2's Y"),
|
||||
new Param("oct3", true, "Show Octopus 3", "Should the third octopus be enabled?"),
|
||||
new Param("oct3x", new EntityTypes.Float(-10, 10, 3.363f), "X Octopus 3", "Change Octopus 3's X"),
|
||||
new Param("oct3y", new EntityTypes.Float(-10, 10, -2.5f), "Y Octopus 3", "Change Octopus 3's Y"),
|
||||
},
|
||||
defaultLength = 0.5f,
|
||||
},
|
||||
@ -84,29 +161,49 @@ namespace HeavenStudio.Games
|
||||
using Scripts_OctopusMachine;
|
||||
public partial class OctopusMachine : Minigame
|
||||
{
|
||||
[Header("Sprite Renderers")]
|
||||
[SerializeField] SpriteRenderer Background;
|
||||
|
||||
[Header("Octopodes")]
|
||||
public Octopus Octopus1;
|
||||
public Octopus Octopus2;
|
||||
public Octopus Octopus3;
|
||||
[Header("Objects")]
|
||||
[SerializeField] SpriteRenderer bg;
|
||||
[SerializeField] Material mat;
|
||||
[SerializeField] ParticleSystem[] Bubbles;
|
||||
[SerializeField] GameObject YouArrow;
|
||||
[SerializeField] TMP_Text YouText;
|
||||
[SerializeField] TMP_Text Text;
|
||||
[SerializeField] Octopus[] octopodes;
|
||||
|
||||
public bool isHappy;
|
||||
public bool isAngry;
|
||||
public bool isShocked;
|
||||
public bool isPreparing;
|
||||
public bool bopOn = true;
|
||||
public float lastReportedBeat = 0f;
|
||||
[Header("Static Variables")]
|
||||
static Color backgroundColor = new Color(1, 0.87f, 0.24f);
|
||||
public static Color octopodesColor = new Color(0.97f, 0.235f, 0.54f);
|
||||
public static Color octopodesSqueezedColor = new Color(1f, 0f, 0f);
|
||||
public static bool queuePrepare;
|
||||
|
||||
[Header("Variables")]
|
||||
public bool hasMissed;
|
||||
public int bopStatus = 0;
|
||||
Tween bgColorTween;
|
||||
int bopIterate = 0;
|
||||
bool intervalStarted;
|
||||
bool autoAction;
|
||||
float intervalStartBeat;
|
||||
float beatInterval = 1f;
|
||||
float lastReportedBeat;
|
||||
|
||||
static List<float> queuedSqueezes = new List<float>();
|
||||
static List<float> queuedReleases = new List<float>();
|
||||
static List<float> queuedPops = new List<float>();
|
||||
|
||||
public static OctopusMachine instance;
|
||||
|
||||
public enum Bops
|
||||
{
|
||||
Bop,
|
||||
Joyful,
|
||||
Upset,
|
||||
Shocked,
|
||||
Happy,
|
||||
Angry,
|
||||
}
|
||||
|
||||
public enum Actives
|
||||
{
|
||||
Activate,
|
||||
Deactivate,
|
||||
}
|
||||
|
||||
void Awake()
|
||||
@ -114,57 +211,199 @@ namespace HeavenStudio.Games
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
private void Start()
|
||||
{
|
||||
bg.color = backgroundColor;
|
||||
foreach (var octo in octopodes) octo.AnimationColor(0);
|
||||
bopStatus = 0;
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
if (queuedSqueezes.Count > 0) queuedSqueezes.Clear();
|
||||
if (queuedReleases.Count > 0) queuedReleases.Clear();
|
||||
if (queuedPops.Count > 0) queuedPops.Clear();
|
||||
|
||||
mat.SetColor("_ColorAlpha", new Color(0.97f, 0.235f, 0.54f));
|
||||
}
|
||||
|
||||
private void AllFunction()
|
||||
private void Update()
|
||||
{
|
||||
//Octopus1;
|
||||
}
|
||||
if (queuePrepare) {
|
||||
foreach (var octo in octopodes) octo.queuePrepare = true;
|
||||
if (Text.text is "Wrong! \nTry Again!" or "Good!") Text.text = "";
|
||||
queuePrepare = false;
|
||||
}
|
||||
|
||||
public void Prepare(float beat)
|
||||
{
|
||||
//AllAnimate("Prepare");
|
||||
isPreparing = true;
|
||||
}
|
||||
|
||||
public void Expand(float beat)
|
||||
{
|
||||
Debug.Log("expand event rn");
|
||||
}
|
||||
|
||||
public void Bop(float beat, float length, bool doesBop, bool autoBop)
|
||||
{
|
||||
bopOn = autoBop;
|
||||
if (doesBop)
|
||||
if (Conductor.instance.ReportBeat(ref lastReportedBeat))
|
||||
{
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + i, delegate
|
||||
{
|
||||
|
||||
})
|
||||
});
|
||||
if (bopIterate >= 3) {
|
||||
bopStatus =
|
||||
bopIterate = 0;
|
||||
autoAction = false;
|
||||
}
|
||||
|
||||
if (autoAction) bopIterate++;
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayAnimation(float beat, bool keepBopping, int whichBop)
|
||||
public static void Prepare(float beat, float prepBeats)
|
||||
{
|
||||
|
||||
if (GameManager.instance.currentGame != "octopusMachine") {
|
||||
OctopusMachine.queuePrepare = true;
|
||||
} else {
|
||||
BeatAction.New(instance.gameObject, new List<BeatAction.Action>() {
|
||||
new BeatAction.Action(beat - prepBeats, delegate {
|
||||
OctopusMachine.queuePrepare = true;
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void GameplayModifiers(float beat, Color bgColor, Color octoColor, bool oct1, bool oct2, bool oct3)
|
||||
public void ChangeText(string text, string youText)
|
||||
{
|
||||
Background.color = bgColor;
|
||||
|
||||
Octopus1.GameplayModifiers(oct1, octoColor);
|
||||
Octopus2.GameplayModifiers(oct2, octoColor);
|
||||
Octopus3.GameplayModifiers(oct3, octoColor);
|
||||
Text.text = text;
|
||||
YouText.text = youText;
|
||||
YouArrow.SetActive(youText != "");
|
||||
}
|
||||
|
||||
public void AutoAction(bool autoBop, bool autoText, string hitText, string missText)
|
||||
{
|
||||
autoAction = true;
|
||||
if (autoBop) bopStatus = hasMissed ? 2 : 1;
|
||||
if (autoText) Text.text = hasMissed ? missText : hitText;
|
||||
foreach (var octo in octopodes) octo.cantBop = false;
|
||||
hasMissed = false;
|
||||
}
|
||||
|
||||
public void BubbleToggle(bool isInstant, int setActive, float particleStrength, float particleSpeed)
|
||||
{
|
||||
foreach (var bubble in Bubbles) {
|
||||
bubble.gameObject.SetActive(true);
|
||||
|
||||
var main = bubble.main;
|
||||
main.prewarm = isInstant;
|
||||
main.simulationSpeed = particleSpeed/10;
|
||||
|
||||
var emm = bubble.emission;
|
||||
emm.rateOverTime = particleStrength;
|
||||
|
||||
if (setActive == 1) bubble.Stop(true, isInstant ? ParticleSystemStopBehavior.StopEmittingAndClear : ParticleSystemStopBehavior.StopEmitting);
|
||||
else bubble.Play();
|
||||
}
|
||||
}
|
||||
|
||||
public void OctoAction(float beat, float length, string action)
|
||||
{
|
||||
if (action != "Squeeze" && !octopodes[0].isSqueezed) return;
|
||||
if (!intervalStarted) StartInterval(beat, length);
|
||||
octopodes[0].OctoAction(action);
|
||||
|
||||
var queuedList = queuedSqueezes;
|
||||
if (action == "Release") queuedList = queuedReleases;
|
||||
else if (action == "Pop") queuedList = queuedPops;
|
||||
|
||||
queuedList.Add(beat - intervalStartBeat);
|
||||
}
|
||||
|
||||
public void Bop(float length, int whichBop, bool singleBop, bool keepBop)
|
||||
{
|
||||
foreach (var octo in octopodes) {
|
||||
if (singleBop) octo.PlayAnimation(whichBop);
|
||||
if (keepBop) bopStatus = whichBop;
|
||||
octo.cantBop = !keepBop;
|
||||
}
|
||||
}
|
||||
|
||||
public void FadeBackgroundColor(Color color, float beats)
|
||||
{
|
||||
var seconds = Conductor.instance.secPerBeat * beats;
|
||||
|
||||
if (bgColorTween != null)
|
||||
bgColorTween.Kill(true);
|
||||
|
||||
if (seconds == 0) bg.color = color;
|
||||
else bgColorTween = bg.DOColor(color, seconds);
|
||||
}
|
||||
|
||||
public void ChangeColor(Color bgStart, Color bgEnd, Color octoColor, Color octoSqueezedColor, float beats, bool bgInstant)
|
||||
{
|
||||
FadeBackgroundColor(bgStart, 0f);
|
||||
if (!bgInstant) FadeBackgroundColor(bgEnd, beats);
|
||||
backgroundColor = bgEnd;
|
||||
octopodesColor = octoColor;
|
||||
octopodesSqueezedColor = octoSqueezedColor;
|
||||
foreach (var octo in octopodes) octo.AnimationColor(octo.isSqueezed ? 1 : 0);
|
||||
}
|
||||
|
||||
public void OctopusModifiers(float beat, float oct1x, float oct2x, float oct3x, float oct1y, float oct2y, float oct3y, bool oct1, bool oct2, bool oct3)
|
||||
{
|
||||
octopodes[0].OctopusModifiers(oct1x, oct1y, oct1);
|
||||
octopodes[1].OctopusModifiers(oct2x, oct2y, oct2);
|
||||
octopodes[2].OctopusModifiers(oct3x, oct3y, oct3);
|
||||
}
|
||||
|
||||
public void ForceSqueeze()
|
||||
{
|
||||
foreach (var octo in octopodes) octo.ForceSqueeze();
|
||||
}
|
||||
|
||||
public void StartInterval(float beat, float length)
|
||||
{
|
||||
intervalStartBeat = beat;
|
||||
beatInterval = length;
|
||||
intervalStarted = true;
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>() {
|
||||
new BeatAction.Action(beat + length, delegate {
|
||||
PassTurn(beat + length);
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
public void PassTurn(float beat)
|
||||
{
|
||||
intervalStarted = false;
|
||||
var queuedInputs = new List<BeatAction.Action>();
|
||||
foreach (var squeeze in queuedSqueezes) {
|
||||
queuedInputs.Add(new BeatAction.Action(beat + squeeze, delegate { octopodes[1].OctoAction("Squeeze"); }));
|
||||
ScheduleInput(beat, beatInterval + squeeze, InputType.STANDARD_DOWN, SqueezeHit, Miss, Miss);
|
||||
}
|
||||
foreach (var release in queuedReleases) {
|
||||
queuedInputs.Add(new BeatAction.Action(beat + release, delegate { octopodes[1].OctoAction("Release"); }));
|
||||
ScheduleInput(beat, beatInterval + release, InputType.STANDARD_UP, ReleaseHit, Miss, Miss);
|
||||
}
|
||||
foreach (var pop in queuedPops) {
|
||||
queuedInputs.Add(new BeatAction.Action(beat + pop, delegate { octopodes[1].OctoAction("Pop"); }));
|
||||
ScheduleInput(beat, beatInterval + pop, InputType.STANDARD_UP, PopHit, Miss, Miss);
|
||||
}
|
||||
queuedSqueezes.Clear();
|
||||
queuedReleases.Clear();
|
||||
queuedPops.Clear();
|
||||
|
||||
// thanks to ras for giving me this line of code
|
||||
// i do NOT understand how it works
|
||||
queuedInputs.Sort((s1, s2) => s1.beat.CompareTo(s2.beat));
|
||||
BeatAction.New(gameObject, queuedInputs);
|
||||
}
|
||||
|
||||
private void SqueezeHit(PlayerActionEvent caller, float state)
|
||||
{
|
||||
octopodes[2].OctoAction("Squeeze");
|
||||
}
|
||||
|
||||
private void ReleaseHit(PlayerActionEvent caller, float state)
|
||||
{
|
||||
octopodes[2].OctoAction("Release");
|
||||
}
|
||||
|
||||
private void PopHit(PlayerActionEvent caller, float state)
|
||||
{
|
||||
octopodes[2].OctoAction("Pop");
|
||||
}
|
||||
|
||||
private void Miss(PlayerActionEvent caller)
|
||||
{
|
||||
hasMissed = true;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user