2023-03-27 03:30:11 +00:00
using HeavenStudio.Util ;
using System ;
using System.Collections.Generic ;
using UnityEngine ;
2023-05-28 04:33:02 +00:00
using TMPro ;
2023-03-27 03:30:11 +00:00
// using GhostlyGuy's Balls;
namespace HeavenStudio.Games.Loaders
{
using static Minigames ;
public static class NtrOctopusMachineLoader
{
public static Minigame AddGame ( EventCaller eventCaller ) {
2023-05-28 04:33:02 +00:00
return new Minigame ( "octopusMachine" , "Octopus Machine" , "FFf362B" , false , false , new List < GameAction > ( )
2023-03-27 03:30:11 +00:00
{
2023-05-28 04:33:02 +00:00
new GameAction ( "bop" , "Bop" )
2023-03-27 03:30:11 +00:00
{
2023-05-28 04:33:02 +00:00
function = delegate {
var e = eventCaller . currentEntity ;
OctopusMachine . instance . Bop ( e . length , e [ "whichBop" ] , e [ "singleBop" ] , e [ "keepBop" ] ) ;
2023-03-27 03:30:11 +00:00
} ,
2023-05-28 04:33:02 +00:00
parameters = new List < Param > ( ) {
2024-01-15 02:04:10 +00:00
new Param ( "singleBop" , true , "Bop" , "Toggle if the octopodes should bop for the duration of this event. Since this event is not stretchable, they will only bop once." ) ,
new Param ( "keepBop" , false , "Bop (Auto)" , "Toggle if the octopodes should automatically bop until another Bop event is reached." ) ,
new Param ( "whichBop" , OctopusMachine . Bops . Bop , "Which Bop" , "Set the type of bop." ) ,
2023-03-27 03:30:11 +00:00
} ,
} ,
2023-05-28 04:33:02 +00:00
new GameAction ( "startInterval" , "Start Interval" )
2023-03-27 03:30:11 +00:00
{
2023-05-28 04:33:02 +00:00
function = delegate {
var e = eventCaller . currentEntity ;
OctopusMachine . instance . StartInterval ( e . beat , e . length ) ;
2023-03-27 03:30:11 +00:00
} ,
2023-05-28 04:33:02 +00:00
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 > ( ) {
2024-01-15 02:04:10 +00:00
new Param ( "shouldPrep" , true , "Prepare" , "Toggle if the octopodes should automatically prepare for this cue." , new List < Param . CollapseParam > ( )
2023-09-08 14:27:07 +00:00
{
2023-10-27 20:19:11 +00:00
new Param . CollapseParam ( ( x , _ ) = > ( bool ) x , new string [ ] { "prepBeats" } )
2023-09-08 14:27:07 +00:00
} ) ,
2024-01-15 02:04:10 +00:00
new Param ( "prepBeats" , new EntityTypes . Float ( 0 , 4 , 1 ) , "Prepare Beats" , "Set how many beats before the cue the octopodes should prepare." ) ,
2023-05-28 04:33:02 +00:00
} ,
preFunctionLength = 4f ,
2023-03-27 03:30:11 +00:00
preFunction = delegate {
var e = eventCaller . currentEntity ;
2023-10-27 20:19:11 +00:00
if ( e [ "shouldPrep" ] ) OctopusMachine . queuePrepare = e . beat - e [ "prepBeats" ] ;
2023-03-27 03:30:11 +00:00
} ,
2023-05-28 04:33:02 +00:00
priority = 1 ,
2023-03-27 03:30:11 +00:00
} ,
2023-05-28 04:33:02 +00:00
new GameAction ( "release" , "Release" )
2023-03-27 03:30:11 +00:00
{
2023-05-28 04:33:02 +00:00
function = delegate {
2023-03-27 03:30:11 +00:00
var e = eventCaller . currentEntity ;
2023-05-28 04:33:02 +00:00
OctopusMachine . instance . OctoAction ( e . beat , e . length , "Release" ) ;
2023-03-27 03:30:11 +00:00
} ,
2023-05-28 04:33:02 +00:00
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 ,
2023-03-27 03:30:11 +00:00
} ,
2023-05-28 04:33:02 +00:00
new GameAction ( "automaticActions" , "Automatic Actions" )
2023-03-27 03:30:11 +00:00
{
function = delegate {
2023-05-28 04:33:02 +00:00
var e = eventCaller . currentEntity ;
2023-06-04 04:30:42 +00:00
OctopusMachine . instance . AutoAction ( e [ "forceBop" ] , e [ "autoBop" ] , e [ "autoText" ] , e [ "hitText" ] , e [ "missText" ] ) ;
2023-03-27 03:30:11 +00:00
} ,
2023-05-28 04:33:02 +00:00
parameters = new List < Param > ( ) {
2024-01-15 02:04:10 +00:00
new Param ( "forceBop" , true , "Force Bop" , "Toggle if a bop should be forced to play, even if an animation is already playing." ) ,
new Param ( "autoBop" , true , "Hit/Miss Bop" , "Toggle if the octopodes should bop depending on if you hit or missed the cues." ) ,
new Param ( "autoText" , true , "Display Text" , "Toggle if text should display depending on if you hit or missed the cues." , new List < Param . CollapseParam > ( )
2023-09-08 14:27:07 +00:00
{
2023-10-27 20:19:11 +00:00
new Param . CollapseParam ( ( x , _ ) = > ( bool ) x , new string [ ] { "hitText" , "missText" } )
2023-09-08 14:27:07 +00:00
} ) ,
2024-01-15 02:04:10 +00:00
new Param ( "hitText" , "Good!" , "Hit Text" , "Set the text to display if you hit the cues." ) ,
new Param ( "missText" , "Wrong! Try again!" , "Miss Text" , "Set the text to display if you missed the cues." ) ,
2023-03-27 03:30:11 +00:00
} ,
2023-05-28 04:33:02 +00:00
} ,
new GameAction ( "forceSqueeze" , "Force Squeeze" )
{
function = delegate { OctopusMachine . instance . ForceSqueeze ( ) ; }
} ,
new GameAction ( "prepare" , "Prepare" )
{
2023-10-27 20:19:11 +00:00
function = delegate { OctopusMachine . queuePrepare = eventCaller . currentEntity . beat ; } ,
2023-03-27 03:30:11 +00:00
defaultLength = 0.5f ,
} ,
2023-05-28 04:33:02 +00:00
new GameAction ( "bubbles" , "Bubbles" )
2023-03-27 03:30:11 +00:00
{
2023-05-28 04:33:02 +00:00
function = delegate {
var e = eventCaller . currentEntity ;
OctopusMachine . instance . BubbleToggle ( e [ "isInstant" ] , e [ "setActive" ] , e [ "particleStrength" ] , e [ "particleSpeed" ] ) ;
} ,
parameters = new List < Param > ( ) {
2024-01-15 02:04:10 +00:00
new Param ( "isInstant" , true , "Instant" , "Toggle if the particles should start or stop instantly." ) ,
new Param ( "setActive" , OctopusMachine . Actives . Activate , "State" , "Set if the bubbles should appear or disappear." , new List < Param . CollapseParam > ( )
2023-09-08 14:27:07 +00:00
{
2023-10-27 20:19:11 +00:00
new Param . CollapseParam ( ( x , _ ) = > ( int ) x = = ( int ) OctopusMachine . Actives . Activate , new string [ ] { "particleStrength" } )
2023-09-08 14:27:07 +00:00
} ) ,
2024-01-15 02:04:10 +00:00
new Param ( "particleStrength" , new EntityTypes . Float ( 0 , 25 , 3 ) , "Intensity" , "Set the intensity of the bubbles." ) ,
new Param ( "particleSpeed" , new EntityTypes . Float ( 0 , 25 , 5 ) , "Speed" , "Set the speed of the bubbles." ) ,
2023-05-28 04:33:02 +00:00
} ,
} ,
2024-01-15 02:04:10 +00:00
new GameAction ( "changeText" , "Text" )
2023-05-28 04:33:02 +00:00
{
function = delegate {
var e = eventCaller . currentEntity ;
OctopusMachine . instance . ChangeText ( e [ "text" ] , e [ "youText" ] ) ;
} ,
parameters = new List < Param > ( ) {
2024-01-15 02:04:10 +00:00
new Param ( "text" , "Do what the others do." , "Text" , "Set the text on the screen." ) ,
new Param ( "youText" , "You" , "Player Text" , "Set the text that points to the player." ) ,
2023-05-28 04:33:02 +00:00
} ,
} ,
new GameAction ( "changeColor" , "Change Color" )
{
function = delegate {
var e = eventCaller . currentEntity ;
2023-08-12 03:30:03 +00:00
OctopusMachine . instance . BackgroundColor ( e . beat , e . length , e [ "color1" ] , e [ "color2" ] , e [ "octoColor" ] , e [ "squeezedColor" ] , e [ "ease" ] ) ;
2023-03-27 03:30:11 +00:00
} ,
2023-05-28 04:33:02 +00:00
parameters = new List < Param > ( ) {
2024-01-15 02:04:10 +00:00
new Param ( "color1" , new Color ( 1f , 0.87f , 0.24f ) , "Start BG Color" , "Set the color at the start of the event." ) ,
new Param ( "color2" , new Color ( 1f , 0.87f , 0.24f ) , "End BG Color" , "Set the color at the end of the event." ) ,
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." ) ,
new Param ( "ease" , Util . EasingFunction . Ease . Linear , "Ease" , "Set the easing of the action." ) ,
2023-05-28 04:33:02 +00:00
} ,
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 > ( ) {
2024-01-15 02:04:10 +00:00
new Param ( "oct1" , true , "Show Octopus 1" , "Toggle if the first octopus should be enabled." , new List < Param . CollapseParam > ( )
2023-09-08 14:27:07 +00:00
{
2023-10-27 20:19:11 +00:00
new Param . CollapseParam ( ( x , _ ) = > ( bool ) x , new string [ ] { "oct1x" , "oct1y" } )
2023-09-08 14:27:07 +00:00
} ) ,
2024-01-15 02:04:10 +00:00
new Param ( "oct1x" , new EntityTypes . Float ( - 10 , 10 , - 4.64f ) , "X Octopus 1" , "Set the position on the X axis of octopus 1." ) ,
new Param ( "oct1y" , new EntityTypes . Float ( - 10 , 10 , 2.5f ) , "Y Octopus 1" , "Set the position on the Y axis of octopus 1." ) ,
new Param ( "oct2" , true , "Show Octopus 2" , "Toggle if the second octopus should be enabled." , new List < Param . CollapseParam > ( )
2023-09-08 14:27:07 +00:00
{
2023-10-27 20:19:11 +00:00
new Param . CollapseParam ( ( x , _ ) = > ( bool ) x , new string [ ] { "oct2x" , "oct2y" } )
2023-09-08 14:27:07 +00:00
} ) ,
2024-01-15 02:04:10 +00:00
new Param ( "oct2x" , new EntityTypes . Float ( - 10 , 10 , - 0.637f ) , "X Octopus 2" , "Set the position on the X axis of octopus 2." ) ,
new Param ( "oct2y" , new EntityTypes . Float ( - 10 , 10 , 0f ) , "Y Octopus 2" , "Set the position on the Y axis of octopus 2." ) ,
new Param ( "oct3" , true , "Show Octopus 3" , "Toggle if the third octopus should be enabled." , new List < Param . CollapseParam > ( )
2023-09-08 14:27:07 +00:00
{
2023-10-27 20:19:11 +00:00
new Param . CollapseParam ( ( x , _ ) = > ( bool ) x , new string [ ] { "oct3x" , "oct3y" } )
2023-09-08 14:27:07 +00:00
} ) ,
2024-01-15 02:04:10 +00:00
new Param ( "oct3x" , new EntityTypes . Float ( - 10 , 10 , 3.363f ) , "X Octopus 3" , "Set the position on the X axis of octopus 3." ) ,
new Param ( "oct3y" , new EntityTypes . Float ( - 10 , 10 , - 2.5f ) , "Y Octopus 3" , "Set the position on the Y axis of octopus 3." ) ,
2023-03-27 03:30:11 +00:00
} ,
defaultLength = 0.5f ,
} ,
2023-05-28 17:34:44 +00:00
} ,
new List < string > ( ) { "ntr" , "repeat" } ,
"ntrcork" , "en" ,
2024-03-29 02:35:07 +00:00
new List < string > ( ) { } ,
chronologicalSortKey : 204
2023-05-28 17:34:44 +00:00
) ;
2023-03-27 03:30:11 +00:00
}
}
}
namespace HeavenStudio.Games
{
using Scripts_OctopusMachine ;
public partial class OctopusMachine : Minigame
{
2023-05-28 04:33:02 +00:00
[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 ;
[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 ) ;
2023-10-27 20:19:11 +00:00
public static double queuePrepare = double . MaxValue ;
2023-05-28 04:33:02 +00:00
[Header("Variables")]
public bool hasMissed ;
public int bopStatus = 0 ;
int bopIterate = 0 ;
bool intervalStarted ;
bool autoAction ;
2023-06-10 19:13:29 +00:00
double intervalStartBeat ;
2023-05-28 04:33:02 +00:00
float beatInterval = 1f ;
2023-06-10 19:13:29 +00:00
static List < double > queuedSqueezes = new ( ) ;
static List < double > queuedReleases = new ( ) ;
static List < double > queuedPops = new ( ) ;
2023-03-27 03:30:11 +00:00
public static OctopusMachine instance ;
public enum Bops
{
Bop ,
2023-05-28 04:33:02 +00:00
Happy ,
Angry ,
}
public enum Actives
{
Activate ,
Deactivate ,
2023-03-27 03:30:11 +00:00
}
void Awake ( )
{
instance = this ;
2023-12-05 22:38:52 +00:00
SetupBopRegion ( "octopusMachine" , "bop" , "keepBop" ) ;
2023-03-27 03:30:11 +00:00
}
2023-05-28 04:33:02 +00:00
private void Start ( )
2023-03-27 03:30:11 +00:00
{
2023-05-28 04:33:02 +00:00
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 ( ) ;
2023-10-27 20:19:11 +00:00
queuePrepare = double . MaxValue ;
2023-03-27 03:30:11 +00:00
2023-05-28 04:33:02 +00:00
mat . SetColor ( "_ColorAlpha" , new Color ( 0.97f , 0.235f , 0.54f ) ) ;
2023-06-03 23:30:17 +00:00
foreach ( var evt in scheduledInputs )
{
evt . Disable ( ) ;
}
2023-05-28 04:33:02 +00:00
}
2023-11-23 16:19:39 +00:00
public override void OnBeatPulse ( double beat )
{
if ( bopIterate > = 3 )
{
bopStatus =
bopIterate = 0 ;
autoAction = false ;
}
if ( autoAction ) bopIterate + + ;
2023-12-05 22:38:52 +00:00
bool keepBop = BeatIsInBopRegion ( beat ) ;
2023-11-23 16:19:39 +00:00
foreach ( var octo in octopodes )
{
2023-12-05 22:38:52 +00:00
octo . cantBop = ! keepBop ;
2023-11-23 16:19:39 +00:00
octo . RequestBop ( ) ;
}
}
2023-05-28 04:33:02 +00:00
private void Update ( )
{
2023-08-12 03:30:03 +00:00
BackgroundColorUpdate ( ) ;
2023-10-27 20:19:11 +00:00
if ( queuePrepare < = Conductor . instance . songPositionInBeatsAsDouble ) {
foreach ( var octo in octopodes ) octo . queuePrepare = queuePrepare ;
2023-06-04 04:30:42 +00:00
if ( Text . text is "Wrong! Try Again!" or "Good!" ) Text . text = "" ;
2023-10-27 20:19:11 +00:00
queuePrepare = double . MaxValue ;
2023-05-28 04:33:02 +00:00
}
2023-03-27 03:30:11 +00:00
}
2023-05-28 04:33:02 +00:00
public void ChangeText ( string text , string youText )
2023-03-27 03:30:11 +00:00
{
2023-05-28 04:33:02 +00:00
Text . text = text ;
YouText . text = youText ;
YouArrow . SetActive ( youText ! = "" ) ;
2023-03-27 03:30:11 +00:00
}
2023-06-04 04:30:42 +00:00
public void AutoAction ( bool forceBop , bool autoBop , bool autoText , string hitText , string missText )
2023-03-27 03:30:11 +00:00
{
2023-05-28 04:33:02 +00:00
autoAction = true ;
if ( autoBop ) bopStatus = hasMissed ? 2 : 1 ;
if ( autoText ) Text . text = hasMissed ? missText : hitText ;
2023-06-04 04:30:42 +00:00
foreach ( var octo in octopodes ) {
if ( forceBop ) octo . PlayAnimation ( bopStatus ) ;
octo . cantBop = false ;
}
2023-05-28 04:33:02 +00:00
hasMissed = false ;
2023-03-27 03:30:11 +00:00
}
2023-05-28 04:33:02 +00:00
public void BubbleToggle ( bool isInstant , int setActive , float particleStrength , float particleSpeed )
2023-03-27 03:30:11 +00:00
{
2023-05-28 04:33:02 +00:00
foreach ( var bubble in Bubbles ) {
bubble . gameObject . SetActive ( true ) ;
var main = bubble . main ;
main . prewarm = isInstant ;
2023-10-27 20:19:11 +00:00
main . simulationSpeed = particleSpeed / 10 ;
2023-05-28 04:33:02 +00:00
var emm = bubble . emission ;
emm . rateOverTime = particleStrength ;
if ( setActive = = 1 ) bubble . Stop ( true , isInstant ? ParticleSystemStopBehavior . StopEmittingAndClear : ParticleSystemStopBehavior . StopEmitting ) ;
else bubble . Play ( ) ;
2023-03-27 03:30:11 +00:00
}
}
2023-06-10 19:13:29 +00:00
public void OctoAction ( double beat , float length , string action )
2023-03-27 03:30:11 +00:00
{
2023-05-28 04:33:02 +00:00
if ( action ! = "Squeeze" & & ! octopodes [ 0 ] . isSqueezed ) return ;
if ( ! intervalStarted ) StartInterval ( beat , length ) ;
octopodes [ 0 ] . OctoAction ( action ) ;
2023-10-27 20:19:11 +00:00
// var queuedList = queuedSqueezes;
// if (action == "Release") queuedList = queuedReleases;
// else if (action == "Pop") queuedList = queuedPops;
var queuedList = action switch {
"Release" = > queuedReleases ,
"Pop" = > queuedPops ,
_ = > queuedSqueezes ,
} ;
2023-05-28 04:33:02 +00:00
queuedList . Add ( beat - intervalStartBeat ) ;
2023-03-27 03:30:11 +00:00
}
2023-06-10 19:13:29 +00:00
public void Bop ( double length , int whichBop , bool singleBop , bool keepBop )
2023-03-27 03:30:11 +00:00
{
2023-05-28 04:33:02 +00:00
foreach ( var octo in octopodes ) {
if ( singleBop ) octo . PlayAnimation ( whichBop ) ;
if ( keepBop ) bopStatus = whichBop ;
}
}
2023-08-12 03:30:03 +00:00
private double colorStartBeat = - 1 ;
private float colorLength = 0f ;
private Color colorStart = new Color ( 1 , 0.87f , 0.24f ) ; //obviously put to the default color of the game
private Color colorEnd = new Color ( 1 , 0.87f , 0.24f ) ;
private Util . EasingFunction . Ease colorEase ; //putting Util in case this game is using jukebox
//call this in update
private void BackgroundColorUpdate ( )
2023-05-28 04:33:02 +00:00
{
2023-08-12 03:30:03 +00:00
float normalizedBeat = Mathf . Clamp01 ( Conductor . instance . GetPositionFromBeat ( colorStartBeat , colorLength ) ) ;
var func = Util . EasingFunction . GetEasingFunction ( colorEase ) ;
2023-05-28 04:33:02 +00:00
2023-08-12 03:30:03 +00:00
float newR = func ( colorStart . r , colorEnd . r , normalizedBeat ) ;
float newG = func ( colorStart . g , colorEnd . g , normalizedBeat ) ;
float newB = func ( colorStart . b , colorEnd . b , normalizedBeat ) ;
2023-05-28 04:33:02 +00:00
2023-08-12 03:30:03 +00:00
bg . color = new Color ( newR , newG , newB ) ;
2023-05-28 04:33:02 +00:00
}
2023-08-12 03:30:03 +00:00
public void BackgroundColor ( double beat , float length , Color colorStartSet , Color colorEndSet , Color octoColor , Color octoSqueezeColor , int ease )
2023-05-28 04:33:02 +00:00
{
2023-08-12 03:30:03 +00:00
colorStartBeat = beat ;
colorLength = length ;
colorStart = colorStartSet ;
colorEnd = colorEndSet ;
colorEase = ( Util . EasingFunction . Ease ) ease ;
2023-05-28 04:33:02 +00:00
octopodesColor = octoColor ;
2023-08-12 03:30:03 +00:00
octopodesSqueezedColor = octoSqueezeColor ;
2023-05-28 04:33:02 +00:00
foreach ( var octo in octopodes ) octo . AnimationColor ( octo . isSqueezed ? 1 : 0 ) ;
}
2023-08-12 03:30:03 +00:00
//call this in OnPlay(double beat) and OnGameSwitch(double beat)
private void PersistColor ( double beat )
{
2023-10-27 20:19:11 +00:00
var bgColor = GameManager . instance . Beatmap . Entities . FindLast ( c = > c . datamodel = = "octopusMachine/changeColor" & & c . beat < beat ) ;
if ( bgColor ! = null ) {
BackgroundColor ( bgColor . beat , bgColor . length , bgColor [ "color1" ] , bgColor [ "color2" ] , bgColor [ "octoColor" ] , bgColor [ "squeezedColor" ] , bgColor [ "ease" ] ) ;
2023-08-12 03:30:03 +00:00
}
}
public override void OnPlay ( double beat )
{
2024-01-17 23:49:14 +00:00
if ( queuedSqueezes . Count > 0 ) queuedSqueezes . Clear ( ) ;
if ( queuedReleases . Count > 0 ) queuedReleases . Clear ( ) ;
if ( queuedPops . Count > 0 ) queuedPops . Clear ( ) ;
queuePrepare = double . MaxValue ;
2023-08-12 03:30:03 +00:00
PersistColor ( beat ) ;
}
public override void OnGameSwitch ( double beat )
{
PersistColor ( beat ) ;
}
2023-06-10 19:13:29 +00:00
public void OctopusModifiers ( double beat , float oct1x , float oct2x , float oct3x , float oct1y , float oct2y , float oct3y , bool oct1 , bool oct2 , bool oct3 )
2023-05-28 04:33:02 +00:00
{
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 ( ) ;
}
2023-06-10 19:13:29 +00:00
public void StartInterval ( double beat , float length )
2023-05-28 04:33:02 +00:00
{
intervalStartBeat = beat ;
beatInterval = length ;
intervalStarted = true ;
2023-09-11 22:28:04 +00:00
BeatAction . New ( this , new List < BeatAction . Action > ( ) {
2023-05-28 04:33:02 +00:00
new BeatAction . Action ( beat + length , delegate {
PassTurn ( beat + length ) ;
} ) ,
} ) ;
}
2023-06-10 19:13:29 +00:00
public void PassTurn ( double beat )
2023-05-28 04:33:02 +00:00
{
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" ) ; } ) ) ;
2023-10-29 19:44:47 +00:00
ScheduleInput ( beat , beatInterval + squeeze , InputAction_BasicPress , SqueezeHit , Miss , Miss ) ;
2023-05-28 04:33:02 +00:00
}
foreach ( var release in queuedReleases ) {
queuedInputs . Add ( new BeatAction . Action ( beat + release , delegate { octopodes [ 1 ] . OctoAction ( "Release" ) ; } ) ) ;
2023-10-29 19:44:47 +00:00
ScheduleInput ( beat , beatInterval + release , InputAction_BasicRelease , ReleaseHit , Miss , Miss ) ;
2023-05-28 04:33:02 +00:00
}
foreach ( var pop in queuedPops ) {
queuedInputs . Add ( new BeatAction . Action ( beat + pop , delegate { octopodes [ 1 ] . OctoAction ( "Pop" ) ; } ) ) ;
2023-10-29 19:44:47 +00:00
ScheduleInput ( beat , beatInterval + pop , InputAction_FlickRelease , PopHit , Miss , Miss ) ;
2023-05-28 04:33:02 +00:00
}
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 ) ) ;
2023-09-11 22:28:04 +00:00
BeatAction . New ( this , queuedInputs ) ;
2023-05-28 04:33:02 +00:00
}
private void SqueezeHit ( PlayerActionEvent caller , float state )
{
octopodes [ 2 ] . OctoAction ( "Squeeze" ) ;
2023-06-10 19:13:29 +00:00
if ( state < = - 1f | | state > = 1f ) SoundByte . PlayOneShotGame ( "nearMiss" ) ;
2023-05-28 04:33:02 +00:00
}
private void ReleaseHit ( PlayerActionEvent caller , float state )
{
octopodes [ 2 ] . OctoAction ( "Release" ) ;
2023-06-10 19:13:29 +00:00
if ( state < = - 1f | | state > = 1f ) SoundByte . PlayOneShotGame ( "nearMiss" ) ;
2023-05-28 04:33:02 +00:00
}
private void PopHit ( PlayerActionEvent caller , float state )
{
octopodes [ 2 ] . OctoAction ( "Pop" ) ;
2023-06-10 19:13:29 +00:00
if ( state < = - 1f | | state > = 1f ) SoundByte . PlayOneShotGame ( "nearMiss" ) ;
2023-05-28 04:33:02 +00:00
}
2023-06-04 04:30:42 +00:00
private void Miss ( PlayerActionEvent caller ) { }
2023-03-27 03:30:11 +00:00
}
}