2022-07-29 19:06:22 +00:00
using System ;
2021-12-29 06:52:48 +00:00
using System.Collections ;
using System.Collections.Generic ;
using UnityEngine ;
2022-03-14 14:21:05 +00:00
using HeavenStudio.Util ;
2021-12-29 06:52:48 +00:00
2022-04-12 16:14:46 +00:00
namespace HeavenStudio.Games.Loaders
{
using static Minigames ;
2022-07-29 19:06:22 +00:00
public static class RvlNewKarateLoader
2022-04-12 16:14:46 +00:00
{
public static Minigame AddGame ( EventCaller eventCaller ) {
2022-07-29 19:06:22 +00:00
return new Minigame ( "karateman" , "Karate Man [INDEV REWORK]" , "70A8D8" , false , false , new List < GameAction > ( )
2022-04-12 16:14:46 +00:00
{
2022-08-07 23:40:06 +00:00
new GameAction ( "bop" , delegate { KarateMan . instance . ToggleBop ( eventCaller . currentEntity . toggle ) ; } , 0.5f , true , new List < Param > ( )
{
new Param ( "toggle" , true , "Bop" , "Whether to bop to the beat or not" )
} ) ,
2022-07-29 19:06:22 +00:00
new GameAction ( "hit" , delegate { var e = eventCaller . currentEntity ; KarateMan . instance . CreateItem ( e . beat , e . type ) ; } , 2 , false ,
new List < Param > ( )
{
new Param ( "type" , KarateMan . HitType . Pot , "Object" , "The object to fire" )
} ) ,
new GameAction ( "bulb" , delegate { var e = eventCaller . currentEntity ; KarateMan . instance . CreateBulbSpecial ( e . beat , e . type , e . colorA ) ; } , 2 , false ,
new List < Param > ( )
{
new Param ( "type" , KarateMan . LightBulbType . Normal , "Type" , "The preset bulb type. Yellow is used for kicks while Blue is used for combos" ) ,
2022-08-03 20:14:37 +00:00
new Param ( "colorA" , new Color ( 1f , 1f , 1f ) , "Custom Color" , "The color to use when the bulb type is set to Custom" )
2022-07-29 19:06:22 +00:00
} ) ,
2022-07-29 19:26:59 +00:00
new GameAction ( "kick" , delegate { KarateMan . instance . Kick ( eventCaller . currentEntity . beat ) ; } , 4f ) ,
2022-04-12 16:14:46 +00:00
new GameAction ( "combo" , delegate { KarateMan . instance . Combo ( eventCaller . currentEntity . beat ) ; } , 4f ) ,
2022-07-29 19:06:22 +00:00
new GameAction ( "hitX" , delegate { var e = eventCaller . currentEntity ; KarateMan . instance . DoWord ( e . beat , e . type ) ; } , 1f , false ,
new List < Param > ( )
2022-04-12 16:14:46 +00:00
{
2022-07-29 19:06:22 +00:00
new Param ( "type" , KarateMan . HitThree . HitThree , "Type" , "The warning text to show" )
} ) ,
2022-08-11 23:36:47 +00:00
new GameAction ( "special camera" , delegate { var e = eventCaller . currentEntity ; KarateMan . instance . DoSpecialCamera ( e . beat , e . length , e . toggle ) ; } , 8f , true , new List < Param > ( )
{
new Param ( "toggle" , true , "Return Camera" , "Camera zooms back in?" ) ,
} ) ,
2022-08-07 23:40:06 +00:00
new GameAction ( "prepare" , delegate { var e = eventCaller . currentEntity ; KarateMan . instance . Prepare ( e . beat , e . length ) ; } , 1f , true ) ,
2022-08-07 01:09:28 +00:00
new GameAction ( "set background effects" , delegate { var e = eventCaller . currentEntity ; KarateMan . instance . SetBgAndShadowCol ( e . beat , e . length , e . type , e . type2 , e . colorA , e . colorB , e . type3 ) ; } , 0.5f , true , new List < Param > ( )
2022-04-12 16:14:46 +00:00
{
new Param ( "type" , KarateMan . BackgroundType . Yellow , "Background Type" , "The preset background type" ) ,
new Param ( "type2" , KarateMan . ShadowType . Tinted , "Shadow Type" , "The shadow type. If Tinted doesn't work with your background color try Custom" ) ,
new Param ( "colorA" , new Color ( ) , "Custom Background Color" , "The background color to use when background type is set to Custom" ) ,
2022-08-07 01:09:28 +00:00
new Param ( "colorB" , new Color ( ) , "Custom Shadow Color" , "The shadow color to use when shadow type is set to Custom. When fading the background colour shadows fade to this color" ) ,
2022-08-06 23:15:44 +00:00
new Param ( "type3" , KarateMan . BackgroundFXType . None , "FX Type" , "The background effect to be displayed. Fade uses the entity length to determine colour fading speed" )
2022-04-12 16:14:46 +00:00
} ) ,
2022-08-06 23:15:44 +00:00
new GameAction ( "set background texture" , delegate { var e = eventCaller . currentEntity ; KarateMan . instance . SetBgTexture ( e . type , e . type2 , e . colorA , e . colorB ) ; } , 0.5f , false , new List < Param > ( )
2022-08-06 01:19:18 +00:00
{
new Param ( "type" , KarateMan . BackgroundTextureType . Plain , "Texture" , "The type of background texture to use" ) ,
new Param ( "type2" , KarateMan . ShadowType . Tinted , "Color Filter Type" , "The method used to apply colour to the texture" ) ,
new Param ( "colorA" , new Color ( ) , "Custom Filter Color" , "The filter color to use when color filter type is set to Custom" ) ,
2022-08-06 23:15:44 +00:00
new Param ( "colorB" , new Color ( ) , "Fading Filter Color" , "When using the Fade background effect, make filter colour fade to this colour" ) ,
2022-08-06 01:19:18 +00:00
} ) ,
2022-08-11 23:36:47 +00:00
new GameAction ( "set object colors" , delegate { var e = eventCaller . currentEntity ; KarateMan . instance . UpdateMaterialColour ( e . colorA , e . colorB , e . colorC ) ; } , 0.5f , true , new List < Param > ( )
2022-08-03 21:49:32 +00:00
{
2022-08-11 23:36:47 +00:00
new Param ( "colorA" , new Color ( ) , "Joe Body Color" , "The color to use for Karate Joe's body" ) ,
new Param ( "colorB" , new Color ( ) , "Joe Highlight Color" , "The color to use for Karate Joe's highlights" ) ,
new Param ( "colorC" , new Color ( ) , "Item Color" , "The color to use for the thrown items" ) ,
2022-08-03 21:49:32 +00:00
} ) ,
2022-08-06 01:19:18 +00:00
new GameAction ( "particle effects" , delegate { var e = eventCaller . currentEntity ; KarateMan . instance . SetParticleEffect ( e . beat , e . type , e . valA , e . valB ) ; } , 0.5f , false , new List < Param > ( )
{
2022-08-06 23:15:44 +00:00
new Param ( "type" , KarateMan . ParticleType . None , "Particle Type" , "The type of particle effect to spawn. Using \"None\" will stop all effects" ) ,
2022-08-07 23:40:06 +00:00
new Param ( "valA" , new EntityTypes . Float ( 0f , 64f , 1f ) , "Wind Strength" , "The strength of the particle wind" ) ,
new Param ( "valB" , new EntityTypes . Float ( 1f , 16f , 1f ) , "Particle Intensity" , "The intensity of the particle effect" )
2022-08-06 02:37:06 +00:00
} ) ,
new GameAction ( "force facial expression" , delegate { KarateMan . instance . SetFaceExpression ( eventCaller . currentEntity . type ) ; } , 0.5f , false , new List < Param > ( )
{
new Param ( "type" , KarateMan . KarateManFaces . Normal , "Facial Expression" , "The facial expression to force Joe to. Special moves may override this" )
2022-08-06 01:19:18 +00:00
} ) ,
2022-07-29 19:06:22 +00:00
2022-04-12 16:14:46 +00:00
// These are still here for backwards-compatibility but are hidden in the editor
2022-07-29 19:06:22 +00:00
new GameAction ( "pot" , delegate { KarateMan . instance . CreateItem ( eventCaller . currentEntity . beat , ( int ) KarateMan . HitType . Pot ) ; } , 2 , hidden : true ) ,
new GameAction ( "rock" , delegate { KarateMan . instance . CreateItem ( eventCaller . currentEntity . beat , ( int ) KarateMan . HitType . Rock ) ; } , 2 , hidden : true ) ,
new GameAction ( "ball" , delegate { KarateMan . instance . CreateItem ( eventCaller . currentEntity . beat , ( int ) KarateMan . HitType . Ball ) ; } , 2 , hidden : true ) ,
new GameAction ( "tacobell" , delegate { KarateMan . instance . CreateItem ( eventCaller . currentEntity . beat , ( int ) KarateMan . HitType . TacoBell ) ; } , 2 , hidden : true ) ,
new GameAction ( "hit4" , delegate { KarateMan . instance . DoWord ( eventCaller . currentEntity . beat , ( int ) KarateMan . HitThree . HitFour ) ; } , hidden : true ) ,
2022-08-06 23:15:44 +00:00
new GameAction ( "bgfxon" , delegate { var e = eventCaller . currentEntity ; KarateMan . instance . SetBgFx ( ( int ) KarateMan . BackgroundFXType . Sunburst , e . beat , e . length ) ; } , hidden : true ) ,
new GameAction ( "bgfxoff" , delegate { var e = eventCaller . currentEntity ; KarateMan . instance . SetBgFx ( ( int ) KarateMan . BackgroundFXType . None , e . beat , e . length ) ; } , hidden : true ) ,
2022-07-29 19:06:22 +00:00
new GameAction ( "hit3" , delegate { var e = eventCaller . currentEntity ; KarateMan . instance . DoWord ( e . beat , e . type ) ; } , 1f , false ,
new List < Param > ( )
{
new Param ( "type" , KarateMan . HitThree . HitThree , "Type" , "The warning text to show" )
} ,
hidden : true ) ,
2022-08-07 01:09:28 +00:00
new GameAction ( "set background color" , delegate { var e = eventCaller . currentEntity ; KarateMan . instance . SetBgAndShadowCol ( e . beat , e . length , e . type , e . type2 , e . colorA , e . colorB , ( int ) KarateMan . instance . currentBgEffect ) ; } , 0.5f , false ,
2022-07-29 19:06:22 +00:00
new List < Param > ( )
{
new Param ( "type" , KarateMan . BackgroundType . Yellow , "Background Type" , "The preset background type" ) ,
new Param ( "type2" , KarateMan . ShadowType . Tinted , "Shadow Type" , "The shadow type. If Tinted doesn't work with your background color try Custom" ) ,
new Param ( "colorA" , new Color ( ) , "Custom Background Color" , "The background color to use when background type is set to Custom" ) ,
new Param ( "colorB" , new Color ( ) , "Custom Shadow Color" , "The shadow color to use when shadow type is set to Custom" ) ,
2022-08-03 20:14:37 +00:00
} ,
hidden : true ) ,
2022-08-06 23:15:44 +00:00
new GameAction ( "set background fx" , delegate { var e = eventCaller . currentEntity ; KarateMan . instance . SetBgFx ( e . type , e . beat , e . length ) ; } , 0.5f , false , new List < Param > ( )
2022-07-10 02:42:28 +00:00
{
new Param ( "type" , KarateMan . BackgroundFXType . None , "FX Type" , "The background effect to be displayed" )
} ,
2022-08-03 20:14:37 +00:00
hidden : true ) ,
2022-04-12 16:14:46 +00:00
2022-07-29 19:06:22 +00:00
} ) ;
2022-04-12 16:14:46 +00:00
}
}
}
2022-03-14 14:21:05 +00:00
namespace HeavenStudio.Games
2021-12-29 06:52:48 +00:00
{
2022-03-12 04:10:13 +00:00
using Scripts_KarateMan ;
2021-12-29 06:52:48 +00:00
public class KarateMan : Minigame
{
2022-07-29 19:06:22 +00:00
public static KarateMan instance ;
2022-03-01 08:17:06 +00:00
public enum HitType
{
Pot = 0 ,
2022-07-29 19:06:22 +00:00
Lightbulb = 1 ,
2022-03-01 08:17:06 +00:00
Rock = 2 ,
Ball = 3 ,
2022-03-03 04:23:20 +00:00
CookingPot = 6 ,
Alien = 7 ,
TacoBell = 999
2022-03-01 08:17:06 +00:00
}
2022-03-03 21:16:06 +00:00
public enum HitThree
{
HitTwo ,
HitThree ,
HitThreeAlt ,
2022-07-29 19:06:22 +00:00
HitFour ,
Grr ,
Warning ,
Combo ,
HitOne ,
2022-03-03 21:16:06 +00:00
}
2022-02-26 06:31:35 +00:00
public enum LightBulbType
{
2022-02-26 18:57:09 +00:00
Normal ,
Blue ,
Yellow ,
Custom
2022-02-26 06:31:35 +00:00
}
2022-02-26 18:27:02 +00:00
public enum BackgroundType
2022-02-26 06:31:35 +00:00
{
2022-02-26 18:57:09 +00:00
Yellow ,
2022-02-27 23:46:32 +00:00
Fuchsia ,
2022-02-26 18:57:09 +00:00
Blue ,
Red ,
Orange ,
Pink ,
Custom
2022-02-26 18:27:02 +00:00
}
2022-03-01 17:40:59 +00:00
public enum BackgroundFXType
{
None ,
2022-03-01 20:37:06 +00:00
Sunburst ,
2022-07-29 19:06:22 +00:00
Rings ,
Fade
2022-03-01 17:40:59 +00:00
}
2022-08-06 01:19:18 +00:00
public enum BackgroundTextureType
{
Plain ,
Gradient ,
2022-08-06 02:37:06 +00:00
Radial ,
2022-08-06 01:19:18 +00:00
Blood ,
//ManMan?
}
2022-02-27 17:02:46 +00:00
public enum ShadowType
{
Tinted ,
Custom
}
2022-08-03 21:49:32 +00:00
public enum CameraAngle
{
Normal ,
Special
}
2022-08-06 01:19:18 +00:00
public enum ParticleType
{
None ,
Snow ,
Fire ,
Rain
}
2022-08-06 02:37:06 +00:00
public enum KarateManFaces
{
Normal ,
Smirk ,
Surprise ,
Sad ,
Lenny ,
Happy ,
VerySad ,
Blush
}
2022-08-06 01:19:18 +00:00
2022-02-26 18:57:09 +00:00
public Color [ ] LightBulbColors ;
2022-02-26 18:27:02 +00:00
public Color [ ] BackgroundColors ;
2022-02-27 17:02:46 +00:00
public Color [ ] ShadowColors ;
2022-07-29 19:06:22 +00:00
//camera positions (normal, special)
2022-08-06 01:19:18 +00:00
[Header("Camera Positions")]
2022-07-29 19:06:22 +00:00
public Transform [ ] CameraPosition ;
Vector3 cameraPosition ;
2022-08-03 21:49:32 +00:00
float startCamSpecial = Single . MinValue ;
float wantsReturn = Single . MinValue ;
2022-08-06 01:19:18 +00:00
float cameraReturnLength = 2f ;
CameraAngle cameraAngle = CameraAngle . Normal ;
2021-12-30 12:17:22 +00:00
2022-07-29 19:06:22 +00:00
//pot trajectory stuff
2022-08-06 01:19:18 +00:00
[Header("References")]
2022-07-29 19:06:22 +00:00
public Transform ItemHolder ;
public GameObject Item ;
public KarateManJoe Joe ;
2022-01-03 22:42:43 +00:00
2022-08-11 23:36:47 +00:00
[Header("Colour Map")]
public Material MappingMaterial ;
public Color BodyColor ;
public Color HighlightColor ;
public Color ItemColor ;
2022-08-06 01:19:18 +00:00
[Header("Word")]
2022-07-29 19:06:22 +00:00
public Animator Word ;
float wordClearTime = Single . MinValue ;
const float hitVoiceOffset = 0.042f ;
2021-12-30 12:17:22 +00:00
2022-08-06 01:19:18 +00:00
[Header("Backgrounds")]
2022-07-31 01:16:48 +00:00
public SpriteRenderer BGPlane ;
2022-08-03 21:49:32 +00:00
public GameObject BGEffect ;
2022-08-03 22:55:13 +00:00
int bgType = ( int ) BackgroundType . Yellow ;
Color bgColour ;
2022-08-06 23:15:44 +00:00
Color bgColourLast ;
2022-08-03 21:49:32 +00:00
public BackgroundFXType currentBgEffect = BackgroundFXType . None ;
2022-08-06 23:15:44 +00:00
float bgFadeTime = Single . MinValue ;
float bgFadeDuration = 0f ;
2022-08-06 01:19:18 +00:00
2022-08-03 21:49:32 +00:00
Animator bgEffectAnimator ;
SpriteRenderer bgEffectSpriteRenderer ;
2022-07-31 01:16:48 +00:00
2022-08-06 01:19:18 +00:00
int textureFiltertype = ( int ) ShadowType . Tinted ;
2022-08-06 23:15:44 +00:00
Color filterColour ;
Color filterColourNext ;
2022-08-06 01:19:18 +00:00
public GameObject BGGradient ;
SpriteRenderer bgGradientRenderer ;
[Header("Shadows")]
int currentShadowType = ( int ) ShadowType . Tinted ;
2022-08-03 22:55:13 +00:00
Color customShadowColour = Color . white ;
2022-08-06 23:15:44 +00:00
Color fadeShadowColour = Color . white ;
Color oldShadowColour ;
2022-08-03 22:55:13 +00:00
2022-08-06 01:19:18 +00:00
[Header("Particles")]
//wind
public WindZone Wind ;
//snow
public ParticleSystem SnowEffect ;
public GameObject SnowEffectGO ;
//fire
public ParticleSystem FireEffect ;
public GameObject FireEffectGO ;
//rain
public ParticleSystem RainEffect ;
public GameObject RainEffectGO ;
2021-12-29 06:52:48 +00:00
private void Awake ( )
{
instance = this ;
2022-07-29 19:06:22 +00:00
KarateManPot . ResetLastCombo ( ) ;
cameraPosition = CameraPosition [ 0 ] . position ;
2022-02-26 18:27:02 +00:00
}
2022-07-29 19:06:22 +00:00
private void Start ( )
2022-02-26 18:27:02 +00:00
{
2022-07-29 19:06:22 +00:00
GameCamera . additionalPosition = cameraPosition - GameCamera . defaultPosition ;
2022-08-03 21:49:32 +00:00
bgEffectAnimator = BGEffect . GetComponent < Animator > ( ) ;
bgEffectSpriteRenderer = BGEffect . GetComponent < SpriteRenderer > ( ) ;
2022-08-03 22:55:13 +00:00
2022-08-06 01:19:18 +00:00
bgGradientRenderer = BGGradient . GetComponent < SpriteRenderer > ( ) ;
2022-08-07 01:09:28 +00:00
SetBgAndShadowCol ( 0f , 0f , bgType , ( int ) currentShadowType , BackgroundColors [ bgType ] , customShadowColour , ( int ) currentBgEffect ) ;
2022-08-11 23:36:47 +00:00
UpdateMaterialColour ( BodyColor , HighlightColor , ItemColor ) ;
2021-12-29 06:52:48 +00:00
}
2022-07-29 19:06:22 +00:00
private void Update ( )
2022-01-20 01:48:52 +00:00
{
2022-08-03 21:49:32 +00:00
var cond = Conductor . instance ;
2022-08-07 23:40:06 +00:00
if ( ! cond . isPlaying )
SetBgEffectsToLast ( cond . songPositionInBeats ) ;
2022-08-03 21:49:32 +00:00
switch ( currentBgEffect )
{
case BackgroundFXType . Sunburst :
bgEffectAnimator . DoNormalizedAnimation ( "Sunburst" , ( cond . songPositionInBeats * 0.5f ) % 1f ) ;
break ;
case BackgroundFXType . Rings :
bgEffectAnimator . DoNormalizedAnimation ( "Rings" , ( cond . songPositionInBeats * 0.5f ) % 1f ) ;
break ;
default :
bgEffectAnimator . Play ( "NoPose" , - 1 , 0 ) ;
break ;
}
if ( cond . songPositionInBeats > = wordClearTime )
2022-01-20 01:48:52 +00:00
{
2022-07-29 19:06:22 +00:00
Word . Play ( "NoPose" ) ;
2022-01-20 01:48:52 +00:00
}
2022-08-03 21:49:32 +00:00
if ( cond . songPositionInBeats > = startCamSpecial & & cond . songPositionInBeats < = wantsReturn )
{
float camX = 0f ;
float camY = 0f ;
float camZ = 0f ;
2022-08-06 01:19:18 +00:00
if ( cond . songPositionInBeats < = startCamSpecial + cameraReturnLength )
2022-08-03 21:49:32 +00:00
{
2022-08-06 01:19:18 +00:00
float prog = cond . GetPositionFromBeat ( startCamSpecial , cameraReturnLength ) ;
2022-08-03 21:49:32 +00:00
camX = EasingFunction . EaseOutCubic ( CameraPosition [ 0 ] . position . x , CameraPosition [ 1 ] . position . x , prog ) ;
camY = EasingFunction . EaseOutCubic ( CameraPosition [ 0 ] . position . y , CameraPosition [ 1 ] . position . y , prog ) ;
camZ = EasingFunction . EaseOutCubic ( CameraPosition [ 0 ] . position . z , CameraPosition [ 1 ] . position . z , prog ) ;
cameraPosition = new Vector3 ( camX , camY , camZ ) ;
}
2022-08-06 01:19:18 +00:00
else if ( cond . songPositionInBeats > = wantsReturn - cameraReturnLength )
2022-08-03 21:49:32 +00:00
{
2022-08-06 01:19:18 +00:00
float prog = cond . GetPositionFromBeat ( wantsReturn - cameraReturnLength , cameraReturnLength ) ;
2022-08-03 21:49:32 +00:00
camX = EasingFunction . EaseOutQuad ( CameraPosition [ 1 ] . position . x , CameraPosition [ 0 ] . position . x , prog ) ;
camY = EasingFunction . EaseOutQuad ( CameraPosition [ 1 ] . position . y , CameraPosition [ 0 ] . position . y , prog ) ;
camZ = EasingFunction . EaseOutQuad ( CameraPosition [ 1 ] . position . z , CameraPosition [ 0 ] . position . z , prog ) ;
cameraPosition = new Vector3 ( camX , camY , camZ ) ;
}
else
{
cameraPosition = CameraPosition [ 1 ] . position ;
}
}
else
{
2022-08-06 01:19:18 +00:00
if ( cameraAngle = = CameraAngle . Special )
cameraAngle = CameraAngle . Normal ;
2022-08-03 21:49:32 +00:00
cameraPosition = CameraPosition [ 0 ] . position ;
}
2022-08-06 23:15:44 +00:00
float fadeProg = cond . GetPositionFromBeat ( bgFadeTime , bgFadeDuration ) ;
if ( bgFadeTime ! = Single . MinValue & & fadeProg > = 0 )
{
if ( fadeProg > = 1f )
{
bgFadeTime = Single . MinValue ;
bgFadeDuration = 0f ;
BGPlane . color = bgColour ;
filterColour = filterColourNext ;
UpdateFilterColour ( bgColour , filterColour ) ;
oldShadowColour = GetShadowColor ( true ) ;
}
else
{
Color col = Color . LerpUnclamped ( bgColourLast , bgColour , fadeProg ) ;
BGPlane . color = col ;
UpdateFilterColour ( col , Color . LerpUnclamped ( filterColour , filterColourNext , fadeProg ) ) ;
}
}
2022-08-03 21:49:32 +00:00
GameCamera . additionalPosition = cameraPosition - GameCamera . defaultPosition ;
BGEffect . transform . position = new Vector3 ( GameCamera . instance . transform . position . x , GameCamera . instance . transform . position . y , 0 ) ;
}
public void DoSpecialCamera ( float beat , float length , bool returns )
{
2022-08-06 01:19:18 +00:00
if ( cameraAngle = = CameraAngle . Normal )
{
startCamSpecial = beat ;
cameraAngle = CameraAngle . Special ;
}
wantsReturn = returns ? beat + length : Single . MaxValue ;
cameraReturnLength = Mathf . Min ( 2f , length * 0.5f ) ;
2022-01-20 01:48:52 +00:00
}
2022-08-07 23:40:06 +00:00
public void DoWord ( float beat , int type , bool doSound = true )
2021-12-30 12:17:22 +00:00
{
2022-08-07 23:40:06 +00:00
String word = "NoPose" ;
float clear = 0f ;
2022-07-29 19:06:22 +00:00
switch ( type )
2021-12-30 12:17:22 +00:00
{
2022-07-29 19:06:22 +00:00
case ( int ) HitThree . HitTwo :
2022-08-07 23:40:06 +00:00
word = "Word02" ;
clear = beat + 4f ;
if ( doSound )
MultiSound . Play ( new MultiSound . Sound [ ]
{
new MultiSound . Sound ( "karateman/hit" , beat + 0.5f , offset : hitVoiceOffset ) ,
new MultiSound . Sound ( "karateman/two" , beat + 1f ) ,
} , forcePlay : true ) ;
2022-07-29 19:06:22 +00:00
break ;
case ( int ) HitThree . HitThree :
2022-08-07 23:40:06 +00:00
word = "Word03" ;
clear = beat + 4f ;
if ( doSound )
MultiSound . Play ( new MultiSound . Sound [ ]
{
new MultiSound . Sound ( "karateman/hit" , beat + 0.5f , offset : hitVoiceOffset ) ,
new MultiSound . Sound ( "karateman/three" , beat + 1f ) ,
} , forcePlay : true ) ;
2022-07-29 19:06:22 +00:00
break ;
case ( int ) HitThree . HitThreeAlt :
2022-08-07 23:40:06 +00:00
word = "Word03" ;
clear = beat + 4f ;
if ( doSound )
MultiSound . Play ( new MultiSound . Sound [ ]
{
new MultiSound . Sound ( "karateman/hitAlt" , beat + 0.5f , offset : hitVoiceOffset ) ,
new MultiSound . Sound ( "karateman/threeAlt" , beat + 1f ) ,
} , forcePlay : true ) ;
2022-07-29 19:06:22 +00:00
break ;
case ( int ) HitThree . HitFour :
2022-08-07 23:40:06 +00:00
word = "Word04" ;
clear = beat + 4f ;
if ( doSound )
MultiSound . Play ( new MultiSound . Sound [ ]
{
new MultiSound . Sound ( "karateman/hit" , beat + 0.5f , offset : hitVoiceOffset ) ,
new MultiSound . Sound ( "karateman/four" , beat + 1f ) ,
} , forcePlay : true ) ;
2022-07-29 19:06:22 +00:00
break ;
case ( int ) HitThree . Grr :
2022-08-07 23:40:06 +00:00
word = "Word01" ;
clear = beat + 1f ;
2022-07-29 19:06:22 +00:00
break ;
case ( int ) HitThree . Warning :
2022-08-07 23:40:06 +00:00
word = "Word05" ;
clear = beat + 1f ;
2022-07-29 19:06:22 +00:00
break ;
case ( int ) HitThree . Combo :
2022-08-07 23:40:06 +00:00
word = "Word00" ;
clear = beat + 3f ;
2022-07-29 19:06:22 +00:00
break ;
case ( int ) HitThree . HitOne : //really?
2022-08-07 23:40:06 +00:00
word = "Word06" ;
clear = beat + 4f ;
if ( doSound )
MultiSound . Play ( new MultiSound . Sound [ ]
{
new MultiSound . Sound ( "karateman/hit" , beat + 0.5f , offset : hitVoiceOffset ) ,
new MultiSound . Sound ( "karateman/one" , beat + 1f ) ,
} , forcePlay : true ) ;
2022-07-29 19:06:22 +00:00
break ;
2022-02-14 13:48:41 +00:00
}
2022-08-07 23:40:06 +00:00
if ( Conductor . instance . songPositionInBeats < = clear & & Conductor . instance . songPositionInBeats > = beat )
{
Word . Play ( word ) ;
wordClearTime = clear ;
}
2021-12-30 12:17:22 +00:00
}
2022-07-29 19:06:22 +00:00
public void CreateItem ( float beat , int type )
2021-12-30 12:17:22 +00:00
{
2022-03-01 20:37:06 +00:00
2022-07-29 19:06:22 +00:00
string outSound ;
if ( Starpelly . Mathp . GetDecimalFromFloat ( beat + 0.5f ) = = 0f )
outSound = "karateman/offbeatObjectOut" ;
2022-03-01 17:40:59 +00:00
else
2022-07-29 19:06:22 +00:00
outSound = "karateman/objectOut" ;
switch ( type )
2022-03-01 17:40:59 +00:00
{
2022-07-29 19:06:22 +00:00
case ( int ) HitType . Pot :
CreateItemInstance ( beat , "Item00" ) ;
break ;
case ( int ) HitType . Lightbulb :
if ( Starpelly . Mathp . GetDecimalFromFloat ( beat + 0.5f ) = = 0f )
outSound = "karateman/offbeatLightbulbOut" ;
else
outSound = "karateman/lightbulbOut" ;
var mobj = CreateItemInstance ( beat , "Item01" , KarateManPot . ItemType . Bulb ) ;
mobj . GetComponent < KarateManPot > ( ) . SetBulbColor ( LightBulbColors [ 0 ] ) ;
break ;
case ( int ) HitType . Rock :
CreateItemInstance ( beat , "Item02" , KarateManPot . ItemType . Rock ) ;
break ;
case ( int ) HitType . Ball :
CreateItemInstance ( beat , "Item03" , KarateManPot . ItemType . Ball ) ;
break ;
case ( int ) HitType . CookingPot :
CreateItemInstance ( beat , "Item06" , KarateManPot . ItemType . Cooking ) ;
break ;
case ( int ) HitType . Alien :
CreateItemInstance ( beat , "Item07" , KarateManPot . ItemType . Alien ) ;
break ;
case ( int ) HitType . TacoBell :
CreateItemInstance ( beat , "Item99" , KarateManPot . ItemType . TacoBell ) ;
break ;
default :
CreateItemInstance ( beat , "Item00" ) ;
break ;
2022-03-01 17:40:59 +00:00
}
2022-07-29 19:06:22 +00:00
Jukebox . PlayOneShotGame ( outSound , forcePlay : true ) ;
2022-02-26 18:27:02 +00:00
}
2022-07-29 19:06:22 +00:00
public void CreateBulbSpecial ( float beat , int type , Color c )
2022-02-26 18:27:02 +00:00
{
2022-07-29 19:06:22 +00:00
string outSound ;
if ( Starpelly . Mathp . GetDecimalFromFloat ( beat + 0.5f ) = = 0f )
outSound = "karateman/offbeatLightbulbOut" ;
else
outSound = "karateman/lightbulbOut" ;
var mobj = CreateItemInstance ( beat , "Item01" , KarateManPot . ItemType . Bulb ) ;
2021-12-30 12:17:22 +00:00
2022-07-29 19:06:22 +00:00
if ( type = = ( int ) LightBulbType . Custom )
mobj . GetComponent < KarateManPot > ( ) . SetBulbColor ( c ) ;
else
mobj . GetComponent < KarateManPot > ( ) . SetBulbColor ( LightBulbColors [ type ] ) ;
Jukebox . PlayOneShotGame ( outSound , forcePlay : true ) ;
2021-12-29 06:52:48 +00:00
}
2022-01-19 05:40:49 +00:00
2022-07-29 19:06:22 +00:00
public void Combo ( float beat )
2022-03-03 21:16:06 +00:00
{
2022-07-29 19:06:22 +00:00
Jukebox . PlayOneShotGame ( "karateman/barrelOutCombos" , forcePlay : true ) ;
2022-03-03 21:16:06 +00:00
2022-07-29 19:06:22 +00:00
int comboId = KarateManPot . GetNewCombo ( ) ;
BeatAction . New ( gameObject , new List < BeatAction . Action > ( )
2022-01-21 07:09:32 +00:00
{
2022-07-29 19:06:22 +00:00
new BeatAction . Action ( beat , delegate { CreateItemInstance ( beat , "Item00" , KarateManPot . ItemType . ComboPot1 , comboId ) ; } ) ,
new BeatAction . Action ( beat + 0.25f , delegate { CreateItemInstance ( beat + 0.25f , "Item00" , KarateManPot . ItemType . ComboPot2 , comboId ) ; } ) ,
new BeatAction . Action ( beat + 0.5f , delegate { CreateItemInstance ( beat + 0.5f , "Item00" , KarateManPot . ItemType . ComboPot3 , comboId ) ; } ) ,
new BeatAction . Action ( beat + 0.75f , delegate { CreateItemInstance ( beat + 0.75f , "Item00" , KarateManPot . ItemType . ComboPot4 , comboId ) ; } ) ,
new BeatAction . Action ( beat + 1f , delegate { CreateItemInstance ( beat + 1f , "Item00" , KarateManPot . ItemType . ComboPot5 , comboId ) ; } ) ,
new BeatAction . Action ( beat + 1.5f , delegate { CreateItemInstance ( beat + 1.5f , "Item05" , KarateManPot . ItemType . ComboBarrel , comboId ) ; } ) ,
2022-01-21 07:09:32 +00:00
} ) ;
2022-07-29 19:06:22 +00:00
MultiSound . Play ( new MultiSound . Sound [ ]
2022-01-21 07:09:32 +00:00
{
2022-07-29 19:06:22 +00:00
new MultiSound . Sound ( "karateman/punchy1" , beat + 1f ) ,
new MultiSound . Sound ( "karateman/punchy2" , beat + 1.25f ) ,
new MultiSound . Sound ( "karateman/punchy3" , beat + 1.5f ) ,
new MultiSound . Sound ( "karateman/punchy4" , beat + 1.75f ) ,
new MultiSound . Sound ( "karateman/ko" , beat + 2f ) ,
new MultiSound . Sound ( "karateman/pow" , beat + 2.5f )
} , forcePlay : true ) ;
2022-01-19 05:40:49 +00:00
}
2022-02-27 03:28:15 +00:00
2022-07-29 19:26:59 +00:00
public void Kick ( float beat )
{
Jukebox . PlayOneShotGame ( "karateman/barrelOutKicks" , forcePlay : true ) ;
CreateItemInstance ( beat , "Item05" , KarateManPot . ItemType . KickBarrel ) ;
MultiSound . Play ( new MultiSound . Sound [ ]
{
new MultiSound . Sound ( "karateman/punchKick1" , beat + 1f ) ,
new MultiSound . Sound ( "karateman/punchKick2" , beat + 1.5f ) ,
new MultiSound . Sound ( "karateman/punchKick3" , beat + 1.75f ) ,
new MultiSound . Sound ( "karateman/punchKick4" , beat + 2.5f ) ,
} , forcePlay : true ) ;
}
2022-07-31 01:16:48 +00:00
public GameObject CreateItemInstance ( float beat , string awakeAnim , KarateManPot . ItemType type = KarateManPot . ItemType . Pot , int comboId = - 1 )
2022-02-27 03:28:15 +00:00
{
2022-07-29 19:06:22 +00:00
GameObject mobj = GameObject . Instantiate ( Item , ItemHolder ) ;
KarateManPot mobjDat = mobj . GetComponent < KarateManPot > ( ) ;
mobjDat . type = type ;
mobjDat . startBeat = beat ;
mobjDat . awakeAnim = awakeAnim ;
mobjDat . comboId = comboId ;
mobj . SetActive ( true ) ;
2022-02-27 17:02:46 +00:00
2022-07-29 19:06:22 +00:00
return mobj ;
2022-02-27 03:28:15 +00:00
}
2022-08-03 22:55:13 +00:00
2022-08-07 23:40:06 +00:00
void SetBgEffectsToLast ( float beat )
{
var bgfx = GameManager . instance . Beatmap . entities . FindAll ( en = > en . datamodel = = "karateman/set background effects" ) ;
for ( int i = 0 ; i < bgfx . Count ; i + + )
{
var e = bgfx [ i ] ;
if ( e . beat > beat )
break ;
SetBgAndShadowCol ( e . beat , e . length , e . type , e . type2 , e . colorA , e . colorB , e . type3 ) ;
}
var bgtex = GameManager . instance . Beatmap . entities . FindAll ( en = > en . datamodel = = "karateman/set background texture" ) ;
for ( int i = 0 ; i < bgtex . Count ; i + + )
{
var e = bgtex [ i ] ;
if ( e . beat > beat )
break ;
SetBgTexture ( e . type , e . type2 , e . colorA , e . colorB ) ;
}
// has issues when creating a new hitx entity so this is deactivated for now
// var hitx = GameManager.instance.Beatmap.entities.FindAll(en => en.datamodel == "karateman/hitX");
// for (int i = 0; i < hitx.Count; i++)
// {
// var e = hitx[i];
// if (e.beat > beat)
// break;
// Debug.Log("hitx");
// DoWord(e.beat, e.type, false);
// }
}
2022-08-07 01:09:28 +00:00
public void SetBgAndShadowCol ( float beat , float length , int bgType , int shadowType , Color a , Color b , int fx )
2022-08-03 22:55:13 +00:00
{
2022-08-06 23:15:44 +00:00
SetBgFx ( fx , beat , length ) ;
2022-08-07 01:09:28 +00:00
UpdateShadowColour ( shadowType , b ) ;
2022-08-06 23:15:44 +00:00
this . bgType = bgType ;
if ( this . bgType = = ( int ) BackgroundType . Custom )
bgColour = a ;
else
bgColour = BackgroundColors [ this . bgType ] ;
BGPlane . color = bgColour ;
2022-08-07 01:09:28 +00:00
//😢
if ( fx ! = ( int ) BackgroundFXType . Fade )
oldShadowColour = GetShadowColor ( true ) ;
2022-08-06 23:15:44 +00:00
if ( textureFiltertype = = ( int ) ShadowType . Tinted )
filterColour = Color . LerpUnclamped ( bgColour , ShadowBlendColor , 0.45f ) ;
}
public void SetBgFx ( int fx , float beat , float length )
{
switch ( fx )
2022-08-03 22:55:13 +00:00
{
2022-08-06 23:15:44 +00:00
case ( int ) BackgroundFXType . Fade :
bgColourLast = bgColour ;
bgFadeTime = beat ;
bgFadeDuration = length ;
break ;
default :
currentBgEffect = ( BackgroundFXType ) fx ;
break ;
2022-08-03 22:55:13 +00:00
}
2022-08-06 23:15:44 +00:00
}
public void SetBgTexture ( int type , int filterType , Color filterColor , Color nextColor )
{
textureFiltertype = filterType ;
if ( textureFiltertype = = ( int ) ShadowType . Tinted )
filterColour = Color . LerpUnclamped ( bgColour , filterColor , 0.45f ) ;
else
{
filterColour = filterColor ;
filterColourNext = nextColor ;
}
switch ( type )
2022-08-03 22:55:13 +00:00
{
2022-08-06 23:15:44 +00:00
case ( int ) BackgroundTextureType . Gradient :
BGGradient . SetActive ( true ) ;
break ;
default :
BGGradient . SetActive ( false ) ;
break ;
2022-08-03 22:55:13 +00:00
}
2022-08-06 23:15:44 +00:00
UpdateFilterColour ( bgColour , filterColour ) ;
}
void UpdateFilterColour ( Color bgColor , Color filterColor )
{
Color col ;
if ( textureFiltertype = = ( int ) ShadowType . Tinted )
col = Color . LerpUnclamped ( bgColor , ShadowBlendColor , 0.45f ) ;
else
col = filterColor ;
2022-08-03 22:55:13 +00:00
2022-08-06 23:15:44 +00:00
bgGradientRenderer . color = col ;
}
public static Color ShadowBlendColor = new Color ( 195 / 255f , 48 / 255f , 2 / 255f ) ;
public Color GetShadowColor ( bool next = false )
{
Color lastCol , nextCol ;
lastCol = oldShadowColour ;
if ( currentShadowType = = ( int ) ShadowType . Custom )
2022-08-07 01:09:28 +00:00
nextCol = customShadowColour ;
2022-08-06 23:15:44 +00:00
else if ( bgType < ( int ) BackgroundType . Custom )
nextCol = ShadowColors [ bgType ] ;
else
nextCol = Color . LerpUnclamped ( bgColour , ShadowBlendColor , 0.45f ) ;
float fadeProg = Conductor . instance . GetPositionFromBeat ( bgFadeTime , bgFadeDuration ) ;
if ( fadeProg < = 1f & & fadeProg > = 0 )
{
return Color . LerpUnclamped ( lastCol , nextCol , fadeProg ) ;
}
return next ? nextCol : lastCol ;
2022-08-03 22:55:13 +00:00
}
2022-08-07 01:09:28 +00:00
public void UpdateShadowColour ( int type , Color colour )
2022-08-03 22:55:13 +00:00
{
2022-08-06 23:15:44 +00:00
if ( currentShadowType = = ( int ) ShadowType . Custom )
oldShadowColour = customShadowColour ;
else if ( bgType < ( int ) BackgroundType . Custom )
oldShadowColour = ShadowColors [ bgType ] ;
else
oldShadowColour = Color . LerpUnclamped ( bgColour , ShadowBlendColor , 0.45f ) ;
2022-08-06 01:19:18 +00:00
currentShadowType = type ;
2022-08-03 22:55:13 +00:00
customShadowColour = colour ;
}
2022-08-06 01:19:18 +00:00
2022-08-11 23:36:47 +00:00
public void UpdateMaterialColour ( Color mainCol , Color highlightCol , Color objectCol )
{
MappingMaterial . SetColor ( "_ColorAlpha" , mainCol ) ;
MappingMaterial . SetColor ( "_ColorBravo" , new Color ( 1 , 0 , 0 , 1 ) ) ;
MappingMaterial . SetColor ( "_ColorDelta" , highlightCol ) ;
ItemColor = objectCol ;
//TODO: joe fist colour when punching Straight with low flow
}
2022-08-06 01:19:18 +00:00
public void SetParticleEffect ( float beat , int type , float windStrength , float particleStrength )
{
2022-08-07 23:40:06 +00:00
ParticleSystem . EmissionModule emm ;
2022-08-06 01:19:18 +00:00
switch ( type )
{
case ( int ) ParticleType . Snow :
SnowEffectGO . SetActive ( true ) ;
SnowEffect . Play ( ) ;
emm = SnowEffect . emission ;
2022-08-07 23:40:06 +00:00
emm . rateOverTime = particleStrength * 6f ;
2022-08-06 01:19:18 +00:00
break ;
case ( int ) ParticleType . Fire :
FireEffectGO . SetActive ( true ) ;
FireEffect . Play ( ) ;
emm = FireEffect . emission ;
2022-08-07 23:40:06 +00:00
emm . rateOverTime = particleStrength * 6f ;
2022-08-06 01:19:18 +00:00
break ;
case ( int ) ParticleType . Rain :
RainEffectGO . SetActive ( true ) ;
RainEffect . Play ( ) ;
emm = RainEffect . emission ;
emm . rateOverTime = particleStrength * 32f ;
break ;
default :
SnowEffect . Stop ( ) ;
2022-08-06 23:15:44 +00:00
FireEffect . Stop ( ) ;
RainEffect . Stop ( ) ;
2022-08-06 01:19:18 +00:00
break ;
}
Wind . windMain = windStrength ;
}
2022-08-06 02:37:06 +00:00
2022-08-07 23:40:06 +00:00
public void ToggleBop ( bool toggle )
{
if ( toggle )
Joe . bop . length = Single . MaxValue ;
else
Joe . bop . length = 0 ;
}
public void Prepare ( float beat , float length )
{
Joe . Prepare ( beat , length ) ;
}
2022-08-06 02:37:06 +00:00
public void SetFaceExpression ( int face )
{
Joe . SetFaceExpression ( face ) ;
}
2021-12-29 06:52:48 +00:00
}
2022-08-11 23:36:47 +00:00
}